Send SOAP message

This guide describes how to send a SOAP message to an endpoint and process the result.

We will use the https://www.dataaccess.com/webservicesserver/NumberConversion.wso to demo this use case and convert 500 to text and make that into an issue.

Step 1.

Create a new Action, do not select any template to leave the content type blank.

Step 2

On the headers section add

Key

Value

Key

Value

Content-Type

text/xml

For some system it requires you to add SOAPAction header example below how it may look like for MS SQL server soap action.

Key

 

ref [MS-SSNWS]: SOAP Request with SOAPAction Header

Step 3

Add the envelope XML as body

<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <NumberToDollars xmlns="http://www.dataaccess.com/webservicesserver/"> <dNum>500</dNum> </NumberToDollars> </soap:Body> </soap:Envelope>

The body can be formatted to fit the envelope of the target system. In our case we will send in 500 as params. You may use Mustache Variables to send issue data or any calculated groovy data.

Step 4 - Process the result

The result will come back as XML and need to be parsed to be accessible by iHub, this is done by adding a Groovy Variables.

 

Below is our example Groovy that parse the xml to json and picks the result and returns that.

We will name this {{SOAP}} and access it in our child action.

 

import org.json.JSONObject import org.json.XML JSONObject xmlJSONObj = XML.toJSONObject(response) xmlJSONObj["soap:Envelope"]["soap:Body"]["m:NumberToDollarsResponse"]["m:NumberToDollarsResult"]

 

Step 5 - create an issue named the same as the result

Create a new Action, select the Jira Core template category and the Create Issue template.

Add a name to the action and select the SOAP - Number to Dollar action created in Step 1 as parent. This will pass the response down to the child. Optional you may create a Group to make a more logical sturctue.

Below is the body that we POST to {{baseUrl}}/rest/api/2/issue

Notice the {{SOAP}} variable being referenced in the body

{ "fields": { "project": { "id": "12000" }, "summary": "{{SOAP}}", "issuetype": { "id": "10004" }, "labels": [ "from_soap" ] } }