Capturing SOAP fault message in ECC client proxy
I am doing proxy to soap synchronous scenario. we got wsdl from web service. wsdl has request,response and fault message type. Fault message type is a custom one.
we are not using standard Fault Messages (SAP Library - Web Services).
Whenever application error happens web service is sending the fault message to ECC. I am able to see the fault message payload in PI and ECC
<?xml version="1.0" encoding="UTF-8"?>
<errorText>record does not exist</errorText>
For application error, we want to display errorText to user as a pop up message.But none of the exception methods is getting this errorText from Fault payload.
this Error Handling (SAP Library - Web Services) help link says that application errors can be handled for sync interface.
Can anyone help how to get the errorText value using proxy exception class? any code snippet?
i also tried using standard sap fault message in the sender side and did the mapping(web service fault message-->sap fault message). Still not able to get the value.
Eng Swee Yeoh replied
Just to confirm - the fault response is making it's way back to the ECC but you are unable to access the fields in the fault message, is that right?
In the calling program, you will need a TRY-CATCH statement when it executes the proxy. Here's a sample, not everything is syntactically correct, just focus on the CATCH part.
lo_exception TYPE <YOUR_PROXY_GENERATED_EXCEPTION_CLASS>.
object->EXECUTE_SYNCHRONOUS( EXPORTING output = request
IMPORTING input = response ).
CATCH <YOUR_PROXY_GENERATED_EXCEPTION_CLASS> INTO lo_exception.
* You can access the fields from LO_EXCEPTION, i.e lo_exception->exception-error_code
* Raise error message
MESSAGE lo_exception->exception-error_text TYPE 'E'.
Can't give you the exact coding required as I do not know how the generated proxy class for the exception looks like.
If you see the screenshots below based on the standard fault message type, you can see the structure is available for access via the instance attributes of the exception.
Hopefully I understood your issue correctly and this helps.