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. Django之ModelForm操作

    一.ModelForm的使用 顾名思义,ModelForm就是将Model与Form进行绑定,Form有自动生成表单的作用,但是每一个forms字段需要自己手动填写,而Model就是数据库表包含了所有 ...

  2. 微信小程序 封装接口

    1.util-util.js //封装接口 let baseURL = 'http://127.0.0.1:3000/'; //接口路径 let request = function (url, op ...

  3. 转译es6原生原生对象及方法,如Object.assign,Object.keys等,及promise

    下面主要为兼容恶心的ie 1,首先引入‘babel-polyfill’,可写在webpack.dev.js的entry.vendors数组里面 2,在入口文件如app.js里面import 'babe ...

  4. vue搭建vue-cli脚手架项目

    一.Node.js 1.介绍 Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine.Node.js是一个基于Ch ...

  5. IT类影视

    1.爱奇艺 代码(The Code) 2.爱奇艺 操作系统革命(Revolution OS) 3.爱奇艺 互联网之子 4.爱奇艺 深网

  6. 【leetcode】949. Largest Time for Given Digits

    题目如下: Given an array of 4 digits, return the largest 24 hour time that can be made. The smallest 24 ...

  7. ES数据导入导出

    ES数据导入导出   1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ...

  8. Django+telnetlib实现webtelnet

    说明 基于 python3.7 + django 2.2.3 实现的 django-webtelnet.有兴趣的同学可以在此基础上稍作修改集成到自己的堡垒机中. 项目地址:https://github ...

  9. 校验文件是否是同一个文件,以及mac中使用MD5命令

    背景 sz了war包,因为查看不到里面的内容,并不确定是否是同一个文件. 解决 通过MD5校验 md5sum xxxx 但是在mac中是没有这个命令的下载半天没下载下来,下面是快捷操作. 1.打开终端 ...

  10. 10. Tasks and functions

    Frm: IEEE Std 1364™-2001, IEEE Standard Verilog® Hardware Description Language 10. Tasks and functio ...