xsl-list
[Top] [All Lists]

[xsl] soap:Header update

2012-03-13 13:30:50
Hi,
    I have a soap response msg with header. i wanted to add the soap header 
with new elements along with existing ones.
Here is my request

<s:Envelope 
xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
 xmlns:s="http://schemas.xmlsoap.org/soap/envelope/";>
        <s:Header>
                <ActivityId CorrelationId="2f96f8f1-7907" 
xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics";>dffb19ef-7232-4357</ActivityId>
                <o:Security s:mustUnderstand="1" 
xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";>
                        <u:Timestamp u:Id="_0">
                                <u:Created>2012-03-13T17:55:36.191Z</u:Created>
                                <u:Expires>2012-03-13T18:00:36.191Z</u:Expires>
                        </u:Timestamp>
                </o:Security>
        </s:Header>
        <s:Body>
                <SearchResponse xmlns="http:/abcd.com/Case">
                        <SearchCasesResult 
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:a="http://abcdcom//Response";>
                                
                        </SearchCasesResult>
                </SearchCasesResponse>
        </s:Body>
</s:Envelope>


Here is the response that i am expecting

<s:Envelope 
xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
 xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"; >
        <s:Header>
                <ActivityId CorrelationId="2f96f8f1-7907" 
xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics";>dffb19ef-7232-4357</ActivityId>
                <o:Security s:mustUnderstand="1" 
xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";>
                        <u:Timestamp u:Id="_0">
                                <u:Created>2012-03-13T17:55:36.191Z</u:Created>
                                <u:Expires>2012-03-13T18:00:36.191Z</u:Expires>
                        </u:Timestamp>
                </o:Security>
                <head:ESBHeader xmlns:con="http://abcd.com/head"; >
                        <head:ESBProps>
                                <head:Property>
                                        <head:name/>
                                        <head:value/>
                                </head:Property>
                        </head:ESBProps>                        
                </head:ESBHeader>
                 <con:Context xmlns:con="http://abcd.com/context";>
         <con:CtxProps>
            <con:Property>
          </con:Property>
         </con:CtxProps>
      </con:Context>
        </s:Header><xsl:stylesheet 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; version="1.0"  
xmlns:head="http://abcd.com/header"; xmlns:con="http://abcd.com/context"; >
        <xsl:output method="xml" indent="yes"/>
        <!-- identity transform -->
        <xsl:template match="@*|node()">
                <xsl:copy>
                <xsl:copy-of 
select="document('')/xsl:stylesheet/namespace::*[not(local-name() = 'xsl')]"/>
                <xsl:apply-templates select="@*|node()"/>
                </xsl:copy>
                 <!--  <xsl:copy-of select="/" />-->
        </xsl:template>
        <!-- special handling for soap:Header -->
        <xsl:template 
match="/*[local-name()='Envelope']/*[local-name()='Header']">
                
                <soapenv:Header>
                
          <xsl:call-template name="ESBHeader"></xsl:call-template>
          <xsl:call-template name="ContextHeader"></xsl:call-template>
                
                
                </soapenv:Header>
                        
        </xsl:template>
        
        <xsl:template name="ESBHeader">
        
        <xsl:variable name="Headeradfad">
          <head:ESBHeader >
                        <head:ESBProps>
                                <head:Property>
                                        <head:name/>
                                        <head:value/>
                                </head:Property>
                        </head:ESBProps>
                        
                </head:ESBHeader>
        </xsl:variable>
           <xsl:copy-of select="$Headeradfad"></xsl:copy-of>
        </xsl:template>
        <xsl:template name="ContextHeader">
        <con:Context >
                
                        <con:CtxProps>
                                <con:Property>
                                        <con:name/>
                                        <con:value/>
                                </con:Property>
                        </con:CtxProps>
                </con:Context>
        </xsl:template>
        
</xsl:stylesheet>


        <s:Body>
                <SearchResponse xmlns="http:/abcd.com/Case">
                        <SearchCasesResult 
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:a="http://abcdcom//Response";>
                                
                        </SearchCasesResult>
                </SearchCasesResponse>
        </s:Body>
</s:Envelope>


I tried with the following peace of code, but its overridding existing 
information in the SOAPHeader,
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; version="1.0"  
xmlns:head="http://abcd.com/header"; xmlns:con="http://abcd.com/context"; >
        <xsl:output method="xml" indent="yes"/>
        <!-- identity transform -->
        <xsl:template match="@*|node()">
                <xsl:copy>
                <xsl:copy-of 
select="document('')/xsl:stylesheet/namespace::*[not(local-name() = 'xsl')]"/>
                <xsl:apply-templates select="@*|node()"/>
                </xsl:copy>
                 <!--  <xsl:copy-of select="/" />-->
        </xsl:template>
        <!-- special handling for soap:Header -->
        <xsl:template 
match="/*[local-name()='Envelope']/*[local-name()='Header']">
                
                <soapenv:Header>
                
          <xsl:call-template name="ESBHeader"></xsl:call-template>
          <xsl:call-template name="ContextHeader"></xsl:call-template>
                
                
                </soapenv:Header>
                        
        </xsl:template>
        
        <xsl:template name="ESBHeader">
        
        <xsl:variable name="Headeradfad">
          <head:ESBHeader >
                        <head:ESBProps>
                                <head:Property>
                                        <head:name/>
                                        <head:value/>
                                </head:Property>
                        </head:ESBProps>
                        
                </head:ESBHeader>
        </xsl:variable>
           <xsl:copy-of select="$Headeradfad"></xsl:copy-of>
        </xsl:template>
        <xsl:template name="ContextHeader">
        <con:Context >
                
                        <con:CtxProps>
                                <con:Property>
                                        <con:name/>
                                        <con:value/>
                                </con:Property>
                        </con:CtxProps>
                </con:Context>
        </xsl:template>
        
</xsl:stylesheet>




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


<Prev in Thread] Current Thread [Next in Thread>