cancel
Showing results for 
Search instead for 
Did you mean: 

SOAP to SOAP Scenario

former_member10771
Active Participant
0 Kudos

Hi,

I have a scenario for SOAP to SOAP. The WSDL when imported in SAP PI has two separate WSDL one for header and one for body.

So ideally I am not sure how to implement the same in PI. Because if I import it in messsge mapping I get only header and not the body part. But the same WSDL when I open via SOAP UI or some other tool it comes with header and body combined.

Can someone please tell me how to approach this scenario or is there any way the header can be attached to the body .

Accepted Solutions (0)

Answers (1)

Answers (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Amit,

The only was to attach the header and the body is to build it via XLST or Java Mapping. You also have to check Do Not Use SOAP Envelope in the receiver communication channel for that to work.

Regards,

Mark

former_member10771
Active Participant
0 Kudos

Thanks Mark for the response.  This is my structure that is coming from the source.

<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></v2:Name>

         <v2:Id></v2:Id>

      </v2:XHeader>

   </soapenv:Header>

   <soapenv:Body>

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

         <v21:Code></v21:Code>

      </v21:Info>

   </soapenv:Body>

</soapenv:Envelope>

I have written this XSLT mapping currently to read the structure. But I am not able to display the tree structure output. Can you please help me with the same.

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

    <xsl:output omit-xml-declaration="yes" indent="yes"/>

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

        <soapenv:Envelope>

            <soapenv:Header>

            <soapenv:Body>

                <Header>

                    <xsl:apply-templates select="soapenv:Header/v2:XHeader/node()"/>

                </Header>

                <Body>

                    <xsl:apply-templates select="./soapenv:Body/v21:Info/node()"/>

                </Body>

            </soapenv:Body>

            </soapenv:Header>

        </soapenv:Envelope>

    </xsl:template>

    <xsl:template match="soapenv:Header/v2:XHeader/node()">

        <xsl:element name="{local-name()}">

            <xsl:apply-templates select="@* | node()"/>

        </xsl:element>

    </xsl:template>

    <xsl:template match="./soapenv:Body/v21:Info/node()">

        <xsl:element name="{local-name()}">

            <xsl:apply-templates select="@* | node()"/>

        </xsl:element>

    </xsl:template>

</xsl:stylesheet>

iaki_vila
Active Contributor
0 Kudos

Hi Amit,

You need to add the v21 namespace to your XSL. It will be:


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

    <xsl:output omit-xml-declaration="yes" indent="yes"/>

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

        <soapenv:Envelope>

            <soapenv:Header>

                <soapenv:Body>

                    <Header>

                        <xsl:apply-templates select="soapenv:Header/v2:XHeader/node()"/>

                    </Header>

                    <Body>

                        <xsl:apply-templates select="./soapenv:Body/v21:Info/node()"/>

                    </Body>

                </soapenv:Body>

            </soapenv:Header>

        </soapenv:Envelope>

    </xsl:template>

    <xsl:template match="soapenv:Header/v2:XHeader/node()">

        <xsl:element name="{local-name()}">

            <xsl:apply-templates select="@* | node()"/>

        </xsl:element>

    </xsl:template>

    <xsl:template match="./soapenv:Body/v21:Info/node()">

        <xsl:element name="{local-name()}">

            <xsl:apply-templates select="@* | node()"/>

        </xsl:element>

    </xsl:template>

</xsl:stylesheet>

Regards.

former_member10771
Active Participant
0 Kudos

Thanks Inaki,

I am able to execute this XSLT mapping under the operation mapping. But the problem is I am getting this error everytime. There is no error in XSLT execution.

iaki_vila
Active Contributor
0 Kudos

Hi Amit,

You Header tag seems to be fine to me when i test it, but i don't understand why you are omitting the XML declaration, if you don't have an XML the Operation can't show to you a XML tree. Have you try to skip the instruction:

<xsl:output omit-xml-declaration="yes" indent="yes"/>

?

Regards.

former_member10771
Active Participant
0 Kudos

Hi,


I have removed that omit XML. I am getting something like this now.

XSLTNEW/NewXSLT.xsl; details: sapximapping:XSLTNEW/NewXSLT.xsl: line 21: Error parsing XPath expression './soapenv:Body/v21:Info/node()"'.

Not sure what is wrong here.. If I check the XML tool kit and test I get the XSLT mapping as successful. But the node is not generated and the target is something like this.

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

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><soapenv:Body><Header></><Name/></><Id/></>

           

           

           

           

           

           

       <Session>

           

           

           

           

           

               ?

               ?

               ?

               ?

               ?

               ?

           

           

           

               ?

               ?

               ?

           

         </Session></></Header><Body>

         ?

         000001

        

        

           

            ?

            ?

        

        

        

           

            ?

           

            ?

        

      </Body></soapenv:Body></soapenv:Header></soapenv:Envelope>.

former_member10771
Active Participant
0 Kudos

Hi Inaki,


This is the full header and body from source message. Mite be I didnt mention full XML earlier so there might be some confusion.

This is the source XML and the target structure is as below

<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></v2:Name>

         <v2:Id></v2:Id>

<v2:UserInformation>

            <v2:Type></v2:Type>

            <v2:Id></v2:Id>

         </v2:UserInformation>

      </v2:XHeader>

   </soapenv:Header>

   <soapenv:Body>

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

         <v21:Code></v21:Code>

<v21:Dep>

            <v21:Code>?</v21:Code>

            <v21:Date>?</v21:Date>

         </v21:Dep>

      </v21:Info>

   </soapenv:Body>

</soapenv:Envelope>

This attachment is the target. I need to map the Name and Id in XHeader to ID and UUID under header and the Code and Date to Internal ID and Type Code.

former_member10771
Active Participant
0 Kudos

Can you please let me know on the above as I guess this might be the problem the target is not generating it properly.

former_member10771
Active Participant
0 Kudos

This extra </> is causing the problem.

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

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><soapenv:Body><Header></><Name/></><Id/></>

          

          

          

          

          

          

       <Session>

          

          

          

          

          

               ?

               ?

               ?

               ?

               ?

               ?

          

          

          

               ?

               ?

               ?

          

         </Session></></Header><Body>

         ?

         000001

       

       

          

            ?

            ?

       

       

       

          

            ?

          

            ?

       

      </Body></soapenv:Body></soapenv:Header></soapenv:Envelope>.

iaki_vila
Active Contributor
0 Kudos

Hi Amit,

I'm a bit confused, i think your XSL can't generate an XML tag like </>, even if i try to force it. Are you sure that in your operation mapping you have only the XSL?, this errors seems to be in a java mapping.

According with you previous message your XSL doesn't go to generate the root tag, the i suppose you have more mappings in cascade, am i right?.

If you share a source and target XML (to do copy/paste and to test quicker the XSL) we can help better. Avoid business data and set values like 1, 2 and so on.

Regards.

former_member191435
Contributor
0 Kudos

Hi Amit,

After your XSL mapping you have to Use another mapping to send the data to the target.

As suggested by Vila,  Please send us your structure and XSL so that we can get some idea.that where you get dtruck

Thanks,

Sreenivas

former_member10771
Active Participant
0 Kudos

Thanks Inaki,

I am attaching the source and sample target XML for which I have to do XSLT mapping

This is my source XML coming from source.

<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></v2:Name>

         <v2:Id></v2:Id>

<v2:UserInformation>

            <v2:Type></v2:Type>

            <v2:Id></v2:Id>

         </v2:UserInformation>

      </v2:XHeader>

   </soapenv:Header>

   <soapenv:Body>

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

         <v21:Code></v21:Code>

<v21:Dep>

            <v21:InfoCode>?</v21:InfoCode>

            <v21:Date>?</v21:Date>

         </v21:Dep>

      </v21:Info>

   </soapenv:Body>

</soapenv:Envelope>

and this is the target XML to which I need to do the mapping.

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

<ns1:MaterialERPBasicDataCreateRequestMessage_sync xmlns:ns1="http://sap.com/xi/SAPGlobal/Global"><MessageHeader><ID></ID><UUID></UUID><ReferenceID schemeID="" schemeAgencyID=""></ReferenceID></MessageHeader><Material><InternalID>Constant</InternalID><TypeCode>Constant</TypeCode><IndustrialSectorCode>Constant</IndustrialSectorCode></Material></ns1:MaterialERPBasicDataCreateRequestMessage_sync>

I need to map Name and Id from Xheader above to the ID and UUID

and the Code and InfoCode from the SOAP Body above to Type Code and Industrial Sector Code.

former_member10771
Active Participant
0 Kudos

Can you please let me know on the same.

iaki_vila
Active Contributor
0 Kudos

Hi Amit,

I think you want a generic solution but in your case when the name of the tags and the structure change, i think is not possible to have a generic solution.

You can check if this solution is right for you:

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:UserInformation>

                <v2:Type/>

                <v2:Id/>

            </v2:UserInformation>

        </v2:XHeader>

    </soapenv:Header>

    <soapenv:Body>

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

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

            <v21:Dep>

                <v21:InfoCode>infocode</v21:InfoCode>

                <v21:Date>?</v21:Date>

            </v21:Dep>

        </v21:Info>

    </soapenv:Body>

</soapenv:Envelope>

XSL:


<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>

                <InternalID>Constant</InternalID>

                <TypeCode>

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

                </TypeCode>

                <IndustrialSectorCode>

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

                </IndustrialSectorCode>

            </Material>

        </ns1:MaterialERPBasicDataCreateRequestMessage_sync>

    </xsl:template>

</xsl:stylesheet>

Target XML get from the XSL:


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

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

    <MessageHeader>

        <ID>name</ID>

        <UUID>id</UUID>

    </MessageHeader>

    <Material>

        <InternalID>Constant</InternalID>

        <TypeCode>code</TypeCode>

        <IndustrialSectorCode>infocode</IndustrialSectorCode>

    </Material>

</ns1:MaterialERPBasicDataCreateRequestMessage_sync>

Hope this helps.

Regards.

former_member10771
Active Participant
0 Kudos

Thanks. I will check and update on this one.

former_member10771
Active Participant
0 Kudos

Hi Inaki,

I have checked with this XSL. Not very sure but for this mapping it is giving me this error.

For the other XSLT mappings everything is working fine not sure for only this one why it is giving like this. The XSL is succcessful but the target is not getting generated.

former_member10771
Active Participant
0 Kudos

Hi,


Thanks I got the output now.. I changed the XSL code a bit.


Changed  <xsl:template match="./soapenv:Envelope"> to <xsl:template match="/"> and subsequently in below <xsl:value-of select="./soapenv:Header/v2:XHeader/v2:Name"/> to <xsl:value-of select="/soapenv:Header/v2:XHeader/v2:Name"/>. It is working now. Not sure why it was giving that error for ./soapenvelope.

Thanks.