wso2 / product-ei

An open source, a high-performance hybrid integration platform that allows developers quick integration with any application, data, or system.
https://wso2.com/integration/
Apache License 2.0
375 stars 280 forks source link

Binary-Relay don't expand SOAP message #1798

Closed ggianoglio closed 5 years ago

ggianoglio commented 6 years ago

Description: The response message of a our web service has content type "application/dime". We changed axis2.xml to use binary-relay (builder and formatter) with that content type.

<messageFormatter contentType="application/dime"                          
   class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>

<messageBuilder contentType="application/dime"
   class="org.wso2.carbon.relay.BinaryRelayBuilder"/>

The response SOAP message is not expanded, so we have a return envelope like this

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
    <ns:binary xmlns:ns="http://ws.apache.org/commons/ns/payload">DCAAAAApACkAAAJxdXVpZDo3MTRDNk...U9GCgA=</ns:binary>
</soapenv:Body>
</soapenv:Envelope>

Affected Product Version: EI 6.1.1, AM 2.1.0

dmxunlimit commented 6 years ago

Step to Reproduce the Issue.

  1. Enable the following messageBuilder and the messageFormatter in the Axis2.xml
<messageFormatter contentType="application/dime"                          
   class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>

<messageBuilder contentType="application/dime"
   class="org.wso2.carbon.relay.BinaryRelayBuilder"/>
  1. Create the following proxy service in EI 6.1.1. The backend should respond with the contentType as application/dime
<?xml version="1.0" encoding="UTF-8"?><proxy xmlns="http://ws.apache.org/ns/synapse" name="BinaryFileProcessor" startOnLoad="true" statistics="disable" trace="disable" transports="http,https">
    <target>
        <inSequence>
            <log level="custom">
                <property xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('transport', 'Content-Type')" name=" ###### IN ContentType : "/>
            </log>
            <log level="full"/>
            <send>
                <endpoint>
                    <address uri="http://www.mocky.io/v2/5bcdb63e2f00007500c85515"/>
                </endpoint>
            </send>
        </inSequence>
        <outSequence>
            <log level="custom">
                <property xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('transport', 'Content-Type')" name=" ###### OUT ContentType :"/>
            </log>
            <log level="full"/>
            <send/>
        </outSequence>
    </target>
    <description/>
</proxy>
  1. Invoke the proxy from a SOAP client

Request URL https://localhost:8243/services/BinaryFileProcessor

Request Body

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body/>
</soapenv:Envelope>
  1. SOAP client will get the binary encoded response
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <ns:binary xmlns:ns="http://ws.apache.org/commons/ns/payload">aGVsbG8=</ns:binary>
   </soapenv:Body>
</soapenv:Envelope>

Flow of execution

image