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. mysql binlog相关

    1.清除的binlog   删除所有binlog日志,新日志编号从头开始 RESET MASTER;   删除mysql-bin.XXXX之前所有日志 PURGE MASTER LOGS TO 'my ...

  2. 前端学习(十九)jquery(笔记)

    jquery:库,框架 js,别人封装成的js 官网:http://jquery.com/ -----------------------------------1.7 ----------jq 1. ...

  3. mysql rpm包安装

    MySql5.7 安装文档 1.yum repo 安装 ``` wget http://dev.mysql.com/get/mysql57-community-release-el6-11.noarc ...

  4. vue 数字输入组件

    index.html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> &l ...

  5. date -d 对于时间的控制

    [root@ ~]# date "+%Y"2019[root@ ~]# date "+%Y%m%d"20190826 [root@localhost ~]# d ...

  6. CSS文本垂直居中显示

    <style> .sty1 { width: 300px; height: 200px; background-color: black; text-align: center; colo ...

  7. Restrictions----用法

    ----------------------------------------方法说明 --------------------------QBC常用限定方法-------------------- ...

  8. python基础特性之函数property

    函数property 1.为了保护属性,不让它随意的被更改(a.width=xxx)(起码,要符合某些条件),所以我们引入了set和get方法,虽然这个需要自定义(如下图的set_size,get_s ...

  9. yum设置代理

    echo "proxy=http://[proxy_url]:8080" >> /etc/yum.conf

  10. 020_JUC

    JUC Java.util.Concurrent 并发包 池的顶级接口 Executor 子接口 ExecutorService 工具类 Executors(Collections.Arrays .. ...