Search code examples
pythonsoapsudsspyne

Hello world example for spyne SOAP server


I am experimenting with several different Python SOAP server libraries, and I don't seem to be able to get the 'hello world' example working for spyne: https://github.com/arskom/spyne/blob/master/examples/helloworld_soap.py

When I run it, it starts up a SOAP server and I can successfully view the WSDL in a browser at http://localhost:7789/?wsdl. However, when I try to connect with a suds client, I get an exception:

Python 2.7.3 (default, Aug  1 2012, 05:14:39) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from suds.client import Client
>>> c = Client('http://localhost:7789/?wsdl')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/acordiner/ve/local/lib/python2.7/site-packages/suds/client.py", line 112, in __init__
    self.wsdl = reader.open(url)
  File "/home/acordiner/ve/local/lib/python2.7/site-packages/suds/reader.py", line 152, in open
    d = self.fn(url, self.options)
  File "/home/acordiner/ve/local/lib/python2.7/site-packages/suds/wsdl.py", line 158, in __init__
    self.resolve()
  File "/home/acordiner/ve/local/lib/python2.7/site-packages/suds/wsdl.py", line 207, in resolve
    c.resolve(self)
  File "/home/acordiner/ve/local/lib/python2.7/site-packages/suds/wsdl.py", line 661, in resolve
    self.resolveheaders(definitions, op)
  File "/home/acordiner/ve/local/lib/python2.7/site-packages/suds/wsdl.py", line 725, in resolveheaders
    raise Exception, "message'%s', not-found" % mn
Exception: message's0:SomeObject', not-found

What could I be doing wrong? I'm using spyne 2.9.4 and suds 0.4.


Solution

  • I'm sorry for this confusion.

    The example that you linked to is this: https://github.com/arskom/spyne/blob/ec2bd6feb89fb36915b7266497c177e4c6f78b83/examples/helloworld_soap.py

    It was used to illustrate a suds bug, which is fixed in my own version of suds, but not in the mainstream suds. I later forgot to revert it back in the main Spyne repository.

    You can find the relevant commit here.

    Suds can't cope with outgoing header objects whose namespace is different than the targetNamespace. You can make your version of suds work by setting SomeObject.__namespace__ = 'spyne.examples.hello.soap' instead of 'aaa'.

    You can also just remove the outgoing header declaration which is out-of-place in a helloworld example anyway.

    I hope this helps.