1.test.xml文件 需求请求的xml信息
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<p_request>
<head>
<core_no>N777751</core_no>
<out_no>on_2020111101</out_no>
<version>1.0</version>
<pay_channel>Z0003</pay_channel>
<pid>00496</pid>
</head>
<type>1</type>
</p_request>
2.python执行 示例xml和py文件是同一个目录下
#coding = utf-8
import requests
#请求地址 "http://192.168.19.11.111:8000/pc/api/Z0003/1.0.in"
host = "http://192.168.11.111:8000/pc/api/"
id= "Z0003"
url = host + id+ "/1.0.in"
with open("text.xml",encoding="utf-8") as fp:
body = fp.read()
r = requests.post(url,data=body.encode("utf-8"))
print(r.text)
3. 返回信息
<?xml version="1.0" encoding="utf-8"?>
<p_response>
<head>
<core_no>N777751</core_no>
...
<p_no>00015981618</p_no>
<version>1.0</version>
<err_code>S</err_code>
<err_code_des>S</err_code_des>
<ret_code>S</ret_code>
</head>
<respCode>000000</respCode>
<respMsg>成功</respMsg>
<wt>
<msg>SUCCESS</msg>
......
</wt>
</p_response>
网友评论