on 08-25-2006 4:29 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.