【发布时间】:2021-05-27 17:58:09
【问题描述】:
我能够在 SOAPUI-5.6.0 中成功运行 XML 请求,但是使用 requests 模块的相同 XML 在 python 中不起作用。
Python代码如下
import requests
api_url = "https://testing2.tracker.com/services/webservices.asmx"
xml_file = "CreateorUpdateTask3"
with open(xml_file) as xml:
r = requests.post(api_url, headers={"Content-Type": "application/xml"}, data=xml)
print(r.content)
XML 文件:
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<CreateOrUpdateTaskRequest xmlns="Trackem.Web.Services">
<UserName>h1234</UserName>
<Password>1234</Password>
<Operation>Create</Operation>
<TaskNumber>393874939</TaskNumber>
<EmployeeNumber>cd123</EmployeeNumber>
<DueDateAsSecondsFromEpoch>20210527130000</DueDateAsSecondsFromEpoch>
<DueDateAsYYYYMMDDHHMMSS>20210527130000</DueDateAsYYYYMMDDHHMMSS>
<Notes>Pycharm</Notes>
<Description>Pycharm Test</Description>
<Status>DontChange</Status>
<Address>Calle 61</Address>
<City>Miami</City>
<Street>Calle 59</Street>
<HouseNumber>8</HouseNumber>
</CreateOrUpdateTaskRequest>
</soap:Body>
</soap:Envelope>
知道为什么这个请求在 SOAPUI-5.6.0 中有效,但在 Pycharm 中无效?现在我得到的错误是“无法处理没有有效动作参数的请求。请提供有效的肥皂动作。”但这只是我一直试图解决的许多错误之一。我不明白为什么这在 SOAPUI 中有效,但在 Pycharm 中无效。有什么想法吗?
【问题讨论】:
-
试试这个:将
?WSDL添加到您的网址末尾。
标签: python xml python-requests pycharm soapui