Suds: Type not found in response

I find it difficult to load a foam-based python SOAP client to analyze the response: the client is built correctly and perfectly parses WSDL. As far as I can see, there is no import in WSDL, so this does not seem to be a typical ImportDoctor problem.

Relevant bits from WSDL:

  <xsd:complexType name="getFontsRequest"> <xsd:sequence> <xsd:element name="UserID" type="xsd:int" maxOccurs="1" minOccurs="1"></xsd:element> <xsd:element name="TAWSAccessKey" type="xsd:string" maxOccurs="1" minOccurs="1"></xsd:element> </xsd:sequence> </xsd:complexType> <xsd:complexType name="getFontsResponse"> <xsd:sequence> <xsd:element name="UserID" type="xsd:int"></xsd:element> <xsd:element name="Status" type="xsd:string"></xsd:element> <xsd:element name="Fonts" type="tns:FontType[]"></xsd:element> </xsd:sequence> </xsd:complexType> <xsd:complexType name="FontType"> <xsd:sequence> <xsd:element name="ID" type="xsd:int"></xsd:element> <xsd:element name="Name" type="xsd:string"></xsd:element> </xsd:sequence> </xsd:complexType> 

My code is:

  self.soap_client = Client(settings.WSDL_URL) self.factory = self.soap_client.factory self.service = self.soap_client.service # ... getFontsRequest = self.factory.create('getFontsRequest') getFontsRequest.UserID = settings.WS_UID getFontsRequest.TAWSAccessKey = settings.WS_KEY self.service.getFonts(getFontsRequest) 

The last line throws this exception:

 ... File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/suds/xsd/sxbasic.py", line 63, in resolve raise TypeNotFound(qref) TypeNotFound: Type not found: '(FontType[], http://www.type-applications.com/character_set/, )' 

I understand that webservice returns an array of FontType objects (i.e. FontType[] ) as specified in the getFontResponse method, but cannot determine the type of FontType[] and just describes FontType .

Any help to solve this problem would be greatly appreciated.

+4
source share
2 answers

This issue was resolved by contacting the WSDL provider and asking them to fix the (broken) WSDL. Unfortunately, I do not know about any code-based solutions to this problem.

+3
source

This may be a task for ImportDoctor . It is surprisingly common to run through broken WSDLs.

Try the following:

 from suds.client import Client from suds.xsd.doctor import Import, ImportDoctor wsdl_url = settings.WSDL_URL # Fix missing types with ImportDoctor schema_url = 'http://www.type-applications.com/character_set/' schema_import = Import(schema_url) schema_doctor = ImportDoctor(schema_import) # Pass doctor to Client client = Client(url=wsdl_url, doctor=schema_doctor) 
+5
source

Source: https://habr.com/ru/post/1347974/


All Articles