cancel
Showing results for 
Search instead for 
Did you mean: 

SOAP envelope/header and body addition using XSLT Mapping in SAP PI

former_member309269
Participant
0 Kudos

code.txtDear All,

I have a requirement to add the SOAP Envelope, Header and Body segments to match the desired format required by the target party. I have tried to use XSLT to achieve this. I tried with the below code but when I test in the operation mapping using 1 to 2 (1- Message mapping, 2-xslt), it fails with below error in PI Operation mapping test :

Transformer Configuration Exception occurred when loading XSLT SOAP_ENV.xsl; details: Could not compile stylesheet

Can anyone please let me now what could be the root cause and what should be the correct XSLT code to be used if mine below is not correct (if something else to be modified in this code to handle in PI mapping)?

CODE :

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml"/>

<xsl:template match="/">

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">

<soap:Header />

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

</soap:Body>

</soap:Envelope>

</xsl:template>

</xsl:stylesheet>

PS: I tried in Stylus Studio, there it is giving me the desired output but during testing in PI Operation Mapping, getting the below error. Please help.

Transformer Configuration Exception occurred when loading XSLT SOAP_ENV.xsl; details: Could not compile stylesheet

former_member309269
Participant
0 Kudos

Any pointers please?

former_member309269
Participant
0 Kudos

Please help with the XSLT code in order to get the expected output (pfa)expected-output.txt

My input XML to XSLT is like this:

<BillingRequest>

<declarantTin>200000328-1</declarantTin> /* this declarantTin is a field inside Billing Request */

</BillingRequest>

former_member309269
Participant
0 Kudos

Hi All,

I am able to run in the Operation Mapping using the attached XSLT code. xsltcode.txt

Now, I am getting the output as attached and below output-xslt.txt. But I need to replace the namespace prefix "ns0" with "tem" at all places in the output. Can you please let me know what can be done to modify the XSLT code to achieve this?

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

http://tempuri.org/"; xmlns:soap=" http://schemas.xmlsoap.org/soap/envelope/">

<soap:Body>

http://tempuri.org/">;

<ns0:declarantTin>abcd</ns0:declarantTin>

</ns0:BillingRequest>

</soap:Body>

</soap:Envelope>

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member309269
Participant
0 Kudos

Hi All,

I am able to run in the Operation Mapping using the attached XSLT code. xsltcode.txt

Now, I am getting the output as attached and below output-xslt.txt. But I need to replace the namespace prefix "ns0" with "tem" at all places in the output. Can you please let me know what can be done to modify the XSLT code to achieve this?

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

http://tempuri.org/"; xmlns:soap=" http://schemas.xmlsoap.org/soap/envelope/">

<soap:Body>

http://tempuri.org/">;

<ns0:declarantTin>abcd</ns0:declarantTin>

</ns0:BillingRequest>

</soap:Body>

</soap:Envelope>

xsltcode.txt (453 B) output-xslt.txt

(336 B)

former_member309269
Participant
0 Kudos

Please let me know the modified XSLT code (please change the existing attached XSLT code to achieve this) to replace the namespace prefix "ns0" with "tem" at all places in the output

xsltcode.txt

former_member309269
Participant
0 Kudos

Any pointers?

former_member190293
Active Contributor
0 Kudos

Hi Amita!

Try to remove the space in Header tag.

The second option is to change XSLT processor to Xalan in your Stylus project and run the test.

Regards, Evgeniy.

former_member309269
Participant
0 Kudos

Thanks Evgeniy for the response. I tried to remove the space in Header tag still the same error while testing in PI Operation Mapping. I need to fix this in PI mapping only

Though in XSLT processor, I don't find any option to change to Xalan. Moreover, the intention is to run the xslt successfully in PI which I am not able to do so.

Please suggest what could be the issue and what XSLT code should be used.

My input XML to XSLT is like this:

<BillingRequest>

<declarantTin>200000328-1</declarantTin> /* this declarantTin is a field inside Billing Request */

</BillingRequest>

I want the output like below (also attached expected output)expected-output.txt:

<soapenv:Envelope xmlns:ser="http://tempuri.org/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header/>

<soapenv:Body>

<ser:BillingRequest>

<ser:declarantTin>200000328-1</ser:declarantTin>

</ser:BillingRequest>

</soapenv:Body>

</soapenv:Envelope>

Please help me with code.

Regards,

Amita

former_member190293
Active Contributor
0 Kudos

I haven't worked with Stylus for quite a long time, but I remember there was an option to select XSLT processor used for transformation both by default and for current scenario. It could be found in scenario settings.

http://www.stylusstudio.com/xslt-editor.html

You can select "Java built-in" processor type. It must be xsltc processor.

The point is that PI uses xsltc java processor based on Xalan. So, to ensure if your XSLT works in PI operation mapping as expected you should test it using Xalan or xsltc. If you perform the test and get errors during it - you will be able to see the error description in Stylus Studio.

Regards, Evgeniy.

former_member309269
Participant
0 Kudos

Hi Evgeniy,

I tried to run the XSLT code using by selecting Java built in processor but it does not support debugging (says XSLT debugging is not possible with this type of XSLT processor)

I think different XSLT code is required to achieve my target desired output, looking forward to it.

former_member309269
Participant
0 Kudos

Hi All,

I am able to run in the Operation Mapping using the attached XSLT code. xsltcode.txt

Now, I am getting the output as attached and below output-xslt.txt. But I need to replace the namespace prefix "ns0" with "tem" at all places in the output. Can you please let me know what can be done to modify the XSLT code to achieve this?

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

<soap:Envelope xmlns:tem="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header/>

<soap:Body>

<ns0:BillingRequest xmlns:ns0="http://tempuri.org/">

<ns0:declarantTin>abcd</ns0:declarantTin>

</ns0:BillingRequest>

</soap:Body>

</soap:Envelope>