zoukankan      html  css  js  c++  java
  • Python发送Soap报文

    原文地址:

    http://users.skynet.be/pascalbotte/rcx-ws-doc/postxmlpython.htm

    # post xml soap message

    import sys, httplib

    # a "as lighter as possible" soap message:

    SM_TEMPLATE = """<?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope
    SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"  
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Body>
    <ns1:readLS xmlns:ns1="http://phonedirlux.homeip.net/types">
    <String_1>%s</String_1>
    </ns1:readLS>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    """

    SoapMessage = SM_TEMPLATE%("Your message or e-mail")

    print SoapMessage

    #construct and send the header

    webservice = httplib.HTTP("www.pascalbotte.be")
    webservice.putrequest("POST", "/rcx-ws/rcx")
    webservice.putheader("Host", "www.pascalbotte.be")
    webservice.putheader("User-Agent", "Python post")
    webservice.putheader("Content-type", "text/xml; charset=\"UTF-8\"")
    webservice.putheader("Content-length", "%d" % len(SoapMessage))
    webservice.putheader("SOAPAction", "\"\"")
    webservice.endheaders()
    webservice.send(SoapMessage)

    # get the response

    statuscode, statusmessage, header = webservice.getreply()
    print "Response: ", statuscode, statusmessage
    print "headers: ", header
    res = webservice.getfile().read()
    print res

    By.徐晓1024
  • 相关阅读:
    牛津
    负逻辑
    NB的为运算
    顿悟--人生也许该如此
    河南近亿国民致教育部的公开信:国民待遇!
    三年
    简体字、白话文的应用是流传百年的错误思潮
    鸿蒙系统的源码,请需要的同志查看
    解决好123劫持主页的方法
    vue echarts 给双饼图添加点击事件
  • 原文地址:https://www.cnblogs.com/axeprpr/p/4463885.html
Copyright © 2011-2022 走看看