Web Service系列之常见问题
原文链接: http://www.kylin-ux.com/2017/04/21/network-web-web-service系列之常见问题
问题: Server raised fault: ‘org.xml.sax.SAXException: No deserializer for {http://www.w3.org/2001/XMLSchema}anyType‘
CSDN网友回复:
原因就是服务器端将对象序列化为SOAP消息, 到了客户端后进行反序列化, 这个时候在SOAP消息中的某个元素是anyType
类型, 但是和客户端在命名空间中的注册属性无法匹配, 导致不能反序列化, 大部分是命名空间的问题
stackoverflow网友回复:
http://stackoverflow.com/questions/13593950/suds-write-request-missing-datatype
I managed to solve it, using the answer from Adding xsi:type and envelope namespace when using SUDS ( http://stackoverflow.com/a/10977734/696768 )
I am not sure this is the only possible solution, and to me it seems more of a hack than anything else, however it will work fine for my current scenario.
The solution i used, is making a plugin for the client, looking for the particular element that i need to be xsi:type=”xsd:int”, then adding these attributes to those elements.
The code i ended up using for reference (from the aforementioned stackoverflow question with minor adjustments):
Then I added plugins=[plugin] to the client ctor.
Example:
补充:
https://wiki.python.org/moin/WebServices
Web Service: JSON-RPC JSON-WSP SOAP SOAPjr XML-RPC XMPP