views:

308

answers:

2

Hi everyone.

I have a PHP script which works and i need to write the same in Python but SOAPpy generates a slightly different request and i'm not sure how to fix it so the server likes it.

The request generated by php script looks like this:

<?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>

When trying to make the same using SOAPPy i get this request:

<?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"&gt;
<includeDeleted xsi:type="xsd:boolean">False</includeDeleted>
<accountID xsi:type="xsd:integer">6674262970</accountID>
</ns1:getCampaignsByAccountID>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

A slightly different request but i guess it should work but i get an error from the server: "Account ID specified in the

header does not match the one specified in the parameter."

But they do match!

The only thing i see is some difference in namespaces, but i have no idea what to do right now. Please help.

A: 

accountID should be of type xsd:string rather than xsd:integer. (maybe you're passing a string instead of an integer and that is why SOAPpy does it that way?)

I tried to pass it as string as well, with the same result unfortunately. But thanks for the answer anyway :) Deadline's approaching so I'm trying to work around without SOAPpy now.
Andrey
+1  A: 

The problem was not about SOAP headers format but just about the parameter order. Here's the full explanation and code: http://pea.somemilk.org/2009/04/05/yahoo-search-marketing-python-soap-binding/

Andrey