
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.
To call our endpoint from Postman, we will need
We send it as POST request and we should get the hard-coded output values from our iflow.
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.
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:
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
7 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 | |
4 |