How to set a default response when a service cannot be found

Document ID : KB000009737
Last Modified Date : 14/02/2018
Show Technical Document Details
Introduction:

When attempting to reach a gateway service that either does not exist or is otherwise unable to be resolved the below error is returned by default.

 

<detail>
<l7:policyResult xmlns:l7="http://www.layer7tech.com/ws/policy/fault" status="Service Not Found. The request may have been sent to an invalid URL, or intended for an unsupported operation."/>
</detail>
 
Instructions:

To customize the message returned to end users a catch all policy can be configured

1. Launch policy manager

2. Publish a Web API

    [9.1] Tasks Menu -> Service and APIs -> Publish Web API

    [9.0 and under] Tasks -> Publish Web API

3. Enter the resolution path as an asterisk (*). This will catch all calls at the root of the Gateway.

catch-all-pub-api.png

4. Click finish

5. You can now write a policy to suite your needs. Common uses are using a 'Return Template Response' assertion with an HTTP error code and status message such as:

catch-all-response.png