Receive SOAP message
This guide describes how to receive a SOAP message in iHub and process that message as a issue.
Step 1.
Click on Incoming Webhooks on the left side menu.
Click New Rule
The rule will map what action to to runName the rule anything related to the incoming system, in our example SOAP incoming message
For now leave the Rule HTTP response as “No Response”
We will add a THEN action to this rule at step 3.
Click Save
Step 2
Click on Integrations
Since we are going to create an issue in our Jira instance we will use an integration that performs this action.Click New button
Add a Name, e.g. SOAP to Issue
Select Action
Select a parent if you want to place this in a Group (e.g a folder), our folder is called SOAP.
Note the Group needs to be created before the action is created.Select Template; Jira Core Server
Select Request Template; Create Issue
This is to get a template for an issue creationClick Create
Now select an Authentication, for sending to Jira select a Basic auth. Our is called KG and was created before this tutorial. See Basic Authentication
In the body we paste in this code.
Use tripple mustache to remove any HTML character on line 7, 8 and 10 when using the variables.
Variables will be defined in Step 4.{ "fields": { "project": { "id": "12000" }, "summary": "{{{soap.example:Summary}}}", "description": "{{{soap.example:Description}}}", "priority": { "name": "{{{soap.example:Priority}}}" }, "issuetype": { "id": "10004" } } }
Click Save
Step 3. Modify the Incoming Webhook rule
Click the Webhook Rules again
Click three dots, then Edit on the Rule created in Step 1.
Select the SOAP to Issue action in the THEN box
Click Save.
Note that IF condition can be added to make sure the right action is triggered. In this tutorial we only have one, but as your integration grows you can add more rules and filter by URL, DATA or User.
This concludes the incoming webhook part of receiving a SOAP message an passing it into an action that will create the issue.
Next up is the steps on how to parse the SOAP message to become variables used in the Action body as mustache variables. eg. {{summary}}, {{description}} and {{priority}}
Step 4. Parse the SOAP message
Click on Variables on the left menu
Click Groovy tab
Click Add Variable
Enter the name, in our example call it soap.
The variable will be accessed using {{soap.summary}}.Select “Enabled for these action(s)” in the drop down, we will select the SOAP to issue action created in step 2.
In the Script paste the following code
import org.json.JSONObject import org.json.XML import com.fasterxml.jackson.databind.ObjectMapper int textIndent = 2 JSONObject xmlJSONObj = XML.toJSONObject(response) def jsonObject = xmlJSONObj["soap:Envelope"]["soap:Body"]["example:CreateIssue"] ObjectMapper objectMapper = new ObjectMapper() def parsedObject = objectMapper.readValue(jsonObject.toString(), Map.class)
This will parse any incoming xml as JSON and return it as a variable to use in the mustache of the Action. Note that we have pointed out the <example:CreateIssue> node in line 7, that might look different in other soap messages.
example this SOAP message<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:example="http://www.example.com/soap-api"> <soap:Header/> <soap:Body> <example:CreateIssue> <example:Summary>Fix critical bug</example:Summary> <example:Description>This is a critical bug that needs immediate attention.</example:Description> <example:Priority>High</example:Priority> </example:CreateIssue> </soap:Body> </soap:Envelope>
Will look like this, after the conversion.
These are the steps to setup the integration, it should now be fully functional for getting any SOAP message.
Note that the groovy script will try to parse the result into a JSON object, if the information in that you need is a string then remove the mapper part and it will look like this;
Step 5. Testing
Testing can be done from any tool or SOAP system. We use iHub to test this integration.
Create an Integration
Name it SOAP test incoming
Select a Basic authentication
Add this to the Body
Press Test button
Result should be a new Issue created with the summary “Fix critical bug”, description “This is a critical bug that needs immediate attention.” and Priority “High”