- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2017 03:24 AM
Hi,
I need steps to tutorial/videos to create API ( using webservice import set) .
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2017 05:02 AM
Here the steps :
Creating an import set web service
Create a new web service import set table to define how to stage and transform imported data.
Navigate to System Web Services > Create New.

The Name of the web service is the table name of the import set table whereas the Label field is the resulting table field.
If you want to create a transform map after creating the web service, check the Create transform map checkbox and choose the target table you want the data to transform into. After the Create button is clicked, the web service will be created and you will be immediately put into the Table Transform Map form. You may then continue to specify the transform map or script.
Web Service Fields
The fields available for this web service. All fields by default are published as the XSD type of xsd:string
. The Name is the field that is exposed for the web service and therefore appears as the name of the field in the WSDL. The Label is the label of the field as it appears for the import sets table.
You can Add, mark for Delete or modify (double click the field) an existing web service field in this list.
To add other fields after the Web Service is created, find the target table, and add the fields to that table.
- Mapping web service import setsDuring the creation of the web service import set, you may optionally create the transform map for it.
Mapping web service import sets
During the creation of the web service import set, you may optionally create the transform map for it.
All transform maps will be executed for the service when it is invoked if the import set mode is set as "Synchronous" (the default).
The following image is an example of the transform map associated with the Notification web service import set.Soap Transform MapAdding Web Service Response Values
In the transform map script associated with a web service import set, setting certain variable values have the effect of changing the response values of the web service. In addition to the normal variables that are available in a transform map script, the table below documents the variables that are available and their effects.
Variable name Type Description response Output Object Javascript object that holds dynamically created response elements used to customize the output response of a web service import set insert. Example
// create new elements called "transaction_id" // and "hello" in the web service response response.transaction_id="abc123"; response.hello="world"; status_message="message 1";
The code snippet above results in the following response being generated back to the web service consumer
// this is the normal status_message variable<soapenv:Envelopexmlns:imp="http://www.service-now.com/imp_notification" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/><soapenv:Body> <insertResponse xmlns="http://www.service-now.com/imp_notification"> <sys_id>969d157c0a0a0baf008ba5770ffa798c</sys_id>
<table>incident</table> <display_name>number</display_name>
<display_value>INC0010091</display_value> <status>inserted</status> <status_message>message 1</status_message>
<transaction_id>abc123</transaction_id> <hello>world</hello> </insertResponse> </soapenv:Body></soapenv:Envelope>Debugging web service import sets
If you need to debug a SOAP Request coming into the system, create the system property glide.processor.debug.SOAPProcessor.
Once you have created it, set it to true to have all SOAP requests be logged in the System Log.
Set it to false when you are done so as to keep the size of your System Log to a managed length.
Web service import sets example
This example demonstrates the WSDL, SOAP envelope and response, Perl invocation, and result of a SOAP web service import.
Sample WSDL
<?xmlversion="1.0"encoding="UTF-8"?><wsdl:definitions targetNamespace="http://www.service-now.com" xmlns:tns="http://www.service-now.com/imp_notification" xmlns:sncns="http://www.service-now.com" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><wsdl:types><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" targetNamespace="http://www.service-now.com/imp_notification"><xsd:element name="insert"><xsd:complexType><xsd:sequence><xsd:element maxOccurs="1" minOccurs="0" name="corrective_message" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="0" name="duration" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="0" name="expires_on" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="0" name="message" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="0" name="severity" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="0" name="source" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="0" name="timestamp" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="0" name="type" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="1" name="uuid" type="xsd:string"/></xsd:sequence></xsd:complexType></xsd:element><xsd:element name="insertResponse"><xsd:complexType><xsd:sequence><xsd:element maxOccurs="1" minOccurs="1" name="sys_id" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="1" name="table" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="1" name="display_name" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="1" name="display_value" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="1" name="status" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="0" name="status_message" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="0" name="error_message" type="xsd:string"/></xsd:sequence></xsd:complexType></xsd:element></xsd:schema></wsdl:types><wsdl:message name="insertSoapOut"><wsdl:part name="imp_notification" element="tns:insertResponse"/></wsdl:message><wsdl:message name="insertSoapIn"><wsdl:part name="imp_notification" element="tns:insert"/></wsdl:message><wsdl:portType name="ServiceNowSoap"><wsdl:operation name="insert"><wsdl:input message="sncns:insertSoapIn"/><wsdl:output message="sncns:insertSoapOut"/></wsdl:operation></wsdl:portType><wsdl:binding name="ServiceNowSoap" type="sncns:ServiceNowSoap"><soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/><wsdl:operation name="insert"><soap:operation soapAction="http://www.service-now.com/imp_notification/insert" style="document"/><wsdl:input><soap:body use="literal"/></wsdl:input><wsdl:output><soap:body use="literal"/></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="ServiceNow"><wsdl:port name="ServiceNowSoap" binding="sncns:ServiceNowSoap"><soap:address location="http://Macintosh-7.local:8080/glide/imp_notification.do?SOAP"/></wsdl:port></wsdl:service></wsdl:definitions>
Sample SOAP Envelope
<?xmlversion="1.0"encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><insert xmlns="http://www.service-now.com"><message xsi:type="xsd:string">Host 198.10.10.210 is down</message><uuid xsi:type="xsd:string">HGAF76251HGF1</uuid></insert></SOAP-ENV:Body></SOAP-ENV:Envelope>
Sample SOAP Response
<?xmlversion="1.0"encoding="UTF-8"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 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>b54aafbfc0a8006f0058db95daa5b88d</sys_id><table>incident</table><display_name>number</display_name><display_value>INC10008</display_value><status>ignored</status><status_message>No field values changed</status_message></insertResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
Example Invocation using Perl
The following example script will use the Notification web service to create an Incident as the itil user. It uses the Perl language and the SOAP::Lite package.#!/usr/bin/perl -w #use SOAP::Lite ( +trace => all, maptype => {} );use SOAP::Lite; sub SOAP::Transport::HTTP::Client::get_basic_credentials{return'itil'=>'itil';// set basic auth credentials for the itil user } my$soap= SOAP::Lite->proxy('http://localhost:8080/glide/imp_notification.do?SOAP'); my$method= SOAP::Data->name('insert')->;attr({xmlns =>'http://www.service-now.com/'}); # insert into the web servicemy@params=( SOAP::Data->name(message =>'problem detected for database DB12DG'));push(@params, SOAP::Data->name(source =>'DB12DG'));push(@params, SOAP::Data->name(uuid =>'HGAF76251HGF2')); my$result=$soap->call($method=>@params); print_fault($result);//print any SOAP faults print_result($result);//print any results sub print_result {my($result)=@_;if($result->body&&$result->body->{'insertResponse'}){my%keyHash=%{$result->body->{'insertResponse'}};foreachmy$k(keys%keyHash){print"name=$k value=$keyHash{$k}\n";}}} sub print_fault {my($result)=@_;if($result->fault){print"faultcode=".$result->fault->{'faultcode'}."\n";print"faultstring=".$result->fault->{'faultstring'}."\n";print"detail=".$result->fault->{'detail'}."\n";}}
The following is the result printed out by the Perl script on the consolename=display_value value=INC10011 name=status value=inserted name=table value=incident name=display_name value=number name=sys_id value=cd45649c0a0a0b2b00e6f27649d6bd2c
The following image shows the resultant row created for the import set table Notification (imp_notification).WS Iset Perl- Please Refer :
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2017 03:38 AM
Hello Sneha,
Please Refer :
Web Service Import Sets - ServiceNow Wiki
Mapping web service import sets
Import Set API - ServiceNow Wiki
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2017 03:57 AM
Hi Rajesh,
Can you please let me know in brief what are the steps to create a webservice import set
for eg :
1.create a webservice
2.create transform map etc
Sorry I am new to servicenow so any basic will be good - thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2017 05:02 AM
Here the steps :
Creating an import set web service
Create a new web service import set table to define how to stage and transform imported data.
Navigate to System Web Services > Create New.

