Web API and Python

Has any been able to access the API using Python?

 

I've tried using ActivePython 2.6 and the SUDS soap library, but I get an error. Soap is new to me so I might be doing something wrong. I'm not trying to create web pages here, just automate some API method calls for testing.

 

Here's my python test code..

from suds import WebFault
from suds.client import Client
 
client = Client('http://localhost/webservice_test/Tessitura.asmx?WSDL')

#client = Client('http://localhost/webservice_test/Tessitura.asmx')
 
print client

 

..and here's the error..

 

  File "C:\Python26\Lib\SITE-P~1\PYTHON~1\pywin\framework\scriptutils.py", line 312, in RunScript
    exec codeObject in __main__.__dict__
  File "C:\Documents and Settings\jstephenson\My Documents\python scripts\test.py", line 4, in <module>
    client = Client('http://localhost/webservice_test/Tessitura.asmx?WSDL')
  File "build\bdist.win32\egg\suds\client.py", line 103, in __init__
    self.wsdl = Definitions(url, options)
  File "build\bdist.win32\egg\suds\wsdl.py", line 192, in __init__
    self.build_schema()
  File "build\bdist.win32\egg\suds\wsdl.py", line 253, in build_schema
    self.schema = container.load()
  File "build\bdist.win32\egg\suds\xsd\schema.py", line 87, in load
    merged.dereference()
  File "build\bdist.win32\egg\suds\xsd\schema.py", line 299, in dereference
    child.dereference()
  File "build\bdist.win32\egg\suds\xsd\sxbase.py", line 335, in dereference
    self.mutate()
  File "build\bdist.win32\egg\suds\xsd\sxbasic.py", line 694, in mutate
    raise TypeNotFound(qref)
TypeNotFound: Type not found: '(schema, http://www.w3.org/2001/XMLSchema, )'

 

I'd appreciate any help here.

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

John Stephenson

Database Administrator

Cincinnati Symphony and Pops Orchestras

513-621-1919

jstephenson@cincinnatisymphony.org

www.cincinnatisymphony.org

 

Parents
  • Hi John,

    I think it may be a problem with the WSDL document.

    Try saving a static version and change this line:

    <s:import namespace="http://microsoft.com/wsdl/types/" />

    to this:

    <s:import namespace="http://www.w3.org/2001/XMLSchema" />

    Then point your code at that static version. Let me know if you'd like help with any of this.

       -Morgan

  • Hi Morgan,

    Thanks for your help!

    I saved the asmx as a file and made that replacement (hope that was right), but now I'm getting a different error..

     

    Here's the code..

    from suds import WebFault
    from suds.client import Client
     
    client = Client('C:\Documents and Settings\jstephenson\My Documents\python scripts\Tessitura.asmx')

    #client = Client('http://localhost/webservice_test/Tessitura.asmx')
     
    print client

     

    ..and error..

    Traceback (most recent call last):
      File "C:\Python26\Lib\SITE-P~1\PYTHON~1\pywin\framework\scriptutils.py", line 312, in RunScript
        exec codeObject in __main__.__dict__
      File "C:\Documents and Settings\jstephenson\My Documents\python scripts\test.py", line 4, in <module>
        client = Client('C:\Documents and Settings\jstephenson\My Documents\python scripts\Tessitura.asmx')
      File "build\bdist.win32\egg\suds\client.py", line 103, in __init__
        self.wsdl = Definitions(url, options)
      File "build\bdist.win32\egg\suds\wsdl.py", line 170, in __init__
        root = p.parse(url=url).root()
      File "build\bdist.win32\egg\suds\sax\parser.py", line 121, in parse
        fp = self.transport.open(Request(url))
      File "build\bdist.win32\egg\suds\transport.py", line 190, in open
        return  HttpTransport.open(self, request)
      File "build\bdist.win32\egg\suds\transport.py", line 130, in open
        return self.__open(u2request)
      File "build\bdist.win32\egg\suds\transport.py", line 164, in __open
        return self.urlopener.open(u2request)
      File "C:\Python26\lib\urllib2.py", line 389, in open
        response = self._open(req, data)
      File "C:\Python26\lib\urllib2.py", line 412, in _open
        'unknown_open', req)
      File "C:\Python26\lib\urllib2.py", line 367, in _call_chain
        result = func(*args)
      File "C:\Python26\lib\urllib2.py", line 1173, in unknown_open
        raise URLError('unknown url type: %s' % type)
    URLError: <urlopen error unknown url type: c>
    >>>

     

     

  • Hmmm... looks like it's expecting a URL, not a local path. Could you serve up the file via http?

       -Morgan

  • Yea. I got that to work, using a file URL..

     

    from suds import WebFault
    from suds.client import Client

    client = Client('file:///C|/Documents and Settings/jstephenson/My Documents/python scripts/Tessitura.asmx')
    print client

     

    I also tried to get ImportDoctor to work (after upgrading SUDS) but I can't seem to get the statements right. Maybe I should quit while I'm ahead (-:

     

    Thanks so much for your help!

    John

Reply
  • Yea. I got that to work, using a file URL..

     

    from suds import WebFault
    from suds.client import Client

    client = Client('file:///C|/Documents and Settings/jstephenson/My Documents/python scripts/Tessitura.asmx')
    print client

     

    I also tried to get ImportDoctor to work (after upgrading SUDS) but I can't seem to get the statements right. Maybe I should quit while I'm ahead (-:

     

    Thanks so much for your help!

    John

Children
  • Not that this is applicable seeing as the RESTful API is out there now; but for anyone searching in the future here is the suds setup, with doctor, required for python :

     

    url = '' #WSDL url; for tessitura this is usually ?WSDL

    imp = Import('http://www.w3.org/2001/XMLSchema',

        location='http://www.w3.org/2001/XMLSchema.xsd')

    imp.filter.add('http://tessiturasoftware.com/')

    doctor = ImportDoctor(imp)

    client = Client(url, doctor=doctor)