python - 如何使用 Python SOAPpy 访问 Yahoo Enterprise Web Services?

标签 python soap soappy

我有一个可以运行的 PHP 脚本,我需要用 Python 编写相同的脚本,但 SOAPpy 生成的请求略有不同,我不知道如何修复它,以便服务器喜欢它。

php脚本生成的请求如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://marketing.ews.yahooapis.com/V4"
>
<SOAP-ENV:Header>
<ns1:username>*****</ns1:username>
<ns1:password>*****</ns1:password>
<ns1:masterAccountID>*****</ns1:masterAccountID>
<ns1:accountID>6674262970</ns1:accountID>
<ns1:license>*****</ns1:license>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:getCampaignsByAccountID>
<ns1:accountID>6674262970</ns1:accountID>
<ns1:includeDeleted>false</ns1:includeDeleted>
</ns1:getCampaignsByAccountID>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

当尝试使用 SOAPy 进行相同操作时,我收到此请求:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
>
<SOAP-ENV:Header>
<username xsi:type="xsd:string">*****</username>
<masterAccountID xsi:type="xsd:string">*****</masterAccountID>
<license xsi:type="xsd:string">*****</license>
<accountID xsi:type="xsd:integer">6674262970</accountID>
<password xsi:type="xsd:string">*****</password>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:getCampaignsByAccountID xmlns:ns1="http://marketing.ews.yahooapis.com/V4">
<includeDeleted xsi:type="xsd:boolean">False</includeDeleted>
<accountID xsi:type="xsd:integer">6674262970</accountID>
</ns1:getCampaignsByAccountID>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

请求略有不同,但我想它应该可以工作,但我从服务器收到错误:“在

中指定的帐户 ID

header 与参数中指定的 header 不匹配。”

但它们确实匹配!

我唯一看到的是命名空间中的一些差异,但我不知道现在该怎么做。请帮忙。

最佳答案

问题不在于 SOAP header 格式,而在于参数顺序。这是完整的解释和代码:http://pea.somemilk.org/2009/04/05/yahoo-search-marketing-python-soap-binding/

关于python - 如何使用 Python SOAPpy 访问 Yahoo Enterprise Web Services?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/657473/

相关文章:

c# - 比较图像文件

python - 用于测试soap客户端的公共(public)免费网络服务

python - 将 Cookie 添加到 ZSI 帖子

python - 带 for 循环的非常小的数字 python

python - 替换对应于另一个数组的索引数组中的值

python - 如何以跨平台方式从另一个 Python 脚本运行 Python 脚本?

java - Java 中基于 HTTPS 的 WSDL

java - 如何在CXF中重命名SOAP响应的元素?

c++ - gSOAP - 如何使用 SSL 和自签名证书

python - 变量的类型是什么