[spyne] Make SOAP webservice compatible with existing clients

Quentin quentin at qvdb.be
Wed May 6 09:49:15 UTC 2015


I am creating a webservice that has to be compatible with existing clients.
The clients already work with another implementation of the same service. The
goal is to make my webservice as similar to the other implementation as
possible, so that the clients do not have to be modified to use my version of
the service.

This is not the case at the moment. One of the client developers let me know 
they call one of the webservice functions like this:

    var response = wcf.getData(user.Username, user.Password);

This works with the other implementation, but not with mine. However the 
following does work with my implementation:

    var responseResult = wcf.getData(new getData{password = user.Password, user = user.Username});
    var response = responseResult.getDataResult;

It seems both the input and the output variables are wrapped in an extra

My code for this function looks like this:

    class WebService(ServiceBase):
        @rpc(String(min_occurs=0, max_occurs=1, nillable=False),
             String(min_occurs=0, max_occurs=1, nillable=False),
        def getData(self, login, password):
            return u'data'

    application = Application([WebService],

Does anyone know how I could change my service so the client can call this
function like in the first example above?

At first I thought the problem was a difference between my service's WSDL and
that of the existing ones, but Burak was so kind to point out that both forms
are valid [1].

I also wrote a small client using suds to test this behavior, but could not
reproduce the problem. Using suds I can just call the function without wrapping 
the parameter in an extra object:

    from suds.client import Client
    client = Client("http://webservice.example.com/?wsdl").service
    data = client.getData(user, password)


[1] http://stackoverflow.com/questions/29943275/wrap-function-parameters-complextype-in-an-element

More information about the people mailing list