We are getting following soap request
- <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
- <soapenv:Body>
- <catalog>
- <product>
- <number>100</number>
- <name>BaseBall</name>
- <colourChoices>Black</Currency>
- <price>$50</DateTime>
- </product>
- </ExchangeRate
- </catalog>
- <soapenv:Body>
- <soapenv:Envelope>
Then we want to add ex0 prefix to catalog tag and namespace must be http://sample.com/test//blog/Sample
So we need to create sample.xslt style sheet like below
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
- <xsl:output indent="yes"/>
- <xsl:strip-space elements="*"/>
- <!--match all the nodes and attributes-->
- <xsl:template match="node()|@*">
- <xsl:copy>
- <xsl:apply-templates select="node()|@*">
- </xsl:apply-templates></xsl:copy>
- </xsl:template>
- <!--Select the element need to be apply the namespace and prefix -->
- <xsl:template match="catalog">
- <!--Define the namespace with prefix ns0 -->
- <xsl:element name="ex0:{name()}" namespace="http://sample.com/test/blog/Sample">
- <!--apply to above selected node-->
- <xsl:apply-templates select="node()|@*">
- </xsl:apply-templates></xsl:element>
- </xsl:template>
- </xsl:stylesheet>
Then Go to Manage-> Service Bus-> Local Entries and add the created sample.xslt file.
Then in your proxy add xslt mediator as <xslt key="sample.xslt"/> and refer the sample.xslt. Add a log mediator after that to check the changed payload
- <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
- <soapenv:Body>
- <ex0:catalog xmlns:ex0="http://sample.com/test/blog/Sample">
- <product>
- <number>100</number>
- <name>BaseBall</name>
- <colourChoices>Black</colourChoices>
- <price>50</price>
- </product>
- </ex0:catalog>
- </soapenv:Body>
- </soapenv:Envelope>
No comments:
Post a Comment