zoukankan      html  css  js  c++  java
  • 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 %('0044636','1017','1017','5401762')
        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 %('0044636','1017','1017','5401762')
    
        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)
  • 相关阅读:
    深入浅出了解OCR识别票据原理(Applying OCR Technology for Receipt Recognition)
    OCR技术浅探:基于深度学习和语言模型的印刷文字OCR系统
    Python 3.6.4 / win10 使用pip安装keras时遇到依赖的PyYAML安装出错
    简单http代理服务器搭建
    Socket之心跳包实现思路
    设计模式之访问者模式
    设计模式之责任链模式
    设计模式之策略者模式
    C#将.spl剥离成.emf文件格式
    设计模式之状态者模式
  • 原文地址:https://www.cnblogs.com/dancesir/p/11164936.html
Copyright © 2011-2022 走看看