如何在python中使用soap zeep登录网站。检查帖子的xml

时间:2017-10-24 05:25:49

标签: python soap wsdl zeep

我的wsdl登录方法xml:

Host: 127.0.0.1
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/Login"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <EhelplineWebAPISecurityContext xmlns="http://tempuri.org/">
      <SessionId>string</SessionId>
      <EHLWebServiceAPIKey>string</EHLWebServiceAPIKey>
    </EhelplineWebAPISecurityContext>
  </soap:Header>
  <soap:Body>
    <Login xmlns="http://tempuri.org/">
      <LoginId>string</LoginId>
      <password>string</password>
    </Login>
  </soap:Body>
</soap:Envelope>

登录方法在wsdl中。

from zeep import Client
URL="wsdl url"
from zeep import Client
from zeep.transports import Transport
from requests import Session
client= Client(URL)
client = client.service.Login(LoginId="id",password="password")

但是我收到了这个错误。

File "C:/Python27/zeeplogin.py", line 7, in <module>
    client = client.service.Login(LoginId="id",password="password")
  File "C:\Python27\lib\site-packages\zeep\client.py", line 41, in __call__
    self._op_name, args, kwargs)
  File "C:\Python27\lib\site-packages\zeep\wsdl\bindings\soap.py", line 121, in send
    return self.process_reply(client, operation_obj, response)
  File "C:\Python27\lib\site-packages\zeep\wsdl\bindings\soap.py", line 178, in process_reply
    return self.process_error(doc, operation)
  File "C:\Python27\lib\site-packages\zeep\wsdl\bindings\soap.py", line 280, in process_error
    detail=fault_node.find('detail'))
Fault: Object reference not set to an instance of an object.

我的LoginId和密码是对的。

1 个答案:

答案 0 :(得分:0)

您尝试过吗?

<div class="parent">
  <label for="option1">
    <span>Select me</span>
    <input id="option1" type="checkbox">
  </label>
</div>