Blog

SoapUI and ServiceNow

"SoapUI is an open source web service testing application for service-oriented architectures (SOA). Its functionality covers web service inspection, invoking, development, simulation and mocking, functional testing, load and compliance testing."

In terms of ServiceNow, soapUI is great for testing and developing web service requests.  This works for consumption and production of these requests from ServiceNow and also from other applications.

Core features of SoapUI include:

  • Web services inspection
  • Web services invoking
  • Web services development
  • Web services simulation and mocking
  • Web services functional, load, compliance and security testing

Here is a quick guide on how to use SoapUI and ServiceNow.

 SoapUI Website

SoapUI Website

Step 1: Install SoapUI Free

http://www.soapui.org/

Note: You can also choose to use SoapUI Pro, but I would start with SoapUI Free and see if the SoapUI Pro functionality is needed later.

Version Note: I have had trouble using certain versions of SoapUI (Version 4.6.4) and ServiceNow.  I received "invalid definition exception" error and couldn't connect.  If I used version 3.6.1 of SoapUI, everything worked great for me.  This issue will likely be fixed in later versions of SoapUI.  Use version of 3.6.1 of SoapUI if you receive an "invalid definition exception" error (HTTP 401).

Step 2: Create Project

1. Open SoapUI
2. Click File > New soapUI Project
3. Project Name: SNE ServiceNow
4. Click Ok

Step 3: Add WSDL

 SoapUI Add WSDL

SoapUI Add WSDL

1. Right Click the SNE ServiceNow project > Click Add WSDL
2. WSDL Location: https://<your_instance>.service-now.com/incident.do?WSDL
 Create Requests: true

Note: Change <your_instance> with your instance

3. Click Ok 

Step 4: Set Security

1. Add Basic Authentication if prompted.

Note: The ServiceNow user used needs the appropriate roles to query needed data.  The soap or soap_query capability word is usually needed.

2. Double click ServiceNowSOAP
3. Click Service Endpoints tab > Fill in Username and Password column
4. Click the X in the top right corner to close the endpoint window

Example 1: Insert new incident

1. In SoapUI click Project > SNE ServiceNow > ServiceNowSOAP > insert
2. Edit XML.  Example XML:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inc="http://www.service-now.com/incident">
 <soapenv:Header/>
 <soapenv:Body>
<inc:insert>
 <caller_id>Mike Kaufman</caller_id>
 <description>SNE ServiceNow SOAP Incident</description>
 <impact>4</impact>
 <short_description>SNE  ServiceNow SOAP Incident</short_description>
 <urgency>4</urgency>
</inc:insert>
 </soapenv:Body>
</soapenv:Envelope>

3. Select the green arrow to submit the soap request
4. You will receive a soap response that the the incident was created. Example response below:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <SOAP-ENV:Body>
<insertResponse>
 <sys_id>f0b43d2bf98ad500bae4f84b43abbc14</sys_id>
 <number>INC0010350</number>
</insertResponse>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

SoapUI Insert Incident

 

Example 2: Update an existing incident

1. In SoapUI click Project > SNE ServiceNow > ServiceNowSOAP > update
2. Edit XML. Example XML:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inc="http://www.service-now.com/incident">
 <soapenv:Header/>
 <soapenv:Body>
<inc:update>
 <sys_id>f0b43d2bf98ad500bae4f84b43abbc14</sys_id>
 <description>Mike Kaufman was here</description>
 <impact>3</impact>
 <urgency>3</urgency>
</inc:update>
 </soapenv:Body>
</soapenv:Envelope>

3. Select the green arrow to submit the soap request
4. You will receive a soap response that the the incident was updated. Example response below:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <SOAP-ENV:Body>
<updateResponse>
 <sys_id>f0b43d2bf98ad500bae4f84b43abbc14</sys_id>
</updateResponse>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

SoapUI Update Incident

Example 3: Delete an Incident

1. In SoapUI click Project > SNE ServiceNow > ServiceNowSOAP > deleteRecord
2. Edit XML. Example XML:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inc="http://www.service-now.com/incident">
 <soapenv:Header/>
 <soapenv:Body>
<inc:deleteRecord>
 <sys_id>f0b43d2bf98ad500bae4f84b43abbc14</sys_id>
</inc:deleteRecord>
 </soapenv:Body>
</soapenv:Envelope>

3. Select the green arrow to submit the soap request
4. You will receive a soap response that the the incident was deleted. Example response below:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <SOAP-ENV:Body>
<deleteRecordResponse>
 <count>1</count>
</deleteRecordResponse>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Example 4: Query Incidents with an encoded query and limit columns

1. In SoapUI click Project > SNE ServiceNow > ServiceNowSOAP > deleteRecord
2. Edit XML. Example XML:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inc="http://www.service-now.com/incident">
 <soapenv:Header/>
 <soapenv:Body>
<inc:getRecords>
 <__encoded_query>stateIN1,2,5,8</__encoded_query>
 <__exclude_columns>activity_due,approval,approval_set,delivery_plan,delivery_task,expected_start,order,upon_approval,upon_reject</__exclude_columns>
</inc:getRecords>
 </soapenv:Body>
</soapenv:Envelope>

3. Select the green arrow to submit the soap request
4. You will receive a soap response with the incidents found