python suds 无网络 访问

准备:

1.下载http://www.w3.org/2001/XMLSchema.xsd和http://www.w3.org/2001/xml.xsd

分别保存为XMLSchema.xml 和 xml.xml 放在/home/myhome/suds/下

修改方式:

1.添加sxbasic.Import.bind
sxbasic.Import.bind('http://www.w3.org/2001/XMLSchema', 'file:///home/myhome/suds/XMLSchema.xml')
2.在XMLSchema.xml的 行<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd">中schemaLocation 改为本地xml路径(如:file:///home/myhome/suds/xml.xml)
3.demo:
            url = '%s?WSDL'% WEBSERVICE_URL
            sxbasic.Import.bind('http://www.w3.org/2001/XMLSchema', 'file:///home/myhome/suds/XMLSchema.xml)
            imp = Import('http://www.w3.org/2001/XMLSchema')    # the schema to import.
            imp.filter.add('http://tempuri.org/') # the schema to import into.
            d = ImportDoctor(imp)
            self.client = Client(url, doctor=d, transport=HttpTransport(timeout=WEBSERVICE_TIMEOUT))#默认90s超时
   

你可能感兴趣的:(python,suds)