0

I'm trying to use pysimplesoap to communicate with the Websitepanel SOAP-API. The WebsitePanel API Introduction says:

For interacting with WebsitePanel API you should use Basic Authentication. WebsitePanel recognizes “Authorization” header with the user credentials provided in the following format: username:password

My first try was the following:

client = SoapClient(wsdl=endpoint_url, trace=True)
client['Authorization'] = "%s:%s" % (username, password)

which returns a 401 "Unauthorized". Second try was:

client = SoapClient(wsdl=endpoint_url, trace=True)          
client['wsse:Security'] = {
    'wsse:UsernameToken': {
        'wsse:Username': username,
        'wsse:Password': password,
    }
}    

which works as expected but returns the following:

status: 500
content-length: 924
x-aspnet-version: 4.0.30319
x-powered-by: ASP.NET
server: Microsoft-IIS/7.5
cache-control: private
date: Tue, 12 Feb 2013 14:23:56 GMT
content-type: text/xml; charset=utf-8

And

pysimplesoap.client.SoapFault: q0:Security: SOAP response should be signed.

Why does client['Authorization'] not work and what is meant by the Response should be signed error message?

Thanks in advance.

Aliaksandr Belik
  • 12,725
  • 6
  • 64
  • 90
Subito
  • 227
  • 3
  • 12

1 Answers1

3

I figured it out: To authenticate correctly with pysimplesoap you have to call

client = SoapClient(wsdl=u, trace=True, 
                    http_headers={'Authorization': 'Basic %s' % encoded})

with encodedbeeing the base64-encoded string username:password

Subito
  • 227
  • 3
  • 12
  • I tried this, but SoapClient's initializer doesn't accept the keyword parameter `http_headers`. Is this code sample correct? – Julian A. Jun 13 '13 at 20:56
  • I'm using version 1.07a - and it works fine. Actual signature of the SoapClient s initializer is: `def __init__(self, location = None, action = None, namespace = None, cert = None, trace = False, exceptions = True, proxy = None, ns=False, soap_ns=None, wsdl = None, cache = False, cacert=None, sessions=False, soap_server=None, timeout=_USE_GLOBAL_DEFAULT, http_headers={} )` – Subito Jun 26 '13 at 10:04