All pastes #103175 Raw Edit

jabbott

public php v1 · immutable
#103175 ·published 2006-07-28 04:33 UTC
rendered paste body
// This uses the NuSOAP library// Client Script// Pull in the NuSOAP coderequire_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 '<p><b>Constructor error: ' . $err . '</b></p>';    // 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 faultif ($client->fault) {    echo '<p><b>Fault: ';        print_r($result);    echo '</b></p>';} else {    // Check for errors    $err = $client->getError();    if ($err) {        // Display the error        echo '<p><b>Error: ' . $err . '</b></p>';    } else {        // Display the result        print_r($result); echo "<br \>";    }}// Server Scriptrequire_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);}