Perl API architecture

This reference explains the Perl API architecture.

Figure 1. Perl API overview

ServiceNow.pm

At the top most of the class hierarchy is the ServiceNow.pm module. This module provides direct subroutines that delegate down into subroutines of the object heirarchy, providing a convenient calling convention if object oriented Perl programming is not a desired practice.

ITIL Objects

The next layer of the class hierarchy contains the ITIL Objects for example Incident.pm, and Change.pm. These objects extend the Task.pm object which inherits from the GlideRecord.pm object.

Configuration.pm

To use the Perl API, the programmer instantiates a Configuration.pm object and sets the service endpoint as well as the login credentials to use the API. For example:
my $CONFIG = ServiceNow::Configuration->new();
$CONFIG->setSoapEndpoint("https://instance_name.service-now.com/");

my $incident = ServiceNow::ITIL::Incident->new($CONFIG);

Connection.pm

The Connection.pm class defines the interfaces for making the SOAP calls to the platform. The default implementation uses the SOAP::Lite module, if you wish to implement your own SOAP interface, you can override this class with your own and implement the following subroutines:
  • new
  • open
  • send
  • close
If running behind a firewall, edit Connection.pm to specify information about the HTTP proxy. In Connection.pm, change the line:
$me->{'SOAP'} = SOAP::Lite->proxy($CONFIG->getSoapEndPoint($target));
to:
$me->{'SOAP'} = SOAP::Lite->proxy($CONFIG->getSoapEndPoint($target), proxy => ['https' => 'http://myproxy.mycompany.com/']);
Substitute the appropriate proxy URL.