Zeep客户端WSDL请求意外的关键字参数



我正在尝试基于EntityId向SOAP API写入请求。我无法提取使用python-mzeep列出的服务,因为我需要一个证书/密钥来访问WSDL。然而,我确实发现了https://stackoverflow.com/a/50093489/2607773帮助我得到了这个:

{'Blah': {'WSHttpBinding_IBlah': 
{'operations': {'EntitySearch': 
input': {'request': {'optional': True, 'type': 
{'EntityId': {'optional': False, 'type': 'Long(value)'}, 
'LName': {'optional': True, 'type': 'String(value)'}, 
'FName': {'optional': True, 'type': 'String(value)'} 
}
}
}
}
}
}
} 

这是我的代码,我正在使用它来尝试查询EntityId:的SOAP API

from requests import Session
from zeep import Client
from zeep.transports import Transport
from zeep.wsa import WsAddressingPlugin
import contextlib
import OpenSSL.crypto
import os
import requests
import ssl
import tempfile
import certifi
import http.client
from OpenSSL import crypto
from zeep.wsse.signature import Signature
import xmlsec
import pprint
test_filename = 'C:\Users\Me\Desktop\test.pem'
session = Session()
session.cert = (test_filename)
client = Client('https://blah.blahblah.local:90/Blah.ProxyService/Blah.svc?singleWsdl',transport=Transport(session=session))
result = client.service.EntitySearch(EntityId = 100000)

当我尝试这个代码时,我得到以下错误:

TypeError: {http://HSDService}EntitySearch() got an unexpected keyword argument 'EntityId'. Signature: `request: {EntityId: xsd:long, LName: xsd:string, FName: xsd:string}`

我不确定这个请求哪里出了问题,但我认为这可能是一个简单的错误,我在尝试查询EntityId时没有看到。在这一点上,我对任何想法都持开放态度。

使用我关于签证卡的简单示例,您可以轻松地编辑代码

client = Client("https://example.com/CARDS/STWS?wsdl")
req_data = {
"StPimsApiPartnerKey": "your-api-partner-key",
"AccessToken": "your-access-token",
"CardNumber": "your-card-number",
"CardExDate": "your-expire-date",
"CardHolderName": "your-holder-name",
"CardCVV": "your-card-cvv",
"PhoneNumber": "your-phone-number",
} # should be dict dont use ** for send data like **req_data
result = client.service.partnerRegisterCardIPS(req_data)
print(result)
I think it's very helpfull for you.

最终我自己解决了这个问题,因为我没有像应该的那样使用字典来处理我的请求。

这就是最终对我有效的:

test_filename = 'C:\Users\Me\Desktop\test.pem'
session = Session()
session.cert = (test_filename)
session.verify = False
client = Client('https://blah.blahblah.cloudapp.azure.com:90/blah.ProxyService/BlahSvc.svc?singleWsdl',transport=Transport(session=session))
request_data = { #'EntityId': 100000
}
print(client.service.EntitySearch(request_data))

最新更新