我第一次使用最新版本的suds (https://fedorahosted.org/suds/),但在第一步就停滞不前了。
suds.TypeNotFound: Type not found: '(schema, http://www.w3.org/2001/XMLSchema, )'现在,我知道这在suds世界(https://fedorahosted.org/suds/wiki/TipsAndTricks#Schema-TypeNotFound和Python/Suds: Type not found: 'xs:complexType')中已经被很好地覆盖了,但这似乎略有不同,因为(a)模式应该在0.3.4版之后自动绑定,(b)即使显式地使用解决方法,它仍然不起作用。
from suds.client import Client
from suds.xsd.sxbasic import Import
url = 'file:wsdl.wsdl'
Import.bind('http://schemas.xmlsoap.org/soap/encoding/')
client = Client(url, cache = None)使用wsdl:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="http://ws.client.com/Members.asmx"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
targetNamespace="http://ws.client.com/Members.asmx"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://ws.client.com/Members.asmx">
<s:element name="GetCategoriesResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetCategoriesResult">
<s:complexType>
<s:sequence>
<s:element ref="s:schema" />
<s:any />
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
</wsdl:definitions>会产生上面的异常。
发布于 2011-05-12 02:59:42
我们让它工作了,我希望你也能做到,尽管它有点古怪。也许一个明确的位置或过滤器会有所帮助。例如:
imp = Import(
'http://schemas.xmlsoap.org/soap/encoding/',
location='http://schemas.xmlsoap.org/soap/encoding/'
)
imp.filter.add('http://ws.client.com/Members.asmx')
client = Client(url, plugins=[ImportDoctor(imp)])发布于 2013-05-22 11:27:42
我在这件事上绞尽脑汁了好一阵子。我最终通过使用以下语法解决了这个问题:
from suds.xsd.doctor import ImportDoctor, Import
url = 'http://somedomain.com/filename.php?wsdl'
imp = Import('http://schemas.xmlsoap.org/soap/encoding/')
imp.filter.add('http://some/namespace/A')
doctor = ImportDoctor(imp)
client = Client(url, doctor=doctor)重要的是,从url开始。在浏览器中打开该文件,它将为您提供wsdl定义。确保您在此处输入了正确的url,并且实际打开了一个XML文件。还要注意url末尾的?wsdl。
其次,imp = Import('http://schemas.xmlsoap.org/soap/encoding/')将导入标准SOAP模式。
第三,imp.filter.add('http:somedomain.com/A')将添加您特定的名称空间。您可以通过打开上面在url=中定义的url并查找<wsdl:import namespace="http://somedomain.com/A"部分来找到此名称空间位置。
也要注意urls中的http和https。
发布于 2015-04-10 14:02:43
对于那些仍然为这个问题所困扰的人。此链接https://bitbucket.org/jurko/suds/issue/20/typenotfound-schema可能提供有用的信息。解决方案是这样的:
from suds.client import Client
from suds.xsd.doctor import Import, ImportDoctor
url = 'http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl'
imp = Import('http://www.w3.org/2001/XMLSchema',
location='http://www.w3.org/2001/XMLSchema.xsd')
imp.filter.add('http://WebXml.com.cn/')
client = Client(url, doctor=ImportDoctor(imp))https://stackoverflow.com/questions/4719854
复制相似问题