cancel
Showing results for 
Search instead for 
Did you mean: 

Removing SOAP Env and Header

satsunros
Explorer
0 Kudos

Dear SAP Forum,

I am struggling to get remove of SoapEnv ,header, body and fault from XSLT mapping

My Soap Envelop format is:

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

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

<soap:Header>

<wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing">urn:uuid</wsa:MessageID>

</soap:Header>

<soap:Body>

<soap:Fault>

<faultstring>OrderError</faultstring>

<detail>

<ns3:E4qServiceException xmlns:ns2="http://xmldefs.ag.com/DD/Commons" xmlns:ns3="http://xmldefs.ag.com/SP/Applications/LLI/Service/V1">

<ns2:FaultTimestamp>2019-05-16T14:51:33.856+02:00</ns2:FaultTimestamp>

<ns2:FaultDescription languageID="en">OrderError</ns2:FaultDescription>

<ns2:FaultReason>Class: business, Code: 83017</ns2:FaultReason>

</ns3:E4qServiceException>

</detail>

</soap:Fault>

</soap:Body>

</soap:Envelope>

Expected Output format is:

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

<ns3:E4qServiceException xmlns:ns2="http://xmldefs.ag.com/DD/Commons" xmlns:ns3="http://xmldefs.ag.com/SP/Applications/LLI/Service/V1">

<ns2:FaultTimestamp>2019-05-16T14:51:33.856+02:00</ns2:FaultTimestamp>

<ns2:FaultDescription languageID="en">OrderError</ns2:FaultDescription>

<ns2:FaultReason>Class: business, Code: 83017</ns2:FaultReason>

</ns3:E4qServiceException>

My XSLT code is giving in consistence result

Could you please give me some idea , how to get it this output.

With Best Regards,
Sateesh N

satsunros
Explorer
0 Kudos

Any comments on this

Accepted Solutions (1)

Accepted Solutions (1)

Muniyappan
Active Contributor
0 Kudos

good to know that you have achieved. i am able to get the required output with this code. code gets complecated when tried to remove soap tag from the input.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns3="http://xmldefs.ag.com/SP/Applications/LLI/Service/V1" 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns2="http://xmldefs.ag.com/DD/Commons"
exclude-result-prefixes = "soap">
    <xsl:output method="xml" indent = "yes" />
     <xsl:template match="/">
        <xsl:apply-templates select="soap:Envelope/soap:Body/soap:Fault/detail/*"/>
    </xsl:template>
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="*" priority="1">
    <xsl:element name="{name()}" namespace="{namespace-uri()}">
      <xsl:copy-of select="namespace::*[not(name()='soap')]"/>
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>
  <xsl:template match="soap:Envelope/soap:Body/soap:Fault/detail/*" priority="2">
    <xsl:element name="ns3:E4qServiceException">
      <xsl:copy-of select="namespace::*[not(name()='soap')]"/>
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>

Answers (4)

Answers (4)

satsunros
Explorer
0 Kudos

Hi Muniyappan, Yes exactly with your code also , it is perfectly suitable to this output.

Thank you.

satsunros
Explorer
0 Kudos

Hello Muniyappan,

thanks for your help. I achieved on this with this built XSLT code

<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:response="http://tempuri.org/" xmlns:ns2="http://xmldefs.ag.com/DD/Commons" xmlns:ns3="http://xmldefs.ag.com/PP/Applications/ELI/dfde/V1">

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

<xsl:strip-space elements="*"/>

<xsl:template match="/">

<xsl:apply-templates select="//detail/node()"/>

</xsl:template>

<xsl:template match="@* | node()">

<xsl:copy>

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

</xsl:copy>

</xsl:template>

</xsl:stylesheet>

satsunros
Explorer
0 Kudos

Hi Muniyappan,

This is XSLT code which I am using for this.

<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns:response="http://tempuri.org/"> <xsl:output method="xml" encoding="UTF-8" indent="yes"/>

<xsl:strip-space elements="*"/>

<xsl:template match="/">

<xsl:apply-templates select="//detail/node()"/>

</xsl:template>

<xsl:template match="*">

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

<xsl:apply-templates/>

</xsl:element>

</xsl:template>

<xsl:template match="@*">

<xsl:copy/>

</xsl:template>

</xsl:stylesheet>


Present output with this XSLT is :

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

<E4qServiceException>

<FaultTimestamp>2019-05-16T14:51:33.856+02:00</FaultTimestamp>

<FaultDescription>OrderErrror</FaultDescription>

<FaultReason>Class: business, Code: 83017</FaultReason>

</E4qServiceException>

Comment: With this XSLT I am missing Attribute value and name prefix

Expected Output format is:

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

<ns3:E4qServiceException xmlns:ns2="http://xmldefs.ag.com/DD/Commons" xmlns:ns3="http://xmldefs.ag.com/SP/Applications/LLI/Service/V1">

<ns2:FaultTimestamp>2019-05-16T14:51:33.856+02:00</ns2:FaultTimestamp>

<ns2:FaultDescription languageID="en">OrderError</ns2:FaultDescription>

<ns2:FaultReason>Class: business, Code: 83017</ns2:FaultReason>

</ns3:E4qServiceException>

And suggestions here.

Thank you

Sateesh N

Muniyappan
Active Contributor
0 Kudos

could you please provide your xslt code here?