The Name of the web service is the table name of the import set table whereas the Label field is the resulting table field.
If you want to create a transform map after creating the web service, check the Create transform map checkbox and choose the target table you want the data to transform into. After the Create button is clicked, the web service will be created and you will be immediately put into the Table Transform Map form. You may then continue to specify the transform map or script.
Web Service Fields
The fields available for this web service. All fields by default are published as the XSD type of xsd:string
. The Name is the field that is exposed for the web service and therefore appears as the name of the field in the WSDL. The Label is the label of the field as it appears for the import sets table.
You can Add, mark for Delete or modify (double click the field) an existing web service field in this list.
To add other fields after the Web Service is created, find the target table, and add the fields to that table.
- Mapping web service import setsDuring the creation of the web service import set, you may optionally create the transform map for it.
Mapping web service import sets
During the creation of the web service import set, you may optionally create the transform map for it.
All transform maps will be executed for the service when it is invoked if the import set mode is set as "Synchronous" (the default).
The following image is an example of the transform map associated with the Notification web service import set.Soap Transform MapAdding Web Service Response Values
In the transform map script associated with a web service import set, setting certain variable values have the effect of changing the response values of the web service. In addition to the normal variables that are available in a transform map script, the table below documents the variables that are available and their effects.
Variable name Type Description response Output Object Javascript object that holds dynamically created response elements used to customize the output response of a web service import set insert. Example
// create new elements called "transaction_id" // and "hello" in the web service response response.transaction_id="abc123"; response.hello="world"; status_message="message 1";
The code snippet above results in the following response being generated back to the web service consumer
// this is the normal status_message variable<soapenv:Envelopexmlns:imp="http://www.service-now.com/imp_notification" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/><soapenv:Body> <insertResponse xmlns="http://www.service-now.com/imp_notification"> <sys_id>969d157c0a0a0baf008ba5770ffa798c</sys_id>
<table>incident</table> <display_name>number</display_name>
<display_value>INC0010091</display_value> <status>inserted</status> <status_message>message 1</status_message>
<transaction_id>abc123</transaction_id> <hello>world</hello> </insertResponse> </soapenv:Body></soapenv:Envelope>Debugging web service import sets
If you need to debug a SOAP Request coming into the system, create the system property glide.processor.debug.SOAPProcessor.
Once you have created it, set it to true to have all SOAP requests be logged in the System Log.
Set it to false when you are done so as to keep the size of your System Log to a managed length.
Web service import sets example
This example demonstrates the WSDL, SOAP envelope and response, Perl invocation, and result of a SOAP web service import.
Sample WSDL
<?xmlversion="1.0"encoding="UTF-8"?><wsdl:definitions targetNamespace="http://www.service-now.com" xmlns:tns="http://www.service-now.com/imp_notification" xmlns:sncns="http://www.service-now.com" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><wsdl:types><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" targetNamespace="http://www.service-now.com/imp_notification"><xsd:element name="insert"><xsd:complexType><xsd:sequence><xsd:element maxOccurs="1" minOccurs="0" name="corrective_message" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="0" name="duration" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="0" name="expires_on" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="0" name="message" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="0" name="severity" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="0" name="source" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="0" name="timestamp" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="0" name="type" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="1" name="uuid" type="xsd:string"/></xsd:sequence></xsd:complexType></xsd:element><xsd:element name="insertResponse"><xsd:complexType><xsd:sequence><xsd:element maxOccurs="1" minOccurs="1" name="sys_id" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="1" name="table" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="1" name="display_name" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="1" name="display_value" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="1" name="status" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="0" name="status_message" type="xsd:string"/><xsd:element maxOccurs="1" minOccurs="0" name="error_message" type="xsd:string"/></xsd:sequence></xsd:complexType></xsd:element></xsd:schema></wsdl:types><wsdl:message name="insertSoapOut"><wsdl:part name="imp_notification" element="tns:insertResponse"/></wsdl:message><wsdl:message name="insertSoapIn"><wsdl:part name="imp_notification" element="tns:insert"/></wsdl:message><wsdl:portType name="ServiceNowSoap"><wsdl:operation name="insert"><wsdl:input message="sncns:insertSoapIn"/><wsdl:output message="sncns:insertSoapOut"/></wsdl:operation></wsdl:portType><wsdl:binding name="ServiceNowSoap" type="sncns:ServiceNowSoap"><soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/><wsdl:operation name="insert"><soap:operation soapAction="http://www.service-now.com/imp_notification/insert" style="document"/><wsdl:input><soap:body use="literal"/></wsdl:input><wsdl:output><soap:body use="literal"/></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="ServiceNow"><wsdl:port name="ServiceNowSoap" binding="sncns:ServiceNowSoap"><soap:address location="http://Macintosh-7.local:8080/glide/imp_notification.do?SOAP"/></wsdl:port></wsdl:service></wsdl:definitions>
Sample SOAP Envelope
<?xmlversion="1.0"encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><insert xmlns="http://www.service-now.com"><message xsi:type="xsd:string">Host 198.10.10.210 is down</message><uuid xsi:type="xsd:string">HGAF76251HGF1</uuid></insert></SOAP-ENV:Body></SOAP-ENV:Envelope>
Sample SOAP Response
<?xmlversion="1.0"encoding="UTF-8"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 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>b54aafbfc0a8006f0058db95daa5b88d</sys_id><table>incident</table><display_name>number</display_name><display_value>INC10008</display_value><status>ignored</status><status_message>No field values changed</status_message></insertResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
Example Invocation using Perl
The following example script will use the Notification web service to create an Incident as the itil user. It uses the Perl language and the SOAP::Lite package.#!/usr/bin/perl -w #use SOAP::Lite ( +trace => all, maptype => {} );use SOAP::Lite; sub SOAP::Transport::HTTP::Client::get_basic_credentials{return'itil'=>'itil';// set basic auth credentials for the itil user } my$soap= SOAP::Lite->proxy('http://localhost:8080/glide/imp_notification.do?SOAP'); my$method= SOAP::Data->name('insert')->;attr({xmlns =>'http://www.service-now.com/'}); # insert into the web servicemy@params=( SOAP::Data->name(message =>'problem detected for database DB12DG'));push(@params, SOAP::Data->name(source =>'DB12DG'));push(@params, SOAP::Data->name(uuid =>'HGAF76251HGF2')); my$result=$soap->call($method=>@params); print_fault($result);//print any SOAP faults print_result($result);//print any results sub print_result {my($result)=@_;if($result->body&&$result->body->{'insertResponse'}){my%keyHash=%{$result->body->{'insertResponse'}};foreachmy$k(keys%keyHash){print"name=$k value=$keyHash{$k}\n";}}} sub print_fault {my($result)=@_;if($result->fault){print"faultcode=".$result->fault->{'faultcode'}."\n";print"faultstring=".$result->fault->{'faultstring'}."\n";print"detail=".$result->fault->{'detail'}."\n";}}
The following is the result printed out by the Perl script on the consolename=display_value value=INC10011 name=status value=inserted name=table value=incident name=display_name value=number name=sys_id value=cd45649c0a0a0b2b00e6f27649d6bd2c
The following image shows the resultant row created for the import set table Notification (imp_notification).WS Iset Perl- Please Refer :
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2017 06:16 AM
Hello Sneha,
I hope your Query is been Answered or else let me know if you need more help, Please hit Like and Helpful and mark as Correct Answer.
This enables other customers to learn from your thread.
Thank you in advance.
If you are viewing this from the community inbox you will not see the correct answer button. If so, please review How to Mark Answers Correct From Inbox View.
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke