Exception Sub process with SOAP Sender Adapter

Exception Sub process with Soap sender adapter
SAP

Exception Sub process with SOAP Sender Adapter

INTRODUCTION :

This article covers SOAP Sender Adapter in SAP CPI, Testing Integration Flow using Postman Client, and Using Exception Subprocess to handle Exceptions in SAP CPI . 

The Demo shows what happens when an Exception occurs in an Integration Flow and how it can be handled using Exception Subprocess and optionally  how the error message can be sent to intended recipients using Mail Receiver adapter. 

CREATING ARTIFACT TO THROW EXCEPTION :

Step 1 : Create an Artifact. Go to Edit mode. 

Step 2 : Connect Sender to Start Event. From the Pop Up appearing, Choose SOAP –> SOAP 1.x 

Step 3 : Go to Connection tab of SOAP Adapter and enter any relative address. ( /Exceptions ). This is to generate end point for accessing the Integration Flow. Keep rest of the fields untouched. 

Step 4 : Add a Content Modifier. In Message Body tab, type as given Below. 

<Result1> 

${in.property.Test}        ---> This line should throw error as there is no such invocation available 

Integration Process 

</Result1> 

Step 5 : Save and Deploy.

Step 6 : Go to Overview Window and Click on All tile to check if your flow is started successfully. 

Step 7 : Once it is started, Go to Endpoints and click on Copy button as highlighted in the below image. 

Step 8 :  Open Postman app.  

Keep the request in POST mode. 

Paste the Endpoint copied in Step 7 in to URL tab

In Authorization tab, Choose TYPE : Basic Auth 

Username : Client ID 

Password : Client Secret 

Client Id and Client Secret you will get when you create Process Integration Runtime Instance during tenant setup. ( Refer Step 34 of this post )

Step 9 : In Body tab, Choose Raw radio Button and from types, Choose XML

Paste the below sample XML code. 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:demo="http://cpi.sap.com/demo"> 
   <soapenv:Header/> 
   <soapenv:Body> 
      <demo:Order_MT> 
         <orderNumber>1</orderNumber> 
      </demo:Order_MT> 
   </soapenv:Body> 
</soapenv:Envelope>

Step 10 : Click on SEND. You will receive back the following Fault message. 

Step 11 :  Check the Message status in Monitoring Window. The Flow will be in Failed status with below shown error description. 

EDITING ARTIFACT TO HANDLE EXCEPTION :

Step 12 : Go back to the Integration Flow. Add an Exception Subprocess from the Pallet and place it inside Integration Process. 

Step 13 : It will Look as below. 

Step 14 :  Add a Content Modifier inside Exception Subprocess. In Message Body tab, Type as below. 

<Result2> 
${exception.message}     ---> This line will catch Error Message thrown by integration Process. 
Exception Subprocess in Action 
</Result2>

Step 15: Save and Deploy

Step 16 :  Make sure that your Flow is in Started state again. 

Step 17 : Go back to Postman. The settings used earlier will still be available. Just Click on Send

Step 18 : You will get back the Response in Postman as below.  

From the Response Received, it is clear that the Exception Subprocess gives the Error as SOAP body. Where in it was included with fault message earlier. 

Step 19 : The Integration Flow will now be in Completed state. This is because, we have caught and processed the exception successfully in Exception Subprocess. 

Step 20 : You can even get the response in Step 18 directly to your Gmail Inbox by adding Mail Receiver Adapter as below. Refer my Previous blog on how to configure Mail Receiver Adapter in SAP CPI to get the detailed Configuration steps. 

FINAL VERDICT :

In conclusion, I hope you enjoyed reading this article on “Exception Sub process with SOAP Sender Adapter ”, If yes, then don’t forget to spread a word about it. Do send the feedback and to know more about it. Signing off sudarshan@recodehive.com 

Tagged , ,
Back To Top