wso2 / product-ei

An open source, a high-performance hybrid integration platform that allows developers quick integration with any application, data, or system.
https://wso2.com/integration/
Apache License 2.0
375 stars 280 forks source link

Mediate BAPI commit response #4130

Closed dilee closed 5 years ago

dilee commented 5 years ago

Description: In our current SAP implementation, we cannot mediate the commit response retrieved from a SAP server. The BAPI request is sent to the SAP server and the response is sent back to the client who invoked the service. But if the client set the property transport.sap.transactionCommit to true, an additional commit response will also be sent from the SAP server to ESB.

There should be a way to mediate the commit response so we need to alter the response flow to send both the original and the commit response to the client.

A suggested approach is to append the commit response to the original response in the below format.

<BAPI_TRANSACTION>
   <ZHR_RFC_SAP_TO_CLEARVIEW>   (Start of the BAPI response)            
      Response content.....
   </ZHR_RFC_SAP_TO_CLEARVIEW>  (End of the BAPI response)
   <BAPI_TRANSACTION_COMMIT>    (Start of the commit response)
      Commit response content...
   </BAPI_TRANSACTION_COMMIT>   (End of the commit response)
</BAPI_TRANSACTION>

We define a custom root element to wrap both BAPI and commit responses and the aggregated response will be sent to the client. This way, the client can mediate both responses. This behaviour should be provided as a configurable option so the users can switch to it only when necessary.

Also, the error handling flow should be changed as described below.

  1. In the current implementation, when a BAPI request receives an error response, the error sequence is hit if the sap.escape.error.handling property is set to false. By default, this property is set to false so whenever there is an error response from the SAP server, the response hits the fault sequence.
  2. With this change, we are setting the aforementioned property to true by default so the error response will be sent back to the client as the default behaviour and the error will only be handled only if the sap.escape.error.handling property is set to false explicitly.

Related Issues: https://github.com/wso2/product-ei/issues/3674

dilee commented 5 years ago

Fixed in https://github.com/dulanjalidilmi/carbon-mediation-1/commit/ffdb7edfa123f5c38410529d6fe67a2810bd59ca