Monday, March 24, 2014

Axiom.soap.SOAPProcessingException: First Element must contain the local name, Envelope.

I faced this issue [1] and struggled a bit to find the root cause of this issue in synapse. The error was not clear enough to find out what was the issue.
The fix was, we need to set  the 'SOAPAction' property before sending out the message.

<property name="SOAPAction" value="urn:select_address " scope="transport"/>

Axis2 dispatches the message based on ;
  • Request URI based
  • Request URI Operation based
  • SOAP Action based
  • SOAP MessageBody based etc..
If system could not find any of the option to dispatch the request to correct endpoint, axis2 will throw an error states "operation not found/ EPR not found error"  .
But here, the error stack is not descriptive  to find the actual missing configuration.

[1] ERROR - RelayUtils Error while building Passthrough stream
org.apache.axiom.soap.SOAPProcessingException: First Element must contain the local name, Envelope , but found faultstring
        at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.constructNode(
        at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createOMElement(
        at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createNextOMElement(
        at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(
        at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.(
        at org.apache.axis2.builder.SOAPBuilder.processDocument(
        at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(
        at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(
        at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(
        at org.apache.synapse.mediators.AbstractListMediator.mediate(