Topic
  • 3 replies
  • Latest Post - ‏2013-06-25T14:50:05Z by souciance
souciance
souciance
203 Posts

Pinned topic HTTP codes and put in message

‏2013-06-25T10:37:59Z |

Hello..

I have a requirement to receive a HTTP response message from the backend. They can reply with standard http codes such as 200 or 500 if there are problems. There is off course the http version and other information that is sent from the server. My question is, how can I access them (config or xslt) and put that information in the response message?

Thanks.

Souciance

  • HermannSW
    HermannSW
    4874 Posts
    ACCEPTED ANSWER

    Re: HTTP codes and put in message

    ‏2013-06-25T12:55:06Z  

    You can get response code in response rule stylesheet by "dp:http-response-header('x-dp-response-code')".

    The first two lines are returned by the following stylesheet:

    <rc>200 Good</rc>

    <rc>500 Internal Server Error</rc>

    $ cat resp.xsl
    <xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:dp="http://www.datapower.com/extensions"
      extension-element-prefixes="dp"
    >
      <xsl:output omit-xml-declaration="yes"/>
        
      <xsl:template match="/">
        <rc>
          <xsl:value-of select="dp:http-response-header('x-dp-response-code')"/>
        </rc>
      </xsl:template>
     
    </xsl:stylesheet>
    $

     

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

  • HermannSW
    HermannSW
    4874 Posts

    Re: HTTP codes and put in message

    ‏2013-06-25T12:55:06Z  

    You can get response code in response rule stylesheet by "dp:http-response-header('x-dp-response-code')".

    The first two lines are returned by the following stylesheet:

    <rc>200 Good</rc>

    <rc>500 Internal Server Error</rc>

    $ cat resp.xsl
    <xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:dp="http://www.datapower.com/extensions"
      extension-element-prefixes="dp"
    >
      <xsl:output omit-xml-declaration="yes"/>
        
      <xsl:template match="/">
        <rc>
          <xsl:value-of select="dp:http-response-header('x-dp-response-code')"/>
        </rc>
      </xsl:template>
     
    </xsl:stylesheet>
    $

     

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

  • souciance
    souciance
    203 Posts

    Re: HTTP codes and put in message

    ‏2013-06-25T13:11:13Z  

    Thanks Hermann, I will test this and get back to you.

  • souciance
    souciance
    203 Posts

    Re: HTTP codes and put in message

    ‏2013-06-25T14:50:05Z  
    • HermannSW
    • ‏2013-06-25T12:55:06Z

    You can get response code in response rule stylesheet by "dp:http-response-header('x-dp-response-code')".

    The first two lines are returned by the following stylesheet:

    <rc>200 Good</rc>

    <rc>500 Internal Server Error</rc>

    $ cat resp.xsl
    <xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:dp="http://www.datapower.com/extensions"
      extension-element-prefixes="dp"
    >
      <xsl:output omit-xml-declaration="yes"/>
        
      <xsl:template match="/">
        <rc>
          <xsl:value-of select="dp:http-response-header('x-dp-response-code')"/>
        </rc>
      </xsl:template>
     
    </xsl:stylesheet>
    $

     

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

    Thanks Hermann, it worked great!