python之SOAP服务—ZIPCodeWorldUSWebService

ZIPCodeWorldUSWebService是Fraudlabs提供的一个SOAP接口,可以通过输入美国的邮政编码查找当地的相关信息

 

具体代码如下:

import sys, urllib, string, SOAPpy
from xml.sax import parse, ContentHandler, SAXParseException
from SOAPpy import SOAPProxy
from SOAPpy import Types

SOAPpy.Config.buildWithNamespacePrefix=0
SOAPpy.Config.debug=0

server=SOAPProxy("http://ws.fraudlabs.com/zipcodeworldUS_webservice.asmx", namespace="http://ws.fraudlabs.com/", noroot=1, soapaction="http://ws.fraudlabs.com/ZIPCodeWorld_US")

#server.config.dumpSOAPOUT = 1
#server.config.dumpSOAPIN = 1

# Change these values to the address to validate
license = "05-T65A-G47J"#申请的序列号
zipcode = "60601"#芝加哥的邮政编码

result = server.ZIPCodeWorld_US(ZIPCode=zipcode, LICENSE=license)
print result

 

#以 WSDL 进行 SOAP 内省

from SOAPpy import WSDL
wsdlFile = 'http://ws.fraudlabs.com/zipcodeworldUS_webservice.asmx?wsdl'
server = WSDL.Proxy(wsdlFile)
print server.methods.keys()#打印提供的函数

你可能感兴趣的:(xml,python,webservice,SOAP)