Integrating ServiceNow with WSO2 Enterprise Integrator

Krishni Andradi
WSO2 Solution Architecture Team Blog
7 min readAug 1, 2019
Integrating ServiceNow with WSO2 Enterprise Integrator

ServiceNow

Service now is an Incredibly popular SAAS solution which can manage services. It specializes in IT services management, IT business management and IT operations management. Nowadays ServiceNow is widely used within many organizations to manage their day to day IT tasks.

WSO2 Enterprise Integrator

WSO2 Enterprise Integrator is a comprehensive integration solution which enables communication between various disparate applications. Instead of having your applications communicate with each other in all their different formats, they simply have to communicate with WSO2 EI.

WSO2 Enterprise Integrator consists of five main profiles.

  • ESB profile to handle short-running stateless integration flows
  • BPS profile to handle long-running stateful business processes
  • MB profile to ensure reliable messaging
  • Analytics profile to monitor statistics
  • MSF4j profile to run microservices within your integration flows

WSO2 EI has many integration capabilities including REST, SOAP service calls as well as Enterprise connectors.

WSO2 Connector Store

Connector store provides 200+ enterprise connectors for connecting to popular business-critical services

WSO2 Integration Studio

WSO2 Integration Studio is a drag-and-drop graphical development environment for WSO2 Enterprise Integrator.

In this article, I am going to demonstrate on implementing communication from ServiceNow to WSO2 Enterprise Integrator.

Here for ServiceNow I have created a free trial account and created a developer instance to implement this.

WSO2 Enterprise Integrator is an open-source product so you can download and use it free.

Usecase

Invoke a BPS process to assign a human task whenever ServiceNow user account is created.

Invoking BPS process from ServiceNow

Creating the business process

First, create a BPMN(Business Process Model Notation) project using WSO2 Integration Studio. Then add a BPMN diagram to it.

The file structure of the project

Double click on BPMN diagram and open it. Now you will see the worksheet area along with the palette with available drag and drop components.

Palette with Worksheet area

To create my business process I am going to use a few components from the palette.

Start event — To indicate the start of the business process.

User task — Using this we can assign a task to a particular user.

End event — To indicate the end of the business process

Business Process with Properties

When you click on this event item, you will be able to see properties associated with it. (If you cannot see this properties tab open it by going to Window>Show view>Others>Properties and clicking Open button)

So in the start event, we have to specify the input parameters which we need to take inside under form. By adding form properties. Click on New and add properties one by one.

Properties tab
Adding new property

Likewise, add following properties.

Form properties to add

For the user task, we can specify the assignee under main configs. Here we have to give the username of the user which this task is assigned.

Assignee

Now you have created the business process. Now right-click on your project in the package explorer. (If you cannot see this package explorer tab open it by going to Window>Show view>Others>Package Explorer and clicking Open button) And click on “Create deployment artifacts”. It will generate a .bar file under deployments folder in your module.

Create deployment artifact
File structure with deployment artifact

Now start your business process server in Enterprise integrator using console. Then go to your management console using a browser.

https://<host_name>:<port_number>/carbon/admin/index.jsp

BPS management console

Now go to Main> Manage > Processes > Add > BPMN and upload the deployment artifact created in the previous step.

Now if you go to Main > Manage > Processes > List > BPMN, you will see your process is listed there.

BPMN list

As you can see there is a Process ID for every business process you deployed. We will need this process ID later when invoking our business process.

Now I am going to invoke this business process using postman. Whenever we deploy a business process into BPS, we can use BPMN Rest API to invoke that business process.

Invoking business process using postman

Invoking BPMN REST API using Postman

Here we have to specify process id as process definition id and the form inputs of the BPMN start node as variables. Here the name of the variable should be equal to the id of the form property. HTTP method remains unchanged, Endpoint URL, hostname and port need to be changed accordingly.

Create a business rule in ServiceNow to invoke the business process

First, go to your ServiceNow instance and create a REST message by providing endpoint URL, a name for the REST message, authentication details (You may need to create a new Auth profile to give auth credentials.

And then add REST resources (under HTTP method) to that REST message. you can specify Endpoint URL, HTTP method, Authentication details ( can give new auth profile or can ask to use same auth profile as REST message ) and Request body. Please specify these values as you already did for the postman.

Creating a REST message ServiceNow

Now you can test this rest message by clicking on the Test in the related links section. But here we specified the request payload as it is. But we need to get input from ServiceNow. So we need to add placeholders to variable values.

For example, modify the “fname” value as below.

Now save this and go to the Preview Script Usage link under related links. This will provide you with the script to execute this message. Copy this script somewhere as we will need this later.

Now go to User > New User and click on top of Additional actions and then go to Configure > Business Rules

Now you can see the list of business rules related to user creation task. Likewise, you can see and create business rules related to any ServiceNow task.

Click on new, Now it is creating a business rule related to user account creation.

Tick the advanced checkbox, so that you can give an advance business rule like invoking a script, tick the insert checkbox under when to run and select after from the drop-down list under when parameter.

Now go to the advanced tab and copy the script of invoking the REST message. Which we copied earlier.

This script invokes the REST message as the way you have specified with placeholders. But we need to fill them with actual user account creation form values.

To do that, set parameter values as below.

r.setStringParameter(“first_name”, current.first_name);

Here r is the request payload name, and “first_name” is the place holder name we gave in the REST message. Now save this request.

All Done now. :) :)

Now go and create a new user, by clicking on User > New and see whether the task is started. In our process when a task is started it will assign a user task to DevOps. So log in as DevOps (First you need to have a user with username DevOps, or else create such user) go-to tasks and see a new task has assigned to DevOps.

If devops user have recieved a task like this, you are success.

Thank You

--

--