I am setting up a SOAP webservice which takes XML input and has to return custom XML output. All this is defined in a WSDL. I apply soapServer for this (until someone says i
Phew!
This took me several retries and googling until I discovered what is wrong.
I think it can be classified as a bug in SoapVar.
I discovered that while SoapVar is perfectly capable of parsing an XML string, it cannot do so if the string contains an XML declaration like .
So when you have a DOMDocument or a SimpleXMLElement, you first have to strip off the declaration before parsing the string by SoapVar.
for a DOMDocument this can be done by applying saveXML with a parameter equal to a DOMNode variable constructed from the dom itself, choosing any node but usually this will be the root node of course.
In my server php, I added the following:
$nodes = $dom -> getElementsByTagName ('cdhead');
$node = $nodes -> item(0);
$result = new SoapVar ($dom -> saveXML($node), XSD_ANYXML);
And now my result is OK:
As for the root name of the returned XML - I am sure I will find out a way to change that to whatever I want it to be (instead of the standard mi102Response generated by SoapVar)!!