【问题标题】:How to access Yahoo Enterprise Web Services using Python SOAPpy?如何使用 Python SOAPpy 访问 Yahoo Enterprise Web Services?
【发布时间】:2009-03-18 09:08:57
【问题描述】:

我有一个可以工作的 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>

当尝试使用 SOAPPy 做同样的事情时,我收到了这个请求:

<?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 与参数中指定的不匹配。"

但它们确实匹配!

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

【问题讨论】:

    标签: python soap soappy


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      accountID 的类型应该是 xsd:string 而不是 xsd:integer。 (也许您传递的是字符串而不是整数,这就是 SOAPpy 这样做的原因?)

      【讨论】:

      • 我也尝试将它作为字符串传递,不幸的是结果相同。但无论如何感谢您的回答:) 截止日期快到了,所以我现在尝试在没有 SOAPpy 的情况下解决问题。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多