我正在尝试使用python中的zeep模块发送SOAP请求。 python -mzeep XXXXXXXX.wsdl 返回以下内容:
前缀:
xsd: http://www.AA.org/2003/XMLSchema
ns0: http://www.bbbb.com/PM/BLS
全局元素:
ns0:GetBalReq(header: ns0:RequestHeader, custId: xsd:string, customAvpList: ns0:AttributeValuePairList)
ns0:GetBalResp(nalId: xsd:string, custId: xsd:string, custRole: xsd:string, nalType: xsd:string, bal: ns0:BalDetailsList, customAvpList: ns0:AttributeValuePairList)
全局类型:
xsd:anyType
ns0:AttributeValuePair(attribute: xsd:string, value: xsd:string)
ns0:AttributeValuePairList(item: ns0:AttributeValuePair[])
ns0:BalDetailsList(item: ns0:BalDetails[])
ns0:RequestHeader(auditInfo: xsd:string, transactionId: xsd:string)
xsd:string
绑定:
Soap11Binding: {http://www.bbbb.com/PM/BLS}BLS
服务:BLS
Port: BLS (Soap11Binding: {http://www.bbbb.com/PM/BLS}BLS)
Operations:
getBalReq(header: ns0:RequestHeader, custId: xsd:string, customAvpList: ns0:AttributeValuePairList) -> nalId: xsd:string, custId: xsd:string, custRole: xsd:string, nalType: xsd:string, bal: ns0:BalDetailsList, customAvpList: ns0:AttributeValuePairList
只需遵循以下步骤:
from zeep import Client
client = Client('XXXXXXXX.wsdl')
client.service.getBalReq(custId='12345678')
我收到以下错误:
"Missing element %s" % (self.name), path=render_path
zeep.exceptions.ValidationError: Missing element header (GetBalReq.header)
现在,过去两天来,我一直在绞尽脑汁,如何进行这项工作,如何发送适当的请求以获取有效的响应,阅读zeep文档,论坛等,但是却无法解决。有适当代码的想法吗?
答案 0 :(得分:0)
您必须将参数“标头”传递给方法“ getBalReq”,如下所示。
from zeep import Client
client = Client('XXXXXXXX.wsdl')
header_request = client.get_type('ns0:RequestHeader')
header = header_request(auditInfo = your_auditInfo,transactionId = your_transactionId)
client.service.getBalReq(header=header, custId='12345678', customAvpList = your_customAvpList)
如果customAvpList是可选参数,则可以忽略它。