如何使用Python处理SOAP UI调用?

2024-06-17 09:52:06 发布

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

我有以下来自soapui的原始请求。如何将其转换为Python的请求

POST https://data.egov.kz/proxy2/culs_payments?token=50a3f6ca0f824f9e97938295fbc7768f HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/json
Content-Length: 273
Host: data.egov.kz
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.5 (Java/12.0.1)

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<sign:Request xmlns:sign="http://xmlns.kztc-cits/sign" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <sign:IIN_BIN>090740002542</sign:IIN_BIN>
</sign:Request>

我试过:

import requests

url = "https://data.egov.kz/proxy2/culs_payments?token=50a3f6ca0f824f9e97938295fbc7768f"
headers = {'content-type': 'application/json'}
body = """<sign:Request xmlns:sign="http://xmlns.kztc-cits/sign" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <sign:IIN_BIN>010540001007</sign:IIN_BIN>
</sign:Request>"""
print(body)
response = requests.post(url,data=body, headers = headers, verify = False)
print (response.content)

我发现了一个错误


Tags: httpsorghttpdatabinrequestwwwbody