我需要使用python SOAPpy模块构造这个SOAP查询:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<LicenseHeader xmlns="http://schemas.acme.eu/">
<LicenseKey>88888-88888-8888-8888-888888888888</LicenseKey>
</LicenseHeader>
</soap:Header>
<soap:Body>
<GetProductClassification xmlns="http://schemas.acme.eu/">
<GetProductClassificationRequest />
</GetProductClassification>
</soap:Body>
</soap:Envelope>
所以我用这个代码:
^{pr2}$生成的请求是:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
>
<SOAP-ENV:Body>
<GetProductClassification SOAP-ENC:root="1">
</GetProductClassification>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
当我发送请求时,我得到Object reference not set to an instance of an object.
我想这可能是因为我的请求中没有带有许可证密钥的header
部分。在
如何修改代码以添加带有LicenseHeader
参数的header
部分?在
我不知道怎么用肥皂水做这个,但我知道怎么用肥皂水。SUDS的功能与SOAPpy相同,但它较新,并且仍然受支持。我觉得索比不再受支持了。下面显示连接到WSDL并发送soap请求的代码:
在发送soap请求之前将其放入脚本中,它将添加所需的任何头。在
^{pr2}$这将允许您添加wsa encing,使XML能够理解:
如果你使用这样的东西,你将能够添加任何标题,名称空间等。我用过这个,它工作得很好。在
要在SUDS中添加许可证头,请添加:
相关问题 更多 >
编程相关推荐