Topic
  • 4 replies
  • Latest Post - ‏2013-06-18T19:07:15Z by smashyrahul
Cliff_B
Cliff_B
23 Posts

Pinned topic Setting HTTP Response Code/Message issue

‏2010-09-17T15:01:54Z |
Hello,

I have a MPGW (A) acting as a router service on our XI50 which intercepts all incoming HTTP requests and based on certain rules, it will dynamically route the request to another MPGW (B) on the same XI50 appliance for additional processing. The MPGW (B) then will dynamically route the request to a Message Broker back-end.

The issue that I'm having is preserving the HTTP response code and response message which is returned from the Message Broker back-end. In my case, Message Broker is returning an HTTP 404 Not Found and MPGW (A) is replacing this with an HTTP 200 OK. I believe I understand the reason why since there are two distinct transactions occurring. Once between the consumer/client and MPGW (A) and another between MPGW (A) and MPGW (B).

Since the ERROR rule doesn't fire in the policy of MPGW (B) for the Message Broker HTTP 404 Not Found, and the fact that an HTTP 200 OK was resulting from the calls, I modified the response rule with a transform action to execute the following (I've excluded the conditional logic):


<dp:set-http-response-header name=
"'x-dp-response-code'" value=
"'404 Not Found'"/>


When the response is returned from MPGW (B ) to MPGW (A), I have the same logic as well as debug statements within the response rule of MPGW (A). I can see that the return HTTP response code is a 404 Processed. However, before the response is sent from MPGW B, the value of x-dp-response-code is "HTTP 404 Not Found". I was able to eliminate the HTTP 200 OK, but I'm puzzled at how to ensure the proper message is associated with the proper 404 code.

I've also reviewed the prior postings:

https://www.ibm.com/developerworks/forums/thread.jspa?threadID=321263
https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14432385&#14432385

This thread resembles the issue that I'm seeing the most:
http://www.ibm.com/developerworks/forums/thread.jspa?messageID=14494356

However, the x-dp-response-phrase doesn't contain a value. I placed debug statements in the XSLT script and viewed the probe and x-dp-response-phrase doesn't even exist as a code/variable ...etc. I've also tried setting the system variable below (which I believe was suggested for the ERROR rule) and it too had no positive effect:

<xsl:variable name=
"backendRespCode" select=
"dp:http-response-header('x-dp-response-code')"/> <dp:set-variable name=
"'var://service/error-protocol-reason-phrase'" value=
"$backendRespCode" />


Perhaps I'm doing something incorrect and any suggestions would be greatly appreciated!
Updated on 2010-09-23T22:44:44Z at 2010-09-23T22:44:44Z by HermannSW
  • msiebler
    msiebler
    140 Posts

    Re: Setting HTTP Response Code/Message issue

    ‏2010-09-22T17:06:45Z  
    This is a weird quirk of the MPGW; I believe this will work if you use the 'append-response-header' instead; I think also maybe if you try replacing MPGW A w/ an XML FW
  • Cliff_B
    Cliff_B
    23 Posts

    Re: Setting HTTP Response Code/Message issue

    ‏2010-09-22T17:10:56Z  
    • msiebler
    • ‏2010-09-22T17:06:45Z
    This is a weird quirk of the MPGW; I believe this will work if you use the 'append-response-header' instead; I think also maybe if you try replacing MPGW A w/ an XML FW
    Actually, I did try that option 'append-response-header' and it too did not work in the MPGW. It actually sent the HTTP 200 OK response back to the client.
  • HermannSW
    HermannSW
    4874 Posts

    Re: Setting HTTP Response Code/Message issue

    ‏2010-09-23T22:44:44Z  
    > ... I placed debug statements in the XSLT script and viewed the probe and
    > x-dp-response-phrase doesn't even exist as a code/variable ..

    That is normal and documented behavior.
    From Extension Functions Catalog:
    ...
    The x-dp-response-code special code is a protocol response code that is returned
    to the DataPower server. This special code is not a field that is included in the
    response header. This special code contains the protocol-specific response code.
    ...

    So where should it be displayed in Probe?
    • cannot in Header tab by the above statement.
    • cannot be under a variable tab since no variable has been defined

    Hermann.
  • smashyrahul
    smashyrahul
    396 Posts

    Re: Setting HTTP Response Code/Message issue

    ‏2013-06-18T19:07:15Z  

    Hello,

    How did you resolve this issue? I am facing the same issue.

    Thanks,

    Rahul