urllib2访问soap
来源:互联网 发布:单例模式作用 java 编辑:程序博客网 时间:2024/05/21 15:05
首先是得到wsdl,用xmlspy产生出一个request,
然后用urllib2写soap的头,把request放在soap的body里。
from ATOM.core import atomurllib2def post_request_to_csa(soap_request_xml, etok=None): WebService_URL = "http://localhost/MyWebService/GetTimeService.asmx/GetDay" hdr = { 'Content-Type': 'text/xml; charset=utf-8', 'Host': 'localhost', 'Content-Length': len(soap_request_xml), 'SOAPAction': 'http://localhost/MyWebService/GetTimeService.asmx/GetDay' } try: urllib2_request_obj = atomurllib2.Request(WebService_URL, data=soap_request_xml, headers=hdr) opener = atomurllib2.build_opener() atomurllib2.install_opener(opener) f = atomurllib2.urlopen(urllib2_request_obj) if f.getcode()==200: soap_response = f.read() print soap_response return soap_response except Exception: print "error"if __name__ == '__main__': print "start" xml='''<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <m:GetDay xmlns:m="http://tempuri.org/"/> </SOAP-ENV:Body> </SOAP-ENV:Envelope>''' post_request_to_csa(xml)
- urllib2访问soap
- 【Python】urllib2访问url
- iphone 访问SOAP
- 使用SAAJ访问soap
- SOAP访问Web服务
- JAVA 访问 SOAP 协议
- python访问web的利器:urllib2
- urllib2如何用代理访问网络
- python访问web的利器:urllib2
- python访问web的利器:urllib2
- python]用urllib2设置代理访问网页
- urllib2
- urllib2
- urllib2
- urllib2
- urllib2
- urllib2
- 使用SOAP访问Web服务
- GB2312和UTF-8的相互转换
- vector练习
- JavaScript 常用的107句话
- 第一章 Linux系统概述
- Spring MVC表单提交多个对象
- urllib2访问soap
- NYOJ 532题 不吉利的数字
- 黑马程序员---oracle更新数据错误,找回数据
- 数据结构--二叉查找树
- ACM编程题
- 顺序链表的实现
- 妙用工具做好时间管理之工具及使用
- linux tar命令总结
- 第二章 RedHat Linux 9.0的安装