cancel
Showing results for 
Search instead for 
Did you mean: 

Add tags to payload before message mapping

Former Member
0 Kudos

Hi,

I've the following problem:

I get the following XML payload:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:MT_Pricing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:xsd="http://www.w3.org/2001/XMLSchema"

xmlns:tns="urn:pricing" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"

xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"

xmlns:ns0="urn:pricing">

   <scales>

      <scale>500.00</scale>

      <rate>2.13</rate>

   </scales>

   <scales>

      <scale>1000.00</scale>

      <rate>1.93</rate>

   </scales>

   <amount>2.33</amount>

   <currency>CNY</currency>

   <per>1  </per>

   <uom>KG</uom>

</ns0:MT_Pricing>

I've the requirement to add the following tags to the XML payload BEFORE performing the message mapping:

<scales>

    <scale>0.00</scale>

    <rate>2.33</rate>

</scales>

That means that I've to fill the value of <amount> to <rate>.

How can I do that?

Is it best to use XSLT mapping for that purpose?

You're help is much appreciated

Accepted Solutions (0)

Answers (1)

Answers (1)

stefan_grube
Active Contributor
0 Kudos

You can use graphical mapping tool also. Define a message mapping, where source and target structure is the same, so you can add this mapping as first step to your operation mapping.

Of course you can also use XSLT or Java mapping, but I think it is more convinient to use graphical mapping tool.

Former Member
0 Kudos

Stefan Grube wrote:

You can use graphical mapping tool also. Define a message mapping, where source and target structure is the same, so you can add this mapping as first step to your operation mapping.

Hi Stefan,

I'm just trying to do that, but I'm a little bit lost.

I don't know how to map the <scales> to <scales> and the <amount> to <rate> simultaneously...

For the given example my output should be like that:

<?xml version="1.0" encoding="UTF-8"?> 

  1. <ns0:MT_Pricing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  2. xmlns:xsd="http://www.w3.org/2001/XMLSchema"  
  3. xmlns:tns="urn:pricing" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"  
  4. xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" 
  5. xmlns:ns0="urn:pricing"> 
  6.    <scales> 
  7.       <scale>0.00</scale> 
  8.       <rate>2.33</rate> 
  9.    </scales>
  10. <scales> 
  11.       <scale>500.00</scale> 
  12.       <rate>2.13</rate> 
  13.    </scales> 
  14.    <scales> 
  15.       <scale>1000.00</scale> 
  16.       <rate>1.93</rate> 
  17.    </scales> 
  18.    <amount>2.33</amount> 
  19.    <currency>CNY</currency> 
  20.    <per></per> 
  21.    <uom>KG</uom> 
  22. </ns0:MT_Pricing> 

It would be very kind if you could help me on that!

stefan_grube
Active Contributor
0 Kudos

right-click on node scales, choose "duplicate subtree" from menu. Now you have two entries for scales in target structure. Assign scales to first, amount to second.

Former Member
0 Kudos

Thanks, Stefan.

As I don't like graphical message mapping (and I also was not able to create it correctly ), I succeeded to map the payload via XSLT mapping:

<?xml version='1.0' encoding='utf-8'?>

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output method="xml" encoding="UTF-8"/>

    <xsl:template match="/">

        <MT_Pricing>

            <xsl:if test="MT_Pricing/scales">

                <scales>

                    <scale>0.00</scale>

                    <rate>

                        <xsl:value-of select="MT_Pricing/amount" />

                    </rate>

                </scales>

            </xsl:if>

            <xsl:copy-of select="MT_Pricing/scales" />

            <xsl:copy-of select="MT_Pricing/amount" />

            <xsl:copy-of select="MT_Pricing/currency" />

            <xsl:copy-of select="MT_Pricing/per" />

            <xsl:copy-of select="MT_Pricing/uom" />

        </MT_Pricing>

    </xsl:template>

</xsl:stylesheet>

But nevertheless thanks for your help.