python 客户端 httplib 、 requests分别post数据(soap)
httplib
import httplib
soapbody ='''
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:te="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<te:GetLisRequest>
<te:Barcode>%s</te:Barcode>
<te:LoginCode>%s</te:LoginCode>
<te:LoginPWD>%s</te:LoginPWD>
<te:DelegateHosCode>%s</te:DelegateHosCode>
</te:GetLisRequest>
</soapenv:Body>
</soapenv:Envelope>'''
soapbody=soapbody %('','','','')
webservice = httplib.HTTPS("hims-core-stg1.xxx.com.cn")
webservice.putrequest("POST", "/lis/IHospitalInterface")
webservice.putheader("Host", "hims-core-stg1.xxx.com.cn")
webservice.putheader("Content-length", "%d" % len(soapbody))
webservice.putheader("Content-type", "text/xml; charset=UTF-8")
webservice.putheader("SOAPAction", "http://tempuri.org/IHospitalInterface/GetLisRequest")
webservice.endheaders()
webservice.send(soapbody)
statuscode, statusmessage, header = webservice.getreply()
res = webservice.getfile().read()
requests
import requests body ='''
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:lns="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<lns:GetLisRequest>
<lns:Barcode>%s</lns:Barcode>
<lns:LoginCode>%s</lns:LoginCode>
<lns:LoginPWD>%s</lns:LoginPWD>
<lns:DelegateHosCode>%s</lns:DelegateHosCode>
</lns:GetLisRequest>
</soapenv:Body>
</soapenv:Envelope>''' payload=body %('','','','') url = "https://hims-core-stg1.xxx.com.cn/lis/IHospitalInterface"
headers = {
'Content-type': "text/xml; charset=UTF-8",
'SOAPAction': "http://tempuri.org/IHospitalInterface/GetLisRequest",
'Content-length': "%d" % len(payload),
'Host': "hims-core-stg1.xxx.com.cn",
} response = requests.request("POST", url, data=payload, headers=headers) print(response.text)
python 客户端 httplib 、 requests分别post数据(soap)的更多相关文章
- 【Python】 http客户端库requests & urllib2 以及ip地址处理IPy
requests requests是个HTTPClient库,相比于urllib,urllib2等模块比更加简洁易用 ■ get请求 作为示例,讲一下关于requests如何发起并处理一个get请求 ...
- python客户端编程
上一篇说了最为底层的用来网络通讯的套接字.有很多基于套接字的一些协议,这些协议构成了当今互联网大多数客户服务器应用的核心 其实这些协议时在套接字上面的进一层封装用来完成特定的应用,这些应用主要包括: ...
- python urllib2 httplib HTTPConnection
httplib实现了HTTP和HTTPS的客户端协议,一般不直接使用,在python更高层的封装模块中(urllib,urllib2)使用了它的http实现. import httplib conn ...
- python 3 关于requests库的 text / content /json
最近在爬SDFDA的数据,刚开始用urllib.request 库,一直连不到数据 : 后来通过CHROME浏览器的F12,发现该 网站用的是JSON格式{}'Content-Type': 'appl ...
- Python语言之requests库
发送请求.传递URL参数.定制headers.接受数据,处理数据等 在Java中用httpclient jar包,在Python中用requests库,即使没有事先下载,在Pycharm开发工具中,出 ...
- python用httplib模块发送get和post请求
在python中,模拟http客户端发送get和post请求,主要用httplib模块的功能. 1.python发送GET请求 我在本地建立一个测试环境,test.php的内容就是输出一句话: 1 e ...
- 【网络爬虫入门02】HTTP客户端库Requests的基本原理与基础应用
[网络爬虫入门02]HTTP客户端库Requests的基本原理与基础应用 广东职业技术学院 欧浩源 1.引言 实现网络爬虫的第一步就是要建立网络连接并向服务器或网页等网络资源发起请求.urllib是 ...
- Python获得百度统计API的数据并发送邮件
Python获得百度统计API的数据并发送邮件 小工具 本来这么晚是不准备写博客的,当是想到了那个狗子绝对会在开学的时候跟我逼逼这个事情,所以,还是老老实实地写一下吧. Baidu统计API的使 ...
- python第三方库requests简单介绍
一.发送请求与传递参数 简单demo: import requests r = requests.get(url='http://www.itwhy.org') # 最基本的GET请求 print(r ...
随机推荐
- shell位置参数和 shift 命令
- windows如何在当前路径下快速打开cmd
直接在打开的文件夹地址栏当中输入cmd即可.
- sql中char,varchar,nvarchar的区别
char[n] 是定长的,也就是当存储字符小于n时,他会自动补齐(补空值).优点:效率较varchar高. varchar[n]是变长且非unicode字符数据类型,n的取值在1到8000之间,该类型 ...
- POJ-1639 Picnic Planning 度数限制最小生成树
解法参考的论文:https://wenku.baidu.com/view/8abefb175f0e7cd1842536aa.html 觉得网上的代码好像都是用邻接矩阵来实现的,觉得可能数据量大了会比较 ...
- Codeforces 346D Robot Control DP spfa 01BFS
题意及思路:https://www.cnblogs.com/zjp-shadow/p/9562888.html 这题由于性质特殊,可以用01BFS来进行DP的转移. 代码: #include < ...
- GetWindowsDirectoryA and GetSystemDirectory
#include <iostream> #include <Windows.h> using std::cout; using std::endl; // 获取Windows文 ...
- 欧拉路径 && 欧拉回路
- rem_2
html{ font-size:625%; } body{ font-size:0.16rem; }
- go声明和初始化
go声明和初始化 当我们第一次看见变量和声明时,我们仅仅看见一些内置的类型,比如整型和字符串.现在我们将学习结构体,并且我们会深入学习包括指针的内容. 通过一种最简单的方式去创建一个结构体值类型: g ...
- 8、iota枚举
1.iota常量自动生成器,每一行,自动累加1 2.iota给常量赋值使用 3.如果iota遇到const,就会重置为0 4.可以可以只写一个iota 5.如果是同一行,值是一样的 // 09_iot ...