Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
jirifridrich
Participant
3,721

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.

jirifridrich_0-1714852007252.png

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.

jirifridrich_1-1714852007255.png

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.

jirifridrich_2-1714852007257.png

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:

jirifridrich_3-1714852007258.png

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...

jirifridrich_4-1714852007259.png

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

jirifridrich_5-1714852007259.png

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.

jirifridrich_6-1714852007260.png

 

 

 

 

 

1 Comment
Labels in this area