Topic
  • 9 replies
  • Latest Post - ‏2014-09-25T18:22:23Z by YV4N_Ramesh_Janjyam
sapiterbang
sapiterbang
4 Posts

Pinned topic [ASK] Change HTTP Status Code

‏2010-02-04T10:46:34Z |
I have developed XML firewall to do message transformation from SOAP to SOAP (different format). When the firewall get the response from backend server which is SOAP fault, the firewall transform the SOAP fault message to another a normal SOAP message.
Then transmit the normal SOAP message to the client.

But I confuse that the message transmitted to the client has HTTP 500 response code. I tried with many ways to change the 500 HTTP response code to 200 (OK), but no luck. Maybe anybody here can help me how to do it ? thanks before
Updated on 2012-05-11T00:46:53Z at 2012-05-11T00:46:53Z by atl30309
  • swlinn
    swlinn
    1348 Posts

    Re: [ASK] Change HTTP Status Code

    ‏2010-02-04T15:03:59Z  
    If you're doing this in an error rule, there is one approach, but if you were changing the code in the response rule you would use another.

    Within an Error Rule:
    <dp:set-variable name="'var://service/error-protocol-response'" value="'200'" />
    <dp:set-variable name="'var://service/error-protocol-reason-phrase'" value="'OK'" />

    Within a Response Rule:
    <dp:set-http-response-header name="'x-dp-response-code'" value="'200 OK'"/>

    Regards,
    Steve
  • sapiterbang
    sapiterbang
    4 Posts

    Re: [ASK] Change HTTP Status Code

    ‏2010-02-05T02:16:41Z  
    • swlinn
    • ‏2010-02-04T15:03:59Z
    If you're doing this in an error rule, there is one approach, but if you were changing the code in the response rule you would use another.

    Within an Error Rule:
    <dp:set-variable name="'var://service/error-protocol-response'" value="'200'" />
    <dp:set-variable name="'var://service/error-protocol-reason-phrase'" value="'OK'" />

    Within a Response Rule:
    <dp:set-http-response-header name="'x-dp-response-code'" value="'200 OK'"/>

    Regards,
    Steve
    Hi Steve, you save me from headaches
    your solution works 100%

    I used it on response rule
    <dp:set-http-response-header name="'x-dp-response-code'" value="'200 OK'"/>

    many thanks to you :)
  • Kheuch
    Kheuch
    1 Post

    Re: [ASK] Change HTTP Status Code

    ‏2010-07-30T02:02:25Z  
    Hi Steve, you save me from headaches
    your solution works 100%

    I used it on response rule
    <dp:set-http-response-header name="'x-dp-response-code'" value="'200 OK'"/>

    many thanks to you :)
    Hello,

    I have been trying to change the HTTP/1.1 200 OK ==> to HTTP/1.1 409 Conflict without any luck.
    Can someone help me on this?

    Thank you
  • swlinn
    swlinn
    1348 Posts

    Re: [ASK] Change HTTP Status Code

    ‏2010-08-05T13:29:42Z  
    • Kheuch
    • ‏2010-07-30T02:02:25Z
    Hello,

    I have been trying to change the HTTP/1.1 200 OK ==> to HTTP/1.1 409 Conflict without any luck.
    Can someone help me on this?

    Thank you
    Note the above post ... have you tried:

    Within an Error Rule:
    <dp:set-variable name="'var://service/error-protocol-response'" value="'409'" />
    <dp:set-variable name="'var://service/error-protocol-reason-phrase'" value="'Conflict'" />

    Within a Response Rule:
    <dp:set-http-response-header name="'x-dp-response-code'" value="'409 Conflict'"/>

    Errors I've seen where you might have issues would be not using the single quotes to designate a literal within the double quotes that distinguish the attribute value, and not having the xml namespace for dp (which would give a compile error) or the extension-element-prefixes="dp" in the xsl:stylesheet tag.

    Regards,
    Steve
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: [ASK] Change HTTP Status Code

    ‏2010-10-17T00:19:20Z  
    swlinn wrote:
    If you're doing this in an error rule, there is one approach, but if you were changing the code in the response rule you would use another.

    Within an Error Rule:
    <?xml:namespace prefix = dp /><dp:set-variable value="'200'" name="'var://service/error-protocol-response'">
    <dp:set-variable value="'OK'" name="'var://service/error-protocol-reason-phrase'">

    Within a Response Rule:
    <dp:set-http-response-header value="'200 OK'" name="'x-dp-response-code'">

    Regards,
    Steve</dp:set-http-response-header></dp:set-variable></dp:set-variable>

    Thanks for your analysis! Nice writing.
  • atl30309
    atl30309
    25 Posts

    Re: [ASK] Change HTTP Status Code

    ‏2012-05-07T18:12:40Z  
    • swlinn
    • ‏2010-08-05T13:29:42Z
    Note the above post ... have you tried:

    Within an Error Rule:
    <dp:set-variable name="'var://service/error-protocol-response'" value="'409'" />
    <dp:set-variable name="'var://service/error-protocol-reason-phrase'" value="'Conflict'" />

    Within a Response Rule:
    <dp:set-http-response-header name="'x-dp-response-code'" value="'409 Conflict'"/>

    Errors I've seen where you might have issues would be not using the single quotes to designate a literal within the double quotes that distinguish the attribute value, and not having the xml namespace for dp (which would give a compile error) or the extension-element-prefixes="dp" in the xsl:stylesheet tag.

    Regards,
    Steve
    Hi Steve,

    what if i am in request rule and have skip-backside = 1?
    i have tried <dp:set-http-response-header name="'x-dp-response-code'" value="'500 Fail'"/> in request rule, but no avail...Thanks
  • swlinn
    swlinn
    1348 Posts

    Re: [ASK] Change HTTP Status Code

    ‏2012-05-10T02:26:13Z  
    • atl30309
    • ‏2012-05-07T18:12:40Z
    Hi Steve,

    what if i am in request rule and have skip-backside = 1?
    i have tried <dp:set-http-response-header name="'x-dp-response-code'" value="'500 Fail'"/> in request rule, but no avail...Thanks
    Hum, well that's a use case I have not tried. I know you need to do the following if in an ERROR rule instead of setting x-dp-response-code ...

    <dp:set-variable name="'var://service/error-protocol-response'" value="'500'" />
    <dp:set-variable name="'var://service/error-protocol-reason-phrase'" value="'Failed'" />
    


    and that skip backside, with at least what I see in the response headers at the client, seems to act like a failure with a HTTP 200 :-), so perhaps that will work????

    Regards,
    Steve
    Updated on 2014-03-25T02:56:52Z at 2014-03-25T02:56:52Z by iron-man
  • atl30309
    atl30309
    25 Posts

    Re: [ASK] Change HTTP Status Code

    ‏2012-05-11T00:46:53Z  
    • swlinn
    • ‏2012-05-10T02:26:13Z
    Hum, well that's a use case I have not tried. I know you need to do the following if in an ERROR rule instead of setting x-dp-response-code ...

    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr"><dp:set-variable name="'var://service/error-protocol-response'" value="'500'" /> <dp:set-variable name="'var://service/error-protocol-reason-phrase'" value="'Failed'" /> </pre>

    and that skip backside, with at least what I see in the response headers at the client, seems to act like a failure with a HTTP 200 :-), so perhaps that will work????

    Regards,
    Steve
    Just to confirm that
    <dp:set-response-header name="'x-dp-response-code'" value="'500 FAIL'"/>
    
    works in request rule with skip-backside as well. The problem was on the caller service response rule that changed the http status code 500 back to 200...pb solved :)
    Updated on 2014-03-25T02:56:39Z at 2014-03-25T02:56:39Z by iron-man
  • YV4N_Ramesh_Janjyam
    YV4N_Ramesh_Janjyam
    5 Posts

    Re: [ASK] Change HTTP Status Code

    ‏2014-09-25T18:22:23Z  
    • swlinn
    • ‏2010-02-04T15:03:59Z
    If you're doing this in an error rule, there is one approach, but if you were changing the code in the response rule you would use another.

    Within an Error Rule:
    <dp:set-variable name="'var://service/error-protocol-response'" value="'200'" />
    <dp:set-variable name="'var://service/error-protocol-reason-phrase'" value="'OK'" />

    Within a Response Rule:
    <dp:set-http-response-header name="'x-dp-response-code'" value="'200 OK'"/>

    Regards,
    Steve

    Thank you it worked for me too. but why is it different in error flow & response flow?