首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

python要写一个soap客户端,应该import那些包?解决思路

2012-04-08 
python要写一个soap客户端,应该import那些包?包括实现soap客户端的功能,处理一个wsdl,解析xml文件这3个部

python要写一个soap客户端,应该import那些包?
包括实现soap客户端的功能,处理一个wsdl,解析xml文件这3个部分。 
  
都需要引入哪些包? 调用soap个功能需要安装额外的python插件吗? 
  
我用的python 2.6.4

[解决办法]

Python code
import httplibfrom xml.dom import minidomimport urllibfrom urlparse import urlparse
[解决办法]
贴个CSDN的例子:
Python code
def getTopicsOfUser(loginUserName, password):    format = '''<?xml version="1.0" encoding="utf-8"?><soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">       <soap12:Body>               <GetTopicsOfUser xmlns="http://www.csdn.net/">                        <identity>                               <username>%s</username>                               <password>%s</password>                        </identity>                        <listType>TopicOfUser</listType>                        <forumId>a3049f56-b572-48f5-89be-4797b70d71cd</forumId>               </GetTopicsOfUser>       </soap12:Body></soap12:Envelope>'''        contentText  = format % (loginUserName, password)            conn = httplib.HTTPConnection("forum.csdn.net")    headers = { "Connection":"close",            "Content-Type": "text/xml; charset=utf-8",            "SOAPAction": "http://www.csdn.net/GetTopicsOfUser"}    headers["Content-Length"] = "%d" % len(contentText)          conn.request("POST",                 "/OpenApi/forumapi.asmx",                  contentText,                  headers)    r1 = conn.getresponse() 

热点排行