python soap suds authenticate to affiliatewindow

I try to use the affiliatewindow - https://www.affiliatewindow.com - api with python. http://v3.core.com.productserve.com/ProductServeService.wsdl

In the documentation:

The authentication SOAP-Header element must be sent with every single request.

sApiKey (required) User specific key to authenticate user (ProductServe API (ShopWindow Client) Password) Value Type: String

but it does not give any example of how this header will look.

My code:

from suds.xsd.doctor import ImportDoctor, Import
from suds.client import Client

imp = Import('http://schemas.xmlsoap.org/soap/encoding/')
imp.filter.add('http://v3.core.com.productserve.com/')
d = ImportDoctor(imp)
url = 'http://v3.core.com.productserve.com/ProductServeService.wsdl'

client = Client(url, doctor=d) 

ssn =   '<urn:sApiKey>[the-api-key]</urn:sApiKey>'
client.set_options(soapheaders=ssn) 

result = client.service.getMerchantList()
print result

But the result that I get is:

suds.WebFault: Server raised fault: 'Authentication Failed'

Any idea how to authenticate? Thank you!

-----------------SOLVED--------------------------------

After more research I found a ruby example, translated it to python, this is the solution:

auth = client.factory.create('UserAuthentication')
auth.sApiKey = [api-key]
client.set_options(soapheaders=auth)

Thank you!

Answers


After more research I found a ruby example, translated it to python, this is the solution:

auth = client.factory.create('UserAuthentication')
auth.sApiKey = [api-key]
client.set_options(soapheaders=auth)

Need Your Help

Are there any pros to use HTML 4.01 strict over XHTML 1.0 strict (content="text/html)?

html css xhtml w3c

Are there any pros to use HTML 4.01 strict over XHTML 1.0 strict (content="text/html)?