Here, I will describe how we can send custom faults to a modeled soap trigger.
Use case:
We will create a soap trigger connection based on a request response and modeled fault wsdl and from the integration, will call an external rest service and the twist is, we will provide invalid rest url and keep all this activities in a scope and from scope APIInvocationError we will customize the fault to the modeled soap to consumer.
Implementation steps:.
Step1: First we should have a request-response with modeled fault wsdl. Then create a soap trigger connection using the wsdl.
Fault schema contains errorCode,error and error details fields.
Step2: create a rest invoke connection using external or internal OIC rest service URL.
Here, I used the following url:.
https://jsonplaceholder.typicode.com/users/1.
Step3: create an app driven integration and configure the soap trigger using the created soap trigger connection.
Step4: create a scope and drag and drop created rest invoke connection and configure it with all details
Endpoint name,
Uri: /1users/{User-id} // purposefully provided wrong uri.
Verb: get
In response section, provide the rest Json response payload
Next map the id and map the response to the soap trigger.
Now the integration flow looks as
Step5: click on the fault handler and choose APIInvocation error. Drag and drop Fault return action and map the $CurrentFaultObject details to soap modeled fault.
Note: you can also define default fault handler.
Step6: save, add tracking id and activate and test with input. You will see your modeled error as below screenshot: