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.
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
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
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