[spyne] namespace prefix with suds

"Thomás S. Bregolin" thomas5th at gmail.com
Tue Sep 30 21:49:17 UTC 2014


Hello,


Does anyone know how to fix this: 
https://github.com/arskom/spyne/issues/242 ?

I'm trying to pass a dict to the service, and get the same dict back.

The error is "suds.WebFault: Server raised fault: 'Namespace prefix xs 
on name is not defined, line 1, column 163'"

Here's a test case:

The server:

#!/usr/bin/python
#coding=utf-8

from spyne.application import Application
from spyne.server.wsgi import WsgiApplication
from spyne.decorator import rpc
from spyne.service import ServiceBase
from spyne.protocol.soap import Soap11

from spyne.model.primitive import AnyDict

class myApp(Application):
     pass

class query(ServiceBase):
     @rpc(AnyDict, _returns=AnyDict)
     def listItems(ctx, names):
         return names

app = myApp([query],
                   'localhost.myapp',
                   in_protocol=Soap11(validator='lxml'),
                   out_protocol=Soap11())
application = WsgiApplication(app)

if __name__ == '__main__':
     import logging
     from wsgiref.simple_server import make_server
     logging.basicConfig(level=logging.DEBUG)
     logging.getLogger('spyne.protocol.xml').setLevel(logging.DEBUG)
     logging.info("listening to http://127.0.0.1:8000")
     logging.info("wsdl is at: http://localhost:8000/?wsdl")
     server = make_server('127.0.0.1', 8000, application)
     server.serve_forever()

*************************

The client:

#!/usr/bin/python

from suds.client import Client

c = Client('http://localhost:8000/?wsdl')
req = { 'name': 'foo' }
res = c.service.listItems(req)
print res

*************************

The server's output:

ERROR:spyne.protocol.soap.soap11.invalid:<?xml version="1.0" 
encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:ns0="localhost.myapp" 
xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><ns1:Body><ns0:listItems><ns0:names><xs:name>foo</xs:name></ns0:names></ns0:listItems></ns1:Body></SOAP-ENV:Envelope>

*************************

The client's output:

No handlers could be found for logger "suds.client"
Traceback (most recent call last):
   File "./testcasesuds.py", line 7, in <module>
     res = c.service.listItems(req)
   File "/usr/lib/python2.7/dist-packages/suds/client.py", line 542, in 
__call__
     return client.invoke(args, kwargs)
   File "/usr/lib/python2.7/dist-packages/suds/client.py", line 602, in 
invoke
     result = self.send(soapenv)
   File "/usr/lib/python2.7/dist-packages/suds/client.py", line 653, in send
     result = self.failed(binding, e)
   File "/usr/lib/python2.7/dist-packages/suds/client.py", line 708, in 
failed
     r, p = binding.get_fault(reply)
   File "/usr/lib/python2.7/dist-packages/suds/bindings/binding.py", 
line 265, in get_fault
     raise WebFault(p, faultroot)
suds.WebFault: Server raised fault: 'Namespace prefix xs on name is not 
defined, line 1, column 163'



I'm using the packages from Debian Jessie's repo:
Python: Version: 2.7.8-1
Spyne: Version: 2.11.0-2
Suds: Version: 0.4.1-14


Thanks,

Thomas


More information about the people mailing list