使用 SUDS 和 python 打印客户端时服务列表为空

Empty list of services when printing client with SUDS and python

当我用 SUDS 打印时,我没有得到任何关于我的 SOAP 客户端的信息。

代码:

url = 'https://website.com/API/AuthenticationService.asmx'
headers = {'Content-Type': 'text/xml; charset=utf-8'}
client = Client(url, headers = headers)
print client

打印结果:

Suds ( https://fedorahosted.org/suds/ )  version: 0.6

我应该可以通过 XML:

传递用户名和密码
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<Login xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://Iris.net">
<username>Username</username>
<password>Password</password>
</Login>
</s:Body>
</s:Envelope>

如果我尝试使用任何服务或工厂命名空间,我会收到错误消息。

尝试使用服务:

response = client.service.Login(username)

错误:

Exception: No services defined

和工厂:

    login = client.factory.create('Login')

错误:

Exception: (Login, None, ), must be qref

Web 服务似乎不能使用肥皂水,所以我发现它可以用于 xml 请求。在这里找到正确答案:Python: Making a request with suds