Article ID: 2270, created on Oct 18, 2007, last review on May 11, 2014

  • Applies to:
  • Virtuozzo for Windows 3.5.1 SP1

Resolution

PHP has its own WSDL-to-PHP generator: PHP SOAP, NuSOAP library, and handle SOAP packet generation.

PHP SOAP can't parse our WSDL.

This is an example of manual packet generation with PHP SOAP:

<?php

echo "Starting...\n";

$ticketm = new soapclient(http://www.swsoft.com/webservices/vza/3.0.3/VZAticketm.wsdl,
             array(
               "location" => 'http://192.168.0.218:8081/',
               "uri"=> 'http://localhost:8081/'
             )
        );
$param->ip = "";      
$param->user = "vzagent0";
$param->password=base64_encode("1q2w3e");

echo "login ...";
$result = $ticketm->login( $param );
echo "[Ok]\n";
$ticket = $result->ticket;
echo "ticket:$ticket\n";

$vem = new soapclient(http://www.swsoft.com/webservices/vza/3.0.3/VZAvem.wsdl,
             array(
               "location" => 'http://192.168.0.218:8081/',
               "uri"=> 'http://localhost:8081/'
             )
        );
 
$viparam = array(
        'status'=> array('state'),
        'config'=> array('ip'=>NULL, 'base_set'=>NULL, 'hostname'=>NULL )
  );
 
$hdr = new SoapHeader("http://www.swsoft.com/webservices/vza/3.0.3/protocol",
packet_header", array( 'session'=>$ticket ) );
 
$result = $vem->__soapCall( "ve_info", $viparam, NULL, $hdr);
 
print_r( $result );
?>


This is an example of using NuSOAP library:

<?
echo "<h1>VZA SOAP test</h1>\n";
require_once('nusoap.php');
function hanle_error($err)
{
        echo "<h1>Error:$err</h1>\n";
}
 
$username = 'vzagent0';
$pwd = base64_encode( '1q2w3e' );
$endpoint = http://192.168.0.218:8081/;
$vemns = http://www.swsoft.com/webservices/vza/3.0.3/vem;
 
echo "<p>Starting....[$endpoint]</p>\n";
 
echo "<p>Loading ticketm wsdl....";
$ticketmWSDL = new soapclient
 "http://www.swsoft.com/webservices/vza/3.0.3/VZAticketm.wsdl", "wsdl" );
$ticketmWSDL->setEndpoint( $endpoint );
echo "[Ok]</p>\n";
 
$ticketm = $ticketmWSDL->getProxy();
 
echo "<h2>login....";
 
$result = $ticketm->login(array('ip'=>'', 'user'=>$username, 'password'=>$pwd));
 
$err = $ticketm->getError();
if($err)
{
        handle_error($err);
        return;
}
echo "[Ok]</h2>\n";
 
$ticket = $result['ticket'];
echo "<blockquote><h3>ticket:$ticket</h3></blockquote>\n";
 
/////////////////// ve_info ////////////////////
echo "<p>Loading vem wsdl....";
$vemWSDL = new soapclient( $endpoint );
echo "[Ok]</p>\n";
 
$veinfoPar = array (
    'status' => '',
    'config' => array (
        'base_set' => '',
        'ip' => '',
        'hostname'=>''
    )
);
 
$hdr = "<packet_header><session>$ticket</session></packet_header>";
 
$vemWSDL->setHeaders( $hdr );
echo "<h2>ve_info....";
$result = $vemWSDL->call( "ve_info",  $veinfoPar,  $vemns  );
$err = $vemWSDL->getError();
if($err)
{
        handle_error($err);
        return;
}
echo "[Ok]</h2>\n";
//print_r( $result );
echo <<<eoh
<blockquote>
<h3>ve_info result:</h3>
<table width="100%" border="0">
<tr>
        <th align="left">VEID</th>
        <th align="left">Status</th>
        <th align="left">ip</th>
        <th align="left">base_set</th>
        <th align="left">hostname</th>
</tr>
eoh;
foreach( $result as $i => $v )
{
    echo "<tr>\n";
    $status    = $v['status']['state'];
    $config     = $v['config'];
    $ip        = array_key_exists( 'ip', $config ) ? $config['ip'] : '';
    $base_set   = array_key_exists( 'base_set', $config ) ? $config['base_set'] : '';
    $hostname  = array_key_exists( 'hostname', $config ) ? $config['hostname'] : '';
    echo "<td>{$v['veid']} <td>$status <td>$ip <td>$base_set <td>$hostname\n";
    echo "</tr>\n";
}
echo <<<eoh
</table>
<blockquote>
eoh;
?>

1348db476c8a5844ffbef8d503db9c15 965b49118115a610e93635d21c5694a8 d02f9caf3e11b191a38179103495106f 2897d76d56d2010f4e3a28f864d69223

Email subscription for changes to this article
Save as PDF