cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT Mapping Help

former_member10771
Active Participant
0 Kudos

Hi All,
Can someone please help me here. This is my source XML.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://www.test.com/v2" xmlns:v21="http://www.test.com/v21" xmlns:v1="http://www.test.com/v1">

    <soapenv:Header>

        <v2:XHeader>

            <v2:Name>name</v2:Name>

            <v2:Id>id</v2:Id>

        </v2:XHeader>

    </soapenv:Header>

    <soapenv:Body>

        <v21:Info v21:version="?">

            <v21:Code>code</v21:Code>

        </v21:Info>

    </soapenv:Body>

</soapenv:Envelope>

Here the value of Name and Id will be the system name which will send the data. So when sending the response back I need to send the same details what is sent by source.

This is my XSLT mapping . Can some one please help me to change this so that the Name and Id can be stored in mapping and again sent back when sending the response. I am not sure how we can do this in XSLT mapping.Now I am sending it to some field in ECC but the requirement is to store it in PI and send it back in response. Can someplease please tell me how I can store this in XSLT mapping here.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://www.test.com/v2" xmlns:v21="http://www.test.com/v21" exclude-result-prefixes="v2 v21 soapenv">

    <xsl:template match="./soapenv:Envelope">

        <ns1:MaterialERPBasicDataCreateRequestMessage_sync xmlns:ns1="http://sap.com/xi/SAPGlobal/Global">

            <MessageHeader>

                <ID>

                    <xsl:value-of select="./soapenv:Header/v2:XHeader/v2:Name"/>

                </ID>

                <UUID>

                    <xsl:value-of select="./soapenv:Header/v2:XHeader/v2:Id"/>

                </UUID>

            </MessageHeader>

            <Material>

                <TypeCode>

                <xsl:value-of select="./soapenv:Body/v21:Info/v21:Code"/>

                </TypeCode>

            </Material>

        </ns1:MaterialERPBasicDataCreateRequestMessage_sync>

    </xsl:template>

</xsl:stylesheet>

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member10771
Active Participant
0 Kudos

Hi,

I read a few blogs and found that we can use dynamic configuration in XSLT to store the same. I referred and changed a bit. Can someone please help me with the same. I am not sure how this will work.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"

xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"

xmlns:map="java.util.Map" xmlns:dyn="java.com.sap.aii.mapping.api.DynamicConfiguration" xmlns:key="java:com.sap.aii.mapping.api.DynamicConfigurationKey"

xmlns:v2="http://www.test.com/v2" xmlns:v21="http://www.test.com/v21" exclude-result-prefixes="v2 v21 soapenv">

  <xsl:template match="./soapenv:Envelope">

<xsl:variable name="v2:applicationName" select="/soapenv:Envelope/soapenv:Header/v2:XHeader/v2:Name"/>

<xsl:variable name="dynamic-conf" select="map.get($inputparam,'DynamicConfiguration')"/>

<xsl:variable name="dynamic-value" select="dyn.get($dynamic-conf,$dynamic-key)"/>

<xsl:copy-of select="."/>

 

        <ns1:MaterialERPBasicDataCreateRequestMessage_sync xmlns:ns1="http://sap.com/xi/SAPGlobal/Global">

            <MessageHeader>

                <ID>

                    <xsl:value-of select="./soapenv:Header/v2:XHeader/v2:Name"/>

                </ID>

                <UUID>

                    <xsl:value-of select="./soapenv:Header/v2:XHeader/v2:Id"/>

                </UUID>

            </MessageHeader>

            <Material>

                <TypeCode>

                <xsl:value-of select="./soapenv:Body/v21:Info/v21:Code"/>

                </TypeCode>

            </Material>

        </ns1:MaterialERPBasicDataCreateRequestMessage_sync>

    </xsl:template>

</xsl:stylesheet>

iaki_vila
Active Contributor
0 Kudos

Hi Amit,

Have you though to use GetPayloadValueBean and PutPayloadValueBean for your purpose?. Check this blog

Regards.

former_member10771
Active Participant
0 Kudos

Hi Inaki,

Thanks will check on that. I am using SOAP to Proxy( SOAP as XI3,.0) . Will this work for SOAP(proxy) receiver adapter.

former_member10771
Active Participant
0 Kudos

Hi Inaki,


I am able to do this with one value and successfully gettting it. Can you please tell me how do I add for multiple values . I have two fields so for one field I am getting it correctly. Somehow if I add one more field it gives error. Am I adding in right way.


For ID its working perfectly fine. But if I add one more UUID it gives error.

com.sap.engine.interfaces.messaging.api.exception.MessagingException: java.lang.NullPointerException: while trying to invoke the method org.w3c.dom.Node.appendChild(org.w3c.dom.Node) of a null object loaded from local variable 'template_parent'

former_member10771
Active Participant
0 Kudos

Hi,


Thanks I got it correct now. It was my mistake . One more question I am currently using this payload bean to store and then send the same data. But the problem is when I am sending it in response I am constructing a soap header in XSLT mapping which is needed for the legacy and sending the value in that.

Problem is in the soap body with the response I am again getting the header value which I have read earlier.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://www.test.com/v2" xmlns:v21="http://www.test.com/v21" xmlns:v1="http://www.test.com/v1">

    <soapenv:Header>

        <v2:XHeader>

            <v2:Name>Value from put payload bean</v2:Name>

            <v2:Id>put payload bean</v2:Id>

        </v2:XHeader>

    </soapenv:Header>

    <soapenv:Body>

Something like this....

<ns1:MaterialERPBasicDataCreateResponseMessage_sync xmlns:ns1="http://sap.com/xi/SAPGlobal/Global">

<MessageHeader>

                <ID>valuefrom bean</ID>

                <UUID>value from bean</UUID>

            </MessageHeader>

    </soapenv:Body>

</soapenv:Envelope>

How can I get rid of this.Because I have already got the values in Name and Id above. Can i remove from here somehow. Will that Removebean work here.

iaki_vila
Active Contributor
0 Kudos

Hi Amit,

Have you tried to use the RemovePayloadValueBean with the same path that the parameter that you have defined for the get parameter?

You can have a look the documentation: Adding RemovePayloadValueBean in the Module Processor -  Adding Modules to the Module Processor - SA...

Hope this helps.

Regards.