如何使用suds客户端发送请求,请求中包含多个元素

2024-06-12 21:58:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我在发送suds请求时遇到问题。在

我只使用以下方法向其他方法发送了一个请求:

from suds.client import Client

   client = Client(wsdlurl)

   client.service.Login(name, employid)

这返回了正确的响应,因为name和employid是Login的直接子元素。在

但如何使用以下选项发送请求:

^{pr2}$

这样做的原因是我可以在num中添加一个动态值

我已经试过了:

return self.client.service.getStuff.stuffSelect.stuffIDs(**{'stuffID': stuff_id, })

但得到这个错误

AttributeError: 'Method' object has no attribute 'stuffSelector'

Tags: 方法namefromimportclient元素选项service
1条回答
网友
1楼 · 发布于 2024-06-12 21:58:31

我假设您使用的是https://bitbucket.org/jurko/suds。了解您的wsdl接口非常重要;suds可以在运行时部分提供:

# ... 'client' via wsdl url, login

# get example
http_status, payload = client.service.your_wsdl_get_stuff_method()
stuffIDs = []
if http_status == 200:
    for stuff_id in payload:  # depending on your wsdl
        stuffIDs.append(stuff_id)

# upload example
stuffSelect = client.factory.create('stuffSelect')  # structure generated by suds from wsdl
stuffSelect.your_wdsl_stuff_ids_name = stuffIDs  # (maybe debug to see your name)

params = foo, bar, stuffSelect
svr_response = client.service.your_wsdl_upload_method(*params)

相关问题 更多 >