Web Service

Top  Previous  Next

LinkServer supports a Web Services technology for integration with third-party ERP, CRM and other software systems. It supports the SOAP protocol,  used for sending XML-encoded data over secure HTTP connections.

note_glossary-term

Web Services is a set of protocols for generic data exchange between different systems.

LinkServer’s Web Service allows total control of the server. It is possible to stop/restart the server, manage users, register and configure Device Servers and Data Terminals, view  Data Terminal events and their status etc.

Technically, the Web Service provides methods for getting and setting values of context variables and calling context functions. Listening to context events is not supported.

Web Service Address

LinkServer Web Service is available at the following addresses:

 

https://server_host_name:server_ssl_port/ws/services/LinkServerWeb (for secure SHTTP-based connections)

http://server_host_name:server_non_ssl_port/ws/services/LinkServerWeb (for non-secure HTTP connections)

 

server_host_name is the IP address or host name of the server. It may match one of the aliases defined in the host name aliases list Global Configuration Setting.

server_ssl_port is the port number on which LinkServer accepts incoming secure HTTP (HTTPS) connections. Default value is 8443. This port is defined by Port number to listen for HTTPS (secure) connections Global Configuration Setting.

server_non_ssl_port is the port number on that LinkServer accepts incoming HTTP connections. Default value is 8080. This port is defined by Port number to listen for HTTP (non-secure) connections Global Configuration Setting.

note_tip-wt

Non-secure HTTP access to the Web Service is disabled by default. It can be enabled by turning on Enable non-secure access to web applications Global Configuration Setting.

note_example-wt

Example: If LinkServer is running on the local host and all settings are set to their defaults, you can access the Web Service using the following URL:

https://localhost:8443/ws/services/LinkServerWeb

Available Functions

Functions that use XML encoding of Data Tables

1. getXML

The getXML Web Service function is used to retrieve values of LinkServer context variables.

Function parameters:

Name

Type

Description

username

String

Name of LinkServer user account that will be used to log in to the server. The Get variable operation will be executed with this user's permissions.

password

String

Password for the user account.

context

String

Context path for the variable.

variable

String

Name of variable.

Return value: this function returns a String that is a Data Table containing the value of requested variable. This value is encoded in XML format. See Data Table XML Encoding for more information. The resulting XML string is encoded once again according to the URL encoding standard specified by RFC 1738 (Uniform Resource Locators). This is to ensure that the resulting string doesn't contain characters unsafe for SOAP protocol.

 

2. setXML

The setXML function allows to change the value for a LinkServer context variable.

 

Function parameters:

Name

Type

Description

username

String

Name of LinkServer user account that will be used to log in to the server. The Set variable operation will be executed with the this user's permissions.

password

String

Password for the user account.

context

String

Path of context to set variable in.

variable

String

Name of variable.

value

String

New value of the variable encoded in XML format. See Data Table XML Encoding for more information. The resulting XML document is encoded once again according to URL encoding standard specified by RFC 1738 (Uniform Resource Locators).  This is to ensure that the resulting string doesn't contain characters unsafe for SOAP protocol.

Return value: none.

In most cases, the value argument passed to this function is a Data Table that was previously retrieved by the getXML function.

 

3. callXML

The callXML function is used to execute LinkServer context functions, by passing function arguments in an XML-encoded Data Table.

 

Function parameters:

Name

Type

Description

username

String

Name of LinkServer user account that will be used to log in to the server. The Call function operation will be executed with this user's permissions.

password

String

Password for the user account.

context

String

Path of context from which the function is to be called.

variable

String

Name of function.

value

String

Data Table containing function input parameters. This table is encoded in XML format. See Data Table XML Encoding for more information. The resulting XML document is encoded once again according to URL encoding standard specified by RFC 1738 (Uniform Resource Locators). This is to ensure that the resulting string doesn't contain characters unsafe for SOAP protocol.

Return value: this Web Service function returns a String that is a Data Table returned by the function executed. This value is encoded just like the value input parameter above.

