IBM Support

Accessing returned message of non-200 HTTP Response

Question & Answer


Question

How do I access the response message from my backend server when it returns a non-200 response message to my Multi-Protocol Gateway or Web Service Proxy service?

Cause

It is not possible to access the response message from an error rule. However, being able to retrieve the content of a message with a non-200 response code may be of value for the user.

Answer

One can access the response message from a backend server, when it returns a non-200 response, by enabling the "Process HTTP Errors" setting. This setting is located in the Advanced Proxy settings tab of a Web Service Proxy. Enabling the "Process Backend Errors" setting located in the Advanced tab of a Multi-Protocol Gateway is another option.

Enabling either of these settings will trigger a response rule instead of an error rule. This will cause the non-200 response message to be returned with response code 200.

If you want to return the full backend HTTP return code, you would need to have a response rule to set the following using a custom stylesheet (XSL):


<dp:set-http-response-header name="'x-dp-response-code'" value="'$rc'"/>


Where $rc could be something like:
<xsl:variable name="rc" select="dp:response-header('x-dp-response-code')"/>

[{"Product":{"code":"SS9H2Y","label":"IBM DataPower Gateway"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"General","Platform":[{"code":"PF009","label":"Firmware"}],"Version":"4.0.2;5.0.0;6.0.0;6.0.1;7.0.0","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
15 June 2018

UID

swg21635555