Details
Description
In sending a SOAP request to a particular service, I receive a response of the following form:
<?xml version="1.0" encoding="UTF-8" ?>
<!-- SOAP 1.1 Message - Powered by Xcentrisityâ„¢ Frameware -->
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
...
</env:Body>
</env:Envelope>
Unfortunately, when this response is received by Axis2C, it is diagnosed as invalid, error 187, SOAP message does not contain a SOAP envelope element.
Stepping through the code reveals that axiom_stax_builder_create_om_comment() treats a leading comment before the root node as discardable and returns a null pointer. Then in axiom_stax_builder_next_with_token(), a null pointer returned is treated as always being an error.
My suggested fix is that axiom_stax_builder_next_with_token() should complete the comment element only if one is created, but should always return it as valid and keep scanning. In particular, the comment portion of the switch statement that reads:
case AXIOM_XML_READER_COMMENT:
val = axiom_stax_builder_create_om_comment(om_builder, env);
if (!val)
axiom_stax_builder_end_element(om_builder, env);
break;
should read instead:
case AXIOM_XML_READER_COMMENT:
val = axiom_stax_builder_create_om_comment(om_builder, env);
if (val)
break;
In my particular situation, I have verified that making this change allows the returned SOAP response to be processed correctly. I have not tested the other case, of a malformed comment that runs off the document. I hope that the subsequent read for more tokens will terminate nicely when it finds the document empty.