我第一次使用最新版本的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:未找到类型:’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>
产生上面的异常。
即使它有点古怪,我们也能正常运行,我希望您也能做到。明确的位置或过滤器可能会有所帮助。例如:
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)])