Topic
  • 3 replies
  • Latest Post - ‏2013-08-01T09:32:54Z by HermannSW
smashyrahul
smashyrahul
394 Posts

Pinned topic Content-type header is getting converted from 'application/xml' to 'text/xml'

‏2013-07-26T14:53:50Z |

Hello Experts,

I am facing this weird issue in DataPower.

When DataPower is transforming the input sml using the below stylesheet, the 'Content-Type' header is getting converted from 'application/xml' to 'text/xml'.

Is there any issue with the xslt? Please help me resolve this.

 

 

<xsl:stylesheet version="1.0" extension-element-prefixes="dp" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:date="http://exslt.org/dates-and-times">

    <xsl:output method="xml" indent="yes"/>
    
    <xsl:template match="*">
        <!-- identity with closing tags -->
        <xsl:element name="{name()}">
            <xsl:apply-templates select="@*|node()"/>
        </xsl:element>
    </xsl:template>
    
    
    
<xsl:variable name="GenericQuoteInd">
            <xsl:value-of select="/*[namespace-uri()='http://www.origoservices.com' and local-name()='message']/*[namespace-uri()='http://www.origoservices.com' and local-name()='m_content']/*[namespace-uri()='http://www.origoservices.com' and local-name()='b_control']/*[namespace-uri()='http://www.origoservices.com' and local-name()='generic_quote_ind']"/>
        </xsl:variable>
        <xsl:variable name="InitiatorId">
            <xsl:value-of select="/*[namespace-uri()='http://www.origoservices.com' and local-name()='message']/*[namespace-uri()='http://www.origoservices.com' and local-name()='m_control']/*[namespace-uri()='http://www.origoservices.com' and local-name()='initiator_id']"/>
        </xsl:variable>
        <xsl:variable name="ServiceType">
            <xsl:value-of select="/*[namespace-uri()='http://www.origoservices.com' and local-name()='message']/*[namespace-uri()='http://www.origoservices.com' and local-name()='m_content']/*[namespace-uri()='http://www.origoservices.com' and local-name()='application']/*[namespace-uri()='http://www.origoservices.com' and local-name()='product']/*[namespace-uri()='http://www.origoservices.com' and local-name()='tpsdata']/*[namespace-uri()='http://www.origoservices.com' and local-name()='service_type']"/>
        </xsl:variable>
        <xsl:variable name="quoteNPrint">
            <xsl:value-of select="/*[namespace-uri()='http://www.origoservices.com' and local-name()='message']/*[namespace-uri()='http://www.origoservices.com' and local-name()='m_content']/*[namespace-uri()='http://www.origoservices.com' and local-name()='b_control']/*[namespace-uri()='http://www.origoservices.com' and local-name()='quote_or_print']"/>
        </xsl:variable>
        
        
        
        <xsl:template match="/*[namespace-uri()='http://www.origoservices.com' and local-name()='message']/*[namespace-uri()='http://www.origoservices.com' and local-name()='m_content']/*[namespace-uri()='http://www.origoservices.com' and local-name()='b_control']/*[namespace-uri()='http://www.origoservices.com' and local-name()='quote_or_print']">

             <xsl:choose>
                
                    <xsl:when test="(($GenericQuoteInd = 'Yes') or (($InitiatorId = 'ASL') and ($ServiceType='QuickQuote'))) and ($quoteNPrint='Quote And Print')">
                      
                                 <dp:reject>Generic Quote Error Messag</dp:reject>
                                
                      </xsl:when>
                       
                       <!--xsl:when test="(($GenericQuoteInd = '') and (($InitiatorId = 'ASL') and ($ServiceType='QuickQuote'))) and ($quoteNPrint='Quote Only')"-->
                       <xsl:when test="(($InitiatorId = 'ASL') and ($ServiceType='QuickQuote')) and ($quoteNPrint='Quote Only')">
                                <xsl:copy>
                                        <xsl:apply-templates select="@*|node()"/>
                                 </xsl:copy>
                       <xsl:element name="generic_quote_ind" namespace="{namespace-uri()}">Yes</xsl:element>
                                        
                                
                                
                       </xsl:when>
                       
                       <xsl:when test="($GenericQuoteInd = 'Yes') and ($quoteNPrint='Quote Only')">
                      
                                <xsl:copy>
                                        <xsl:apply-templates select="@*|node()"/>
                                </xsl:copy>
                          </xsl:when>
                       
                        
                                   
                                  
                                
                                <xsl:otherwise>
                                
                                <xsl:copy>
                                        <xsl:apply-templates select="@*|node()"/>
                                  </xsl:copy>
                                
                                </xsl:otherwise>
                                
                                 
                       
                    
                       </xsl:choose>      
                     
                      
             
        </xsl:template>
        
        <xsl:template match="*|comment()|processing-instruction()">
    <xsl:copy>
      <xsl:copy-of select="@*|namespace::*"/>
      <xsl:apply-templates />
    </xsl:copy>
  </xsl:template>
        
        
        
       </xsl:stylesheet>

Updated on 2013-07-26T14:54:09Z at 2013-07-26T14:54:09Z by smashyrahul
  • HermannSW
    HermannSW
    4744 Posts

    Re: Content-type header is getting converted from 'application/xml' to 'text/xml'

    ‏2013-07-26T21:41:30Z  

    XSLT is a Transformation language.

    Input and Output do not necessarily are the same.

    With <xsl:output method="xml"> you will get "text/xml".

    You can access the original content type by

    dp:variable('var://service/original-content-type')

    and set Content-Type to whatever you want by

    <dp:set-http-request-header name="'Content-Type'" value="..."/>

     

    Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>

  • smashyrahul
    smashyrahul
    394 Posts

    Re: Content-type header is getting converted from 'application/xml' to 'text/xml'

    ‏2013-08-01T09:24:06Z  
    • HermannSW
    • ‏2013-07-26T21:41:30Z

    XSLT is a Transformation language.

    Input and Output do not necessarily are the same.

    With <xsl:output method="xml"> you will get "text/xml".

    You can access the original content type by

    dp:variable('var://service/original-content-type')

    and set Content-Type to whatever you want by

    <dp:set-http-request-header name="'Content-Type'" value="..."/>

     

    Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>

    Thanks Hernann,

    My issue got resolved.

    But, what is the significance of the results action in the request rule, and is it advisable to get rid of the 'results' action?

    Regards,

    Rahul

     

  • HermannSW
    HermannSW
    4744 Posts

    Re: Content-type header is getting converted from 'application/xml' to 'text/xml'

    ‏2013-08-01T09:32:54Z  

    Thanks Hernann,

    My issue got resolved.

    But, what is the significance of the results action in the request rule, and is it advisable to get rid of the 'results' action?

    Regards,

    Rahul

     

    You can have many contexts in a processing rule, and send them with many Result actions to different locations.

    A Result action with output context OUTPUT specifies what should be send to backend (or back to client in case of loopback service).

    You can eg. set a Transform action's output context to OUTPUT. In that case you do not need a Result action at all.


    Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>