SOAP API:使用seep发送请求时出错

2024-09-23 22:21:42 发布

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

我正在使用zeep访问SOAP API。这是我的Python:

import zeep
from requests import Session
from zeep.transports import Transport

https_proxy = "cloudproxy.xxx.com:1234"

proxy_settings = {
         "https" : https_proxy,
         "http" : https_proxy
         }

wsdl = 'file://C:/Users/xxx/Desktop/xxxx.wsdl'

session = Session()
session.proxies = proxy_settings

client = zeep.Client(wsdl=wsdl,transport=Transport(session=session))
#client.wsdl.dump()

# I am not sure how to edit the request below -->
result = client.service.getConfig(userID='user1', password='password')
print (result)

API函数名为getConfig,请求示例如下:

<soapenv:Header/>
<soapenv:Body>
  <r20:getConfig>
  <!--Optional:-->
    <servicePass>
      <!--Optional:-->
      <!--type: string-->
      <userID>user1</userID>
      <!--Optional:-->
      <!--type: string-->
      <password>password</password>
    </servicePass>
  </r20:getConfig>
</soapenv:Body>

如何编辑client.service.getConfig()


Tags: fromhttpsimportclientapisessionservicepassword