How to ensure idempotency of requests to SAP?
We need to submit Sales Orders to SAP BYD over the SOAP web services interface. If there is a communication failure we can safely retry, however if there is a socket timeout, we need to know how we can replay the same request again, without SAP BYD creating a duplicate sales order for it.
I have gone through the documentation and there is a "UUID" which we can optionally pass into a request. However this is not adequate to prevent a duplicate order from being created. There is also a "BuyerID" described as an "External Reference ID" - However neither of these provide what we would desire.
Our expected result is that on a resubmission of the same SOAP web service request, SAP BYD should reply/ignore a duplicate message it has successfully received/processed having the same UUID / BuyerID?
I appreciate if someone could point me to the relevant information that could help me achieve what we expect
Knut Heusermann replied
ByD synchonous writing web services support transparent retries (idem potency) in case of lost server responses caused by bad network connections. Using idem potency is optional. If the Web service consumer fills the UUID element of the BasicMessageHeader message element, the server returns the cached response if the same UUID is received within a short time period. This allows the consumer to perform multiple retries in case the original response did not reach the consumer in time. The maximum time span a consumer performs retries should not exceed some minutes. Responses for requests with a filled UUID are cached for 2-4 hours. Reusing the same UUID after this period is not allowed and results in a fault message response.
Beyond idem potency you can avoid creating duplicates by providing the corresponding key elements and using action code "01 - create". Using action code 01 the system returns an error message if a business object with the same key already exists.