cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT To Remove Soap Envelope...

HarshC
Active Participant
0 Kudos

Hi,

I'm trying to use XSLT mapping to remove SOAP envelope from a soap response message. Facing some issues.

This is my response message(with soap envelope):

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

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">

<soapenv:Body>

<loginResponse xmlns="urn:enterprise.soap.sforce.com">

<result>

<passwordExpired>false</passwordExpired>

[Removed by the moderator.]

<sessionId>aaaaaaaaaaaaaaa</sessionId>

<userId>bbbbbbbbbb</userId>

</result>

</loginResponse>

</soapenv:Body>

</soapenv:Envelope>

-


This is my xsl program:

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

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

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="soapenv:Body">

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

</xsl:template>

</xsl:stylesheet>

-


Where am I going wrong here?

Regards,

Harsh

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos

This is wrong:

<xsl:template match="soapenv:Body">

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

When you have template match="node", you can only work with sub nodes. So your XSLT searches for sub nodes of <i>Body</i> with the name <i>Body</i>.

You could use select=".", but you want to remove the SOAP envelope, so you have to remove the tag Body as well:

<xsl:template match="soapenv:Body">

<xsl:copy-of select="child::node()"/>

Regards

Stefan

HarshC
Active Participant
0 Kudos

Thanks Stefan!

A few questions. Is there any tool I can use to help me with XSL program creation. How do I test my code, other than in XI. Also any usefull links are welcome.

Regards,

Harsh

stefan_grube
Active Contributor
0 Kudos

Get the lib sapxmltoolkit.jar. You find it on your XI installation or in your NW developer studio. Put it in a folder. Write a .bat script:

java -cp sapxmltoolkit.jar com.sap.engine.lib.xsl.xslt.CommandLine test.xml test.xsl > result.xml
pause

put this script in the same folder, your test.xml and the test.xsl as well and run it.

Maybe there are better tools for it, but it works for me

Regards

Stefan

stefan_grube
Active Contributor
0 Kudos

The best link about XSLT is this:

http://www.w3schools.com/xsl/default.asp

XPATH is an important part of XSLT:

http://www.w3schools.com/xpath/default.asp

Stefan

Former Member
0 Kudos

try looking at this

i guess i have answered this question there.

udo_martens
Active Contributor
0 Kudos

Hi Harsh,

standard is the Altovas XMLSpy, you can use a freeware home version. You can test as well with IE (yes, Microsofts Internet Explorer). Just put

<?xml-stylesheet type="text/xsl"  href="C:myFoldermyStyle.xsl"?>

to the top (behind the declaration) of your XML document.

Regards,

Udo

Answers (0)