Web Service Examples

Top  Previous  Next

Example 1: Accessing AggreGate Server Web Service From a PHP Script

This example shows how to get the value of a AggreGate Server 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 = "childInfo";

 

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 AggreGate Server 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