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 ...
随机推荐
- 2018-2-13-win10-UWP-Hmac
title author date CreateTime categories win10 UWP Hmac lindexi 2018-2-13 17:23:3 +0800 2018-2-13 17: ...
- 使用vscode搭建本地的websocket
首先在服务器方面,网上都有不同的对websocket支持的服务器: php - http://code.google.com/p/phpwebsocket/ jetty - http://jetty. ...
- 前端学习(十)初识js(笔记)
js事件(公有属性) onclick="" 当点击...时! onmouseover="" 当鼠标移入...时!onmouseout="" ...
- java多线程并发面试题
1.多线程有什么用? (1)发挥多核CPU的优势 随着工业的进步,现在的笔记本.台式机乃至商用的应用服务器至少也都是双核的,4核.8核甚至16核的也都不少见,如果是单线程的程序,那么在双核CPU上就浪 ...
- 配置文件--spring cloud Config
配置中心--Spring cloud Config 通过本次学习,我们应该掌握: Config Server 读取配置文 Config Server 从远程 Git 仓库读取配置文 搭建芮可用 Con ...
- jupyter|浏览器启动问题|“ImportError: DLL load failed: 找不到指定的模块”sqlite3
问题: 1.安装好Anconda3后,开始——>打开jupyter notebook时 默认浏览器无法启动 2.开始打开——>anaconda prompt 输入jupyter noteb ...
- SQL Select选择
SQL Select(选择) 语法 SELECT 语法用于从数据库中选择数据. 返回的数据存储在结果表中,称为结果集. SQL SELECT 语法 SELECT column1, column2, . ...
- noip2015 提高组 day1t1 神奇的幻方
题目描述 幻方是一种很神奇的N*N矩阵:它由数字1,2,3,--,N*N构成,且每行.每列及两条对角线上的数字之和都相同. 当N为奇数时,我们可以通过以下方法构建一个幻方: 首先将1写在第一行的中间. ...
- django_websocket实现简单聊天室
一.安装模块 pip install channels pip install channels-redis 二.代码 #websocket_v1/settings.py INSTALLED_APPS ...
- CSS3 图形变换
1.zoom 和 transform:scale 的区别 : http://www.zhangxinxu.com/wordpress/2015/11/zoom-transform-sc ...