Search code examples
xmlsoapwso2payloadwso2-micro-integrator

SOAP Envelope is dropped when sending message out in WSO2


I am trying to build a SOAP message with a proper envelope then body but I am unable to get it. Below are the lines of code I am writing to build it.

<payloadFactory media-type="xml">
    <format>
        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
            <soapenv:Body>
                <prov>
                    <abc>123456</abc>
                    <xyz>789</xyz>
                </prov>
            </soapenv:Body>
        </soapenv:Envelope>
    </format>
    <args/>
</payloadFactory>
<property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
<property name="messageType" value="text/xml" scope="axis2"/>
<call>
    <endpoint key="ActiveMQ_EP"/>
</call>
<respond/>

The result I am getting is as follows:

<prov xmlns="http://ws.apache.org/ns/synapse">
    <abc>123456</abc>
    <xyz>789</xyz>
</prov>

There isn't proper SOAP payload with Envelope then body and then prov instead its starting with prov. Any help in this matter would be very helpful. Thank You


Solution

  • Set the following property before sending the message out.

    <property name="messageType" value="text/xml" scope="axis2"/>
    

    Update

    Try forcing soap1.1 message with format="soap11" flag in your endpoint configuration. This will work with both HTTP and Address Endpoints.

    <call>
        <endpoint>
            <http method="post" uri-template="http://localhost:81/post" format="soap11"> 
                <suspendOnFailure>
                    <initialDuration>-1</initialDuration>
                    <progressionFactor>-1</progressionFactor>
                    <maximumDuration>0</maximumDuration>
                </suspendOnFailure>
                <markForSuspension>
                    <retriesBeforeSuspension>0</retriesBeforeSuspension>
                </markForSuspension>
            </http>
        </endpoint>
    </call>
    

    If you are ok with SOAP 1.2 messages you can also try adding the following message type.

    <property name="messageType" value="application/soap+xml" scope="axis2"/>
    

    But for SOAP 1.2 you may have to alter the Payload accordingly.