Service Call Out - Internal Policy Failed - Http Status Code Change issue to 500

Hi All,

Using Service Call Out to call Proxy B from Proxy A.

Run Time Scene:

Service Call Out

Proxy A -------------------------> Proxy B

Proxy B: Policy failed with HTTP status code 4xx.

Proxy B ---------------------> Proxy A => HTTP status code got changed to 500.

Changed Details:

500 Internal Server Error

{"fault":{"faultstring":"Execution of ServiceCallout <Policy Name> failed. Reason: ResponseCode 4xx is treated as error","detail":{"errorcode":"steps.servicecallout.ExecutionFailed"}}}

Here, how to keep the error details as it is when the internal policy fails in service call out.

Regards,

Tarang Banka

0 3 838
3 REPLIES 3

As per the service callout documentation, 4xx/5xx from the backend is considered a runtime error and will generate a 500 and stop proxy execution.

If you set your ServiceCallout continueOnError attribute to true, this will stop it from automatically generating a 500 error and allow other policies to execute. You could then use other policies to do your own processing of the response. The status that came back from the service callout can also be found in the response variable's status.code eg calloutResponse.status.code.

There's an example of an approach to fault handling in this thread

amitkumar2091
Participant III

Yeah , by default service callout policy throw an exception , if service callout response contains an failure status code.

You can change that behaviour by setting success.codes property of LocalTargetConnection / HTTPTargetConnection / TargetServers.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="ServiceCallout">
    <DisplayName>ServiceCallout</DisplayName>
    <Properties/>
    <Request clearPayload="false" variable="ServiceCalloutRequest">
        <Set>
            <Headers>
                <Header name="token">Bearer xxxx</Header>
            </Headers>
            <Verb>GET</Verb>
        </Set>
    </Request>
    <Response>ServiceCalloutResponse</Response>
    <Timeout>30000</Timeout>
    <LocalTargetConnection>
        <Path>/path</Path>
        <Properties>
            <Property name="success.codes">1xx,2xx,3xx,4xx,5xx</Property>
        </Properties>
    </LocalTargetConnection>
</ServiceCallout>

Now your service callout policy will not throw exception and you can access original response status code and original response payload using variables ServiceCalloutResponse.status.code and ServiceCalloutResponse.content

Hope this will help !!

Checkmaterz10
Participant III

On the people that will go on this thread and didn't find the right solution in Service Callout, just try to make all variables from service callout, different to each callout. Hope that solves the issue 🙂