开发者

soaplib problems with XML characters in string payload

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开发者_如何学Python 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.


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.

Suds + JIRA = SAXException

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