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)的更多相关文章

  1. 【Python】 http客户端库requests & urllib2 以及ip地址处理IPy

    requests requests是个HTTPClient库,相比于urllib,urllib2等模块比更加简洁易用 ■ get请求 作为示例,讲一下关于requests如何发起并处理一个get请求 ...

  2. python客户端编程

    上一篇说了最为底层的用来网络通讯的套接字.有很多基于套接字的一些协议,这些协议构成了当今互联网大多数客户服务器应用的核心 其实这些协议时在套接字上面的进一层封装用来完成特定的应用,这些应用主要包括: ...

  3. python urllib2 httplib HTTPConnection

    httplib实现了HTTP和HTTPS的客户端协议,一般不直接使用,在python更高层的封装模块中(urllib,urllib2)使用了它的http实现. import httplib conn  ...

  4. python 3 关于requests库的 text / content /json

    最近在爬SDFDA的数据,刚开始用urllib.request 库,一直连不到数据 : 后来通过CHROME浏览器的F12,发现该 网站用的是JSON格式{}'Content-Type': 'appl ...

  5. Python语言之requests库

    发送请求.传递URL参数.定制headers.接受数据,处理数据等 在Java中用httpclient jar包,在Python中用requests库,即使没有事先下载,在Pycharm开发工具中,出 ...

  6. python用httplib模块发送get和post请求

    在python中,模拟http客户端发送get和post请求,主要用httplib模块的功能. 1.python发送GET请求 我在本地建立一个测试环境,test.php的内容就是输出一句话: 1 e ...

  7. 【网络爬虫入门02】HTTP客户端库Requests的基本原理与基础应用

    [网络爬虫入门02]HTTP客户端库Requests的基本原理与基础应用 广东职业技术学院  欧浩源 1.引言 实现网络爬虫的第一步就是要建立网络连接并向服务器或网页等网络资源发起请求.urllib是 ...

  8. Python获得百度统计API的数据并发送邮件

    Python获得百度统计API的数据并发送邮件 小工具  本来这么晚是不准备写博客的,当是想到了那个狗子绝对会在开学的时候跟我逼逼这个事情,所以,还是老老实实地写一下吧.   Baidu统计API的使 ...

  9. python第三方库requests简单介绍

    一.发送请求与传递参数 简单demo: import requests r = requests.get(url='http://www.itwhy.org') # 最基本的GET请求 print(r ...

随机推荐

  1. Java连接ActiveMQ代码示例(Producer和Consumer)

    import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; ...

  2. mysqldump 导出数据库

    mysqldump -h47.52.67.230 -P3306 -uroot -pAbc\!@#456789 --hex-blob --opt test_fooku_db >/home/test ...

  3. css 一行内显示 超出自动隐藏

    一般的文字截断(适用于内联与块): Example Source Code [www.mb5u.com].text-overflow {display:block;/*内联对象需加*/width:31 ...

  4. JavaScript事件绑定的常见方式

    在Javascript中,事件绑定一共有3种方式: ① 行内绑定 ② 动态绑定 ③ 事件监听 原文: https://mbd.baidu.com/newspage/data/landingsuper? ...

  5. vue 绑定 class 和 内联样式(style)

    <div id="app31"> <!--多个属性 ,号隔开--> <!-- v-bind:style="{fontSize: fontSi ...

  6. Office应用程序对照表

    任何Office应用程序(包括excel)的类型库都作为Office安装的一部分安装.类型库是特定于版本的(即,安装了哪个版本的Office). 例如,Office 2007版本为12.0,Offic ...

  7. 欧拉降幂,基本计算定理——cf615D

    用基本算数定理求约数和的思想来计算, 首先用pi,ci来表示第i个质数,指数为i,然后对于每个pi,pi^2...都有指数为mul{(c_1+1)(c_2+1)(c_i-1+1)(c_i+1+1).. ...

  8. list 链表

    #include <list> #include <iostream> using std::list; /* 双向环状链表 //每一个结点 一个数据域 一个前驱指针 一个后驱 ...

  9. img引用网络图片资源无法加载问题解决

    近期在自己项目中遇到引用一些网络图片资源,显示无法加载,但是在浏览器打开图片路径又可以显示的问题 解决办法: 在图片显示的界面把meta referrer标签改为never <meta name ...

  10. 我看Spring MVC系列(一)

    1.Spring MVC是什么: Spring MVC:Spring框架提供了构建Web应用程序的全功能MVC模块. 2.Spring helloWorld应用(基于Spring 4.2) 1.添加S ...