CLAIMATE

Technical blog

How to build SOAP service in SAP Cloud Integration, Part 2

created by DALL-E

Jiri Fridrich

May 8, 2024

Integration

SOAP request body

We need to call the SOAP service with some input data. In our case it is the invoice id, hence we need to send an http POST request with an XML body, which will contain this invoice id. But what will be the format of that body?

There are several ways how to create a sample XML body for a SOAP service. It will be always based on the WSDL, which we generated to construct the SOAP sender. We did that with the help of ChatGPT, so why not to ask there? The request to ChatGPT can be as simple as:

'Create sample SOAP body, used as the POST call against this WSDL' and paste the WSDL from previous blog post.

We will get a sample code, which we can just copy, as indicated. I am also attaching the code to this blog post.

Call SOAP endpoint from Postman

To call our endpoint from Postman, we will need

  • URL of our SOAP service iflow

  • credentials

  • body - paste the code provided by ChatGPT

We send it as POST request and we should get the hard-coded output values from our iflow.

Call SOAP endpoint from SCI

For this scenario we create a simple iflow starting with Timer, by default set to 'Run Once', which means the event will be triggered once we deploy the iflow.

Another component is a Content modifier, where we just paste our XML body content into the Body section.

Another component is Request Reply, which we connect to Receiver component using SOAP adapter (type SOAP 1.x). Our iflow could look like this now:

Double click on the dashed-line SOAP adapter and configure it as depicted on the screenshot.

  • Address - fill the URL of our SOAP Sender endpoint (see previous blog post)

  • URL to WSDL - select our WSDL (again from previous blog post) saved at your desktop

  • Service, Endpoint, Operation Name gets filled automatically from the WSDL.

  • Authentication - up to you, I chose Basic

  • Credential Name - alias of your basic credentials, saved in Security Material in SCI. These credentials have to be first created as Service Key within the SAP BTP Cockpit. If in doubts how to achieve that, please follow the documentation: https://help.sap.com/docs/cloud-integration/sap-cloud-integration/creating-service-instance-and-serv...

Now save and deploy the iflow. It will end up in error: The PayLoad elements cannot fit with the message parts of the BindingOperation. Please check the BindingOperation and PayLoadMessage.

Overcoming this error can be a little frustrating, as the same request from Postman went through just fine. The thing is, that as we used the SOAP adapter, this adapter treats the message in its own way, so we have to:

  • Remove envelope lines from the message

  • Add namespace. Click anywhere in the iflow canvas, go to Runtime Configuration tab and see the Namespace Mapping

We just modify the namespace mapping a bit and the final result of our request body is this:

<tns:GetInvoiceRequest xmlns:tns="http://example.com/invoiceservice">
<tns:orderId>123456</tns:orderId></tns:GetInvoiceRequest>

Now save and deploy the iflow again. The request should go through and return the same result as did in Postman. You can see the payload in Trace mode or have it logged by a Groovy script component.

It was also published here:

https://community.sap.com/t5/technology-blogs-by-members/how-to-build-soap-service-in-sap-cloud-integration-part-2/ba-p/13691514

Navigation

© 2023 CLAIMATE

Navigation

© 2023 CLAIMATE