0
votes

I'm exploring WSO2 ESB and have hit an issue. I am using a simple pass through proxy to post XML data from SAP (or Postman, to test) which then gets forwarded to a REST API - should be easy!

When I POST direct to the REST API (not through ESB), it works fine.(200, OK)

But WSO2 ESB is adding a SOAP Envelope automatically, which the REST API will not accept. I've tried various approaches to remove the automatically added SOAP envelope, with no success. Tried XSLT transform, POX format, Enrich mediator etc., every suggestion I could find. (I can remove envelope element using XSLT if it is sent as part of the body, but not the one WSO2 adds in)

I can access the body, without SOAP envelope, using :

<property name="body" expression="$body/*[1]" type="OM"/>

but am not sure how to forward this to the API.

Any ideas how to stop this envelope being added in the first place in WSO2 ESB, or on how to remove it?

I used the xslt code from this answer, which works fine when I include the SOAP tags in the body, but has no effect on the SOAP envelope that seems to get automatically added in WSO2 (except to give the error, below).

I tried different variations of the line:

<xsl:apply-templates select="soap:Envelope/soap:Body/*"/>

such as

<xsl:apply-templates select="soap:Envelope/*"/>
<xsl:apply-templates select="/*"/>

this is an error I see in the ESB log:

Unable to perform XSLT transformation using : Value {name ='null', keyValue ='discountPayment'} against source XPath : s11:Body/child::[position()=1] | s12:Body/child::[position()=1] reason : Unable to create an OMElement using XSLT result

I am pretty new to WSO2 ESB, and have not used XSLT before, so may be some very basic mistake in my approach....

here is my proxy xml, and the XSLT "removeSOAP":

<?xml version="1.0" encoding="UTF-8"?>
<proxy name="APIServer" startOnLoad="true" trace="disable"
  transports="https http" xmlns="http://ws.apache.org/ns/synapse">
  <target>
    <inSequence>
      <log level="full">
        <property name="FirstLog" value="APITest LOG...."/>
        <property name="payload" expression="$body/*[1]" type="OM"/>
      </log>
      <xslt key="removeSOAP"/>              
      <log level="full">
        <property name="SecondLog" value="after xslt...."/>
      </log>
  <property name="messageType" scope="axis2" type="STRING" value="application/xml"/>
          <send>      
          <endpoint name="endpoint_urn_uuid_xxxxxx">
      <address trace="disable" uri="http://myAPIendpoint " />
    </endpoint>
              </send>
    </inSequence>
    <outSequence>
      <log level="full"/>   
      <send/> 
    </outSequence>
    <faultSequence/>
  </target>
</proxy>

<?xml version="1.0" encoding="UTF-8"?>
<localEntry key="removeSOAP" xmlns="http://ws.apache.org/ns/synapse">
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
    xmlns:m="http://www.example.org/stock">
    <xsl:template match="/">
        <xsl:apply-templates select="soap:Envelope/soap:Body/*"/>
    </xsl:template>
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>
</localEntry>
2
Please add code you have tried to this question. Consider reading this: stackoverflow.com/help/how-to-askAaron
Can you post your transaction that you are using including headers and you proxy service configuration?jchaplin
add your esb proxy config xml...Jorge Infante Osorio

2 Answers

1
votes

A colleague figured this out today, I post the answer here incase it helps someone in the future:

in the proxy service, before send, add the line

<property name="DISABLE_CHUNKING" value="true" scope="axis2"/>  

then it works.

No need for the XSLT transform that is shown above, just this line fixes it.

0
votes

if your backend it´s an API better you can use the http endpoint https://docs.wso2.com/display/ESB500/HTTP+Endpoint:

     <send>
        <endpoint>
           <http method="POST"
                 uri-template="http://your.backend.endpoint.org/"/>
        </endpoint>
     </send>