开发者

Python - SUDS SOAP Invalid namespaces - channel advisor?

At work I have to access/work with the Channel Advisor API

http://developer.channeladvisor.com/display/cadn/Order+Service

Source:

I'm attempting to perform a simple ping

from suds.client import Client
url = 'https://api.channeladvisor.com/ChannelAdvisorAPI/v4/OrderService.asmx?WSDL'
soap_client = Client(url, location='https://api.channeladvisor.com/ChannelAdvisorAPI/v4/OrderService.asmx')

soap_client.set_options(port='OrderServiceSoap')
#Ping the service
ping = soap_client.service.Ping()

problem:

I get a response stating that my SOAP XML is malformed

The request needs to look like:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://api.channeladvisor.com/webservices/">
       <soapenv:Header>
       </soapenv:Header>
       <soapenv:Body>
          <web:Ping/>
       </soapenv:Body>
    </soapenv:Envelope>

But Instead it looks like:

    <SOAP-ENV:Envelope xmlns:ns0="http://api.channeladvisor.com/webservices/" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
       <SOAP-ENV:Header/>
       <ns1:Body>
          <ns0:Ping/>
       </ns1:Body>
    </SOAP-ENV:Envelope>

I'm not experienced with SOAP at all, i've avoided its endless implementations and complexities thus far - and so pardon me for my sheer ignorance and lack of knowl开发者_JAVA百科edge, but what if anything am I doing wrong - how can I get python (our language of choice for this sort of thing) to work with the channel advisor API

Updates:

*As I have not received any answers, I'll try to update everyone if/when I find a solution (March 3, 2011)

I think part of the problem is SUDS may not be including nested WSDL files correctly.


I just had this same problem and finally realized that I had to pass the APICredentials for CA to respond to any request, even a ping. Here's an example:

import logging
from suds.client import Client

# Set logging to DEBUG level to see soap messages
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)

# URL for CA WSDL
url='https://api.channeladvisor.com/ChannelAdvisorAPI/v5/AdminService.asmx?WSDL'

# Initialize client - The extra location is required because CA is https
client = Client(url,location='https://api.channeladvisor.com/ChannelAdvisorAPI/v5/AdminService.asmx')

# Set soap headers to include login information
login = client.factory.create('APICredentials')
login.DeveloperKey = 'YOUR_KEY'
login.Password = 'YOUR_PWD'
client.set_options(soapheaders=login)

# Send Ping to CA
result = client.service.Ping()

print result
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