Hi Raghu,
A couple of questions:
1. What version of API Connect?
2. What type of Gateway? (API gateway or v5 compatible gateway)
Specific to the type of gateway, a 401 Unauthorized error comes from the preflow. If you wish to change the output of this fault response in an API Gateway, the UnauthorizedError exception must be caught explicitly in a post-error global policy. This error will never flow to your API assembly. If you're on a v5c gateway, you can explicitly catch this exception in your API catch (again, it must be an explicit catch as the default catch will not catch this error), or I believe v5c will also support a post-error global policy but you'd still need to explicitly catch the exception there.
From your description, it appears you're using the map policy to change the actual body of the response, which is fine, but I suspect based on it not working for you that you're never having that map policy executed. One thing you can do is to enable debug logging on the apiconnect domain of your DataPower appliance, and then the logging should allow you to actually follow the policy execution flow. Another option would be to look at the latency data in your analytics record. In either case, what you'd be doing is seeing if your map policy is ever executed or is being skipped. Some additional detail of where you're attempting to do this would be helpful.
Best Regards,
Steve
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
------------------------------
Original Message:
Sent: Tue March 12, 2024 01:26 AM
From: RAGHU
Subject: SOAP Error Message Conversion in IBM API Connect
Hi All,
We've encountered a challenge while attempting to convert the error message format from the httpCode element to the faultcode element using the map policy in IBM API Connect. Despite meticulously mapping the httpCode input field as per our configuration, the error message persists in being returned within the httpCode element of the output XML. We're seeking your expertise to advise us on resolving this issue effectively. Any insights or suggestions would be greatly appreciated.
Input Error message:
<?xml version="1.0" encoding="UTF-8"?>
<errorResponse>
<httpCode>401</httpCode>
<httpMessage>Unauthorized</httpMessage>
<moreInformation>Cannot pass the security checks that are required by the target API or operation, Enable debug headers for more details.</moreInformation>
</errorResponse>
Expected Error message Format:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>401</faultcode>
<faultstring>Unauthorized</faultstring>
<faultactor/>
------------------------------
RAGHU
------------------------------