About Webservices in the SW helpdesk
Some hints about how to setup something similar to the SW helpdesk:
- The SW helpdesk was at the beginning developped from Oneorzero but the code has been touched many times.
- The DB used is MySQL. I do not expect critical difference between versions, however for your information the version we installed is
mysql Ver 11.18 Distrib 3.23.58, for redhat-linux-gnu (i686)
- The webservices package used is nuSOAP, so this one you should have installed. Our version is
nusoap-0.7.2-5
- Then there are some files that I would try to explain: (the authorization is not included, it does not affect the webservices functionality ):
- index_empty.php (the main file: that calls to the nuSOAP classes and includes the files with the webservices functions)
- create_empty.php (this file has the functionality to create a new ticket. This file is called by the helpdesk itself to actualize the database and also communicate to GGUS with the modifyWS function included in the common_empty.php.)
- common_empty.php (include the set up to communicate with the GGUS webservices through the specifications in helpdesk_empty.xml. The client->TicketModify is the call to the GGUS webservices.)
- helpdesk_empty.xml (collection of the main configuration variables: GGUS password for GGUS webservices,...)
- classes/xmlconfig.php
- init.php, just to parser the xml variables in helpdesk_empty.xml
Call to nuSoap, create a new server and configure it:
require "NuSOAP/nusoap.php";
$server = new soap_server();
$server->configureWSDL($helpdeskID, "urn:$helpdeskID", $helpdesk['provider'], 'document');
....
require "myService.php";
...
$server->service($HTTP_RAW_POST_DATA);
The variables $helpdeskID and $helpdesk have been intialized before and myService.php has the service to include; for example, the service to create a new ticket. In myService.php is defined the input and output fields:
$server->wsdl->addComplexType(
'CreateInputMap',
'complexType',
'struct',
'sequence',
'',
$createElements
);
$server->wsdl->addComplexType(
'CreateOutputMap',
'complexType',
'struct',
'sequence',
'',
$ReqID
);
Here the name associated to the input values is
CreateInputMap and the fields are included in $createElements, something like
$createElements = array_merge( $ExternalID , Array(
'Date' => Array('name' => 'Date' , 'type' => 'xsd:string')
));
where the $externalID could be something like
$ExternalID = Array( 'Origin_ID' => Array('name' => 'Origin_ID', 'type' => 'xsd:string' ) );
After the definition you can register the service:
$server->register('opCreate',
Array('input'=>'tns:CreateInputMap'),
Array('result'=>'tns:CreateOutputMap'),
'urn:' . $helpdeskID,
'urn:' . $helpdeskID . '/opCreate',
'document',
'literal'
);
and finally you should provide the correct function opCreate:
function opCreate($array) {
....
return Array( 'result' => Array( 'Request-ID' => "$tid" ) );
}
This is the basic framework to create your own webservices.
Within the function that manages the result for the service, there is a workflow quite general to follow:
- Check the permissions/authorization.
- Check the mandatories fields.
- Format the input data to the data in the DB.
- Check the possibilities for autotasks.
- Check and avoid loops (SW helpdesk to GGUS to SW helpdesk ...).
- Do the queries in the DB.
- Do the assignments.
- Inform the users/supporters.
- Update the external helpdesk: GGUS,...
- ...
The webservices does not include too many operations, just the main ones:
- opCreate: the input fields are some of the information you need to create a ticket. The mandatory field is Short_description. In case the ticket is created by an external helpdesk, the external ID and the identifciation of the external helpdesk are also mandatory.
_
TicketGet? _
-- Main.amoros - 28 Nov 2008