views:

32

answers:

2

I've created a simple SOAP web service using soaplib and run into an issue in which SOAP parameters sent including ampersands or angle brackets are ignored, even when escaped.

Whether the method is set up to accept a primitive string or a primitive of type 'any', any of those characters introduced result in a webfault (using suds) of this type:

suds.WebFault: Server raised fault: 'my_method() takes exactly 2 arguments (1 given)'

For now, here's the method, having removing addition code used to store the result:

@soapmethod(soap_types.String, _returns=soap_types.Boolean)
def my_method_(self, sample):
    return True

Calling this method with any simple string works just fine, e.g. in suds,

suds_object.service.my_method('Hello World')

results in "true". But add in any ampersand or angle bracket, e.g.

suds_object.service.my_method('Hello & World')

and the exception is raised. With logging turned on I can see that suds is escaping these characters. So far I've been able to figure out that the problem is not down at the primitive level and I can't figure out where or what the problem is. It makes it rather difficult to send XML payloads through the service.

The class used is a subclass of SimpleWSGISoapApp, and the method is served as a Django view. I noticed that when attempting to use the Hello World example using the soaplib client library that it worked just fine.

+1  A: 

I had problems with "easier" soap libs in python (esp. suds). I had a question a while ago that led me to use soapPy instead, and a problem similar to yours just vanished.

http://stackoverflow.com/questions/1609666/suds-jira-saxexception/1622578#1622578

That question also had good suggestions on using, e.g., wireshark (or google "soap debugger") to see what was happening at a lower level.

Chris
+1 for pointing out the suds factor. Will try with some other clients - my primary concern is about the service.
bennylope
If you do, please pass along your results here. I'm curious.
Chris
Ended up making edits as noted in my answer and was able to use both suds and a third-party SOAP client (http://www.soapclient.com/soaptest.html) against the service.
bennylope
A: 

The problem was absolutely NOT soaplib, but the Django code. That code was reading request.POST.items() for some reason which chopped up the SOAP request at any special character (e.g. =, &, >). Switched to soaplib trunk, updated the Django code, and that solved both the arguments error raised and related Unicode ValueErrors that lxml was raising.

bennylope