Functions that REPRESENT DATA TABLES AS STRING ARRAYS

1. setByStringArray

The setByStringArray function is used to change values of LinkServer context variables. Cells of the Data Table containing the new value are passed to it as an array of String arguments.

 

Function parameters:

Name

Type

Description

username

String

Name of LinkServer user account that will be used to log in to the server. The Set variable operation will be executed with this user's permissions.

password

String

Password for the user account.

context

String

Path of context from which the function is to be called.

variable

String

Name of variable.

values

String[]

An array of Strings,  used to fill Data Table with the new variable value.

The value of each cell is composed of the corresponding argument (i.e. value in first row and first column is created from the value of first command argument etc.)

If the Record Format for the table defines N fields, the first N arguments are used for filling the first row, the second N arguments for the second row etc.

Rules for encoding/decoding values of different types to/from strings may be found here.

Return value: none.

 

2. callByStringArray

callByStringArray function allows to execute LinkServer context function by passing its arguments as a String array.

 

Function parameters:

Name

Type

Description

username

String

Name of LinkServer user account that will be used to log in to the server. The Call function operation will be executed with this user's permissions.

password

String

Password for the user account.

context

String

Path of context to call function from.

variable

String

Name of function.

parameters

String[]

Array of Strings that are used to fill Data Table representing function input value.

The value of each cell is composed of the corresponding argument (i.e. value in first row and first column is created from the value of first command argument etc.)

If Record Format of for the table defines N fields, first N arguments are used for filling the first row, second N arguments for the second row etc.

Rules for encoding/decoding values of different types to/from strings may be found here.

Return value: this Web Service function returns a String that is a Data Table returned by the function executed. This value is encoded just like the value input parameter above.

Functions that use NATIVE encoding of Data Tables

There are three Web Service functions that use the same Data Table encoding used in AggreGate Communications Protocol:

get
set
call

These functions are used to get/set values of LinkServer context variables and call context functions respectively. They are used by LinkServer .NET API and should not be used by other Web Service clients.

Examples

Example 1: Accessing LinkServer Web Service From a PHP Script

This example shows how to get the value of a LinkServer context variable from a PHP script using the Web Service.

note_further-wt

The complete source code of this example is available in the Downloads section of the AggreGate website.

 

<?php

// Creating SOAP client for the LinkServer running on localhost

$client = new SoapClient("https://localhost:8443/ws/?wsdl");

 

$username = "admin";

$password = "admin";

$context = "users.admin";

$variable = "userInfo";

 

try

{

       // Calling getXML Web Service function and decoding its output by URL decoder

       $userInfoXML = urldecode($client->getXML($username, $password, $context, $variable));

}

catch (SoapFault $fault)

{

       echo "Error occurred while calling remote function: ".$fault->faultcode." (".$fault->faultstring.")";

       exit();

}

 

if (is_soap_fault($userInfoXML))

{

       echo "Error occurred while calling remote function: ".$fault->faultcode." (".$fault->faultstring.")";

       exit();

}

 

// Creating DOM document from XML

$xml = new DomDocument;

$xml->loadXML( $userInfoXML );

 

// Loading XSLT transformation

$xsl = new DomDocument;

$xsl->load( 'resources/xslt/dataTable.xslt' );

 

// Creating XSLT processor

$proc = new xsltprocessor;

$proc->importStyleSheet( $xsl );

 

// Processing out XML document and and showing the output

echo $proc->transformToXML( $xml );

?>

Example 2: Calling a Context Function

This example shows how to create a new LinkServer user account by calling the register function of the root context. Creation of SOAP client and error checking are omitted in this example.

$params[0]="phpuser"; // Username (value for record 0, field 0 of function input Data Table)

$params[1]="test"; // Password (value for record 0, field 1)

$params[2]="test"; // Repeat Password (value for record 0, field 2)

urldecode($client->callByStringArray("admin", "admin", "", "register", $params)); // Calling function via Web Service