0

我正在尝试使用 pysimplesoap 与 Websitepanel SOAP-API 进行通信。WebsitePanel API 介绍说:

要与 WebsitePanel API 交互,您应该使用基本身份验证。WebsitePanel 使用以下格式提供的用户凭据识别“授权”标头:用户名:密码

我的第一次尝试如下:

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

返回 401“未授权”。第二次尝试是:

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

它按预期工作,但返回以下内容:

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

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

为什么不起作用,错误消息client['Authorization']是什么意思?Response should be signed

提前致谢。

4

1 回答 1

3

我想通了:要正确使用 pysimplesoap 进行身份验证,您必须调用

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

使用encodedbase64 编码的字符串username:password

于 2013-02-14T14:15:48.387 回答