1

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

一个稍微不同的请求,但我想它应该可以工作,但我从服务器收到一个错误:“在

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

但他们确实匹配!

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

4

2 回答 2

2

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

于 2009-04-17T14:54:47.440 回答
0

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

于 2009-03-18T10:46:21.603 回答