// This uses the NuSOAP library // Client Script // Pull in the NuSOAP code require_once('lib/nusoap.php'); // Create the client instance $client = new soap_client('http://hostname/server-scripts/soap-server.php?wsdl', true); $NAMESPACE = 'urn:Virtuozzo'; // Check for an error $err = $client->getError(); if ($err) { // Display the error echo '

Constructor error: ' . $err . '

'; // At this point, you know the call that follows will fail } // Call the SOAP method $result = $client->call( 'vzctl', // method name array('set', '300', '--hostname VZSOAP.changed.internal --save'), // input parameters 'uri:Virtuozzo', // namespace 'uri:Virtuozzo/vzctl' // SOAPAction ); // Check for a fault if ($client->fault) { echo '

Fault: '; print_r($result); echo '

'; } else { // Check for errors $err = $client->getError(); if ($err) { // Display the error echo '

Error: ' . $err . '

'; } else { // Display the result print_r($result); echo "
"; } } // Server Script require_once('lib/nusoap.php'); // Require NuSOAP library $NAMESPACE = 'urn:Virtuozzo'; $server = new soap_server; $server->debug_flag=true; // Debug Support OFF $server->configureWSDL('Virtuozzo', $NAMESPACE); // Initialize WSDL support $server->wsdl->schemaTargetNamespace = $NAMESPACE; // Initialize WSDL Target Namespace $server->register( 'vzctl', array('cmd'=>'xsd:string', 'vpsid'=>'xsd:int', 'opt'=>'xsd:string'), array('return'=>'tns:vzctlArray'), $NAMESPACE); // Register Function: "vzctl" $HTTP_RAW_POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : ''; $server->service($HTTP_RAW_POST_DATA); exit(); function vzctl($cmd, $vpsid, $opts) { $rtn0 = 'vzctl '.$cmd.' '.$vpsid.' '.$opts; system($rtn0, $retval); return new soapval('return', 'xsd:string', $retval); }