Send XML data to this interface address as needed

Source: Internet
Author: User

Specifically, I have an interface address that sends XML data to this interface address as needed. Then, a response is received, and the response content is processed accordingly.
I have found a piece of code on the Internet, which should be what I need, but I don't quite understand some of it. I 'd like to ask you here. The Code is as follows. Please help me with it. Python code?

1234567891011121314151617181920212223242526272829 import urllib2 import sys, httplib def SendRtx(target,title,content):     SENDTPL =             '''<?xml version="1.0" encoding="UTF-8"?>     <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws.oa.com/common/message">         <SOAP-ENV:Body>             <ns1:SendRTX>                 <ns1:sender>dantezhu</ns1:sender>                 <ns1:receiver>%s</ns1:receiver>                 <ns1:title>%s</ns1:title>                 <ns1:msgInfo>%s</ns1:msgInfo>                 <ns1:messageType>0</ns1:messageType>             </ns1:SendRTX>         </SOAP-ENV:Body>     </SOAP-ENV:Envelope>'''     SoapMessage = SENDTPL % (target,title,content)     webservice = httplib.HTTP("ws.oa.com"    webservice.putrequest("POST""/messageservice.asmx"    webservice.putheader("Host""ws.oa.com"    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""\"http://ws.oa.com/common/message/SendRTX\""    webservice.endheaders()     webservice.send(SoapMessage)     # get the response     statuscode, statusmessage, header = webservice.getreply() 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.