SOAP with Axis, 4D and something called multiRefs
SOAP really totally sucks. I just wasted several hours trying to access a certain Webservice using Axis. The server is apparently implemented using 4D.
It turns out that by default Axis (at least 1.x) uses a feature called “sendMultiRefs”. This turns regular, unsuspecting messages into this:
<?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <ns1:SomeAction xmlns:ns1="some-namespace" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SID xsi:type="xsd:string">some param1</SID> <startID href="#id0"/> </ns1:SomeAction> <multiRef xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:int">some param2</multiRef> </soapenv:Body> </soapenv:Envelope>
The fun thing is that this happens somewhere really deep down in the Axis code - if you debug the Axis message send, all you see of the SOAP message is a regular message (without that multiRef abomination), even when you get down really close to the HTTP socket send. I found this in the end using Wireshark/Ethereal to inspect the actual packages.
Now what happens is that 4D silently drops/ignores the second parameter and apparently sets the value of that input parameter to 0. It doesn’t give any error whatsoever, thanks. Additionally, due to the close coupling to the programming language, the implementation cannot make out if the parameter is not present or set to zero, because it comes out as an int value.
There are a lot of questions here. Why does Axis use a bizarre encoding scheme, that is known to cause problems with a variety of platforms, where it’s totally superfluous? It even makes the messages larger.
And why is this multiRef thing there, anyways? The only thing I can find about it on www.w3.org is a mention that it’s included in SOAP 1.2, but not in SOAP 1.1. I can’t find any mention of it in the spec itself, though. It only appears to be useful for serializing Object graphs that are self-referencing.
Why a messaging protocol needs something like that, which is totally linked to the complex semantics different meanings of identity in different programming languages etc., is beyond me. And actually most people don’t seem to implement it anyways…
It’s quite frustrating to use all this complex, bizarre stuff when all you’d really need is a webservice that takes 1 parameter and returns some XML-encoded list, i.e. http://foo/bar?startID=x.