Transforming the SOAP message to REST XML message- OSB
While invoking the REST interface from OSB with the content type defined as application\xml, the target system will expect the simple XML message without the target namespace specified.The XSLT can be used to remove the name space from SOAP message but before performing this operation the SOAP envelope of the body variable should be removed
After removing the namespace the XML should be assigned to the body variable to send to target system.
Follow the below steps to achieve the same:
Remove SOAP Envelope:
The below XSLT will help as to remove the namespace from the XML.Create a XSLT resource from SB console.
Add a Assign activity with the XSLT resource
Assign the output to a temp variable - var1.
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="soapenv:*">
<xsl:apply-templates select="@* | node()" />
</xsl:template>
</xsl:stylesheet>
Removing Namespace:
The below XSLT will help as to add the target namespace to the XML.Create a XSLT resource from SB console.
Add a Assign activity with the XSLT resouce to remove the namespace from the variable var1
Assign the ouput to a temp variable - var2
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@* | node()" />
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="." />
</xsl:attribute>
</xsl:template>
<xsl:template match="text() | comment() | processing-instruction()">
<xsl:copy />
</xsl:template>
</xsl:stylesheet>
Hi Albin,
ReplyDeleteThe last replace activity is again adding soapenv to the rest payload i.e to the $body, Is there anyway to avoid the soapenv?