* @author Romain Quetiez * @author Denis Flaven * @license http://www.opensource.org/licenses/gpl-3.0.html LGPL */ require_once('itopsoaptypes.class.inc.php'); $sItopRoot = 'http'.((isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS']!='off')) ? 's' : '').'://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].dirname($_SERVER['SCRIPT_NAME']).'/..'; $sWsdlUri = $sItopRoot.'/webservices/itop.wsdl.php'; //$sWsdlUri .= '?service_category='; $aSOAPMapping = SOAPMapping::GetMapping(); ini_set("soap.wsdl_cache_enabled","0"); $oSoapClient = new SoapClient( $sWsdlUri, array( 'trace' => 1, 'classmap' => $aSOAPMapping, // defined in itopsoaptypes.class.inc.php ) ); try { // The most simple service, returning a string // $sServerVersion = $oSoapClient->GetVersion(); echo "

GetVersion() returned $sServerVersion

"; // More complex ones, returning a SOAPResult structure // (run the page to know more about the returned data) // $oRes = $oSoapClient->CreateIncidentTicket ( 'admin', /* login */ 'admin', /* password */ 'Email server down', /* title */ 'HW found shutdown', /* description */ null, /* caller */ new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Demo'))), /* customer */ new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'NW Management'))), /* service */ new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Troubleshooting'))), /* service subcategory */ '', /* product */ new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'NW support'))), /* workgroup */ array( new SOAPLinkCreationSpec( 'Device', array(new SOAPSearchCondition('name', 'switch01')), array() ), new SOAPLinkCreationSpec( 'Server', array(new SOAPSearchCondition('name', 'dbserver1.demo.com')), array() ), ), /* impacted cis */ '1', /* impact */ '1' /* urgency */ ); echo "

CreateIncidentTicket() returned:\n"; echo "

\n";
	print_r($oRes);
	echo "
\n"; echo "

\n"; $oRes = $oSoapClient->SearchObjects ( 'admin', /* login */ 'admin', /* password */ 'SELECT URP_Profiles' /* oql */ ); echo "

SearchObjects() returned:\n"; if ($oRes->status) { $aResults = $oRes->result; echo "\n"; // Header made after the first line echo "\n"; foreach ($aResults[0]->values as $aKeyValuePair) { echo " \n"; } echo "\n"; foreach ($aResults as $iRow => $aData) { echo "\n"; foreach ($aData->values as $aKeyValuePair) { echo " \n"; } echo "\n"; } echo "
".$aKeyValuePair->key."
".$aKeyValuePair->value."
\n"; } else { $aErrors = array(); foreach ($oRes->errors->messages as $oMessage) { $aErrors[] = $oMessage->text; } $sErrorMsg = implode(', ', $aErrors); echo "

SearchObjects() failed with message: $sErrorMsg

\n"; //echo "
\n";
		//print_r($oRes);
		//echo "
\n"; } echo "

\n"; } catch(SoapFault $e) { echo "

SoapFault Exception: {$e->getMessage()}

\n"; echo "

Request

\n"; echo "
\n"; 
	echo htmlspecialchars($oSoapClient->__getLastRequest())."\n"; 
	echo "
"; echo "

Response

"; echo $oSoapClient->__getLastResponse()."\n"; } ?>