小编Пав*_*нов的帖子

如何通过python发送soap请求?

我有肥皂请求,想通过 python zeep 脚本发送它。

POST /IntegrationService/IntegrationService.asmx HTTP/1.1
Host: 192.168.66.2
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <SendHardwareCommand xmlns="http://parsec.ru/Parsec3IntergationService">
      <sessionID>guid</sessionID>
      <territoryID>guid</territoryID>
      <command>int</command>
    </SendHardwareCommand>
  </soap12:Body>
</soap12:Envelope>
Run Code Online (Sandbox Code Playgroud)

我尝试自己写一下

from pprint import pprint
from zeep import Client
CODE = '1'
LOGIN = 'PARSEC'
PASSWORD = 'pass'
client = Client('http://192.168.66.2:10101/IntegrationService/IntegrationService.asmx?wsdl', strict=False)

result = client.service.SendHardwareCommand(
    SendHardwareCommandRequest={'code': CODE, 'MessageType': 0},
    AuthorizationHeader={'login': LOGIN, 'password': PASSWORD})
pprint(result)
Run Code Online (Sandbox Code Playgroud)

怎样做才正确呢?

python soap zeep

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×1

soap ×1

zeep ×1