简体   繁体   中英

Python suds error creating object

Trying to work with the echosign SOAP API.

The wsdl is here: https://secure.echosign.com/services/EchoSignDocumentService14?wsdl

When I try to create certain objects, it appears to not be able to find the type, even after listing it in print client

import suds

url = "https://secure.echosign.com/services/EchoSignDocumentService14?wsdl"

client = suds.client.Client(url)
print client


  Service ( EchoSignDocumentService14 ) tns="http://api.echosign"
     Prefixes (10)
        ns0 = "http://api.echosign"
        ns1 = "http://dto.api.echosign"
        ns2 = "http://dto10.api.echosign"
        ns3 = "http://dto11.api.echosign"
        ns4 = "http://dto12.api.echosign"
        ns5 = "http://dto13.api.echosign"
        ns15 = "http://dto14.api.echosign"
        ns16 = "http://dto7.api.echosign"
        ns17 = "http://dto8.api.echosign"
        ns18 = "http://dto9.api.echosign"
     Ports (1):
        (EchoSignDocumentService14HttpPort)
           Methods (45):
                 ...
           Types (146):
              ns1:CallbackInfo
              ns17:WidgetCreationInfo

Trimmed for brevity, but showing the namespaces and the 2 types I'm concerned with right now.

Trying to run WCI = client.factory.create("ns17:WidgetCreationInfo") generates this error:

client.factory.create("ns17:WidgetCreationInfo") Traceback (most recent call last): File "", line 1, in File "build/bdist.macosx-10.7-intel/egg/suds/client.py", line 244, in create suds.BuildError: An error occured while building a instance of (ns17:WidgetCreationInfo). As a result the object you requested could not be constructed. It is recommended that you construct the type manually using a Suds object. Please open a ticket with a description of this error. Reason: Type not found: '(CallbackInfo, http://dto.api.echosign , )'

So it doesn't appear to be able to find the CallbackInfo type. Maybe its because its missing the ns there?

Again, figured it out 15 min after posting here.

suds has an option to cross-pollinate all the namespaces so they all import each others schemas. autoblend can be set in the constructor or using the set_options method.

suds.client.Client(url, autoblend=True)

Take a look in the WSDL, it seems lots of definitions in http://*.api.echosign that suds cannot fetch.

Either update your /etc/hosts to make these not well-formed domains can be reached, or save the wsdl locally, modify it, then use Client('file://...', ...) to create your suds client.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM