Article ID: 2271, created on Apr 2, 2009, last review on Apr 24, 2012

  • Applies to:
  • Virtuozzo for Windows 3.5.1 SP1

Resolución

#!/usr/bin/perl -w
use MIME::Base64;
use Config;

my $OS=$Config{'osname'};
my $HOST = 'http://192.168.0.218:8081',
   $USER = 'vzagent0',
#   $USER = 'admin',
   $PWD  = '1q2w3e',
   $URI_HEADER = 'http://www.swsoft.com/webservices/vza/WSDL/3.0.3/mailc',
   $URI_HWM    = 'http://www.swsoft.com/webservices/vza/3.0.3/hwm',
   $URI_VEM    = 'http://www.swsoft.com/webservices/vza/3.0.3/vem',
   $URI_TICKETM= 'http://www.swsoft.com/webservices/vza/3.0.3/ticketm'
   ;

my $PWD64= encode_base64( $PWD, '' );

use SOAP::Lite;

my $service = new SOAP::Lite;

print "Connect URL - [$HOST]\n User: [$USER]\n OS: [$OS]\n";

$service->proxy( $HOST );
$service->autotype( 0 );
$service->readable( 1 ); # For human readable envelopes[C
$service->transport()->timeout( 100 );
#$service->encodingspace( 'enc' );
$service->serializer()->soapversion('1.1');
if($OS eq 'linux') {
    $service->serializer()->register_ns( 'http://schemas.xmlsoap.org/soap/envelope/', 'soapenc' );
}

$SOAP::Constants::PATCH_HTTP_KEEPALIVE=1;

#$service->transport()->agent('TestAgent');
#$service->transport()->request()->header( 'Content-Type'=>'text/plain' );

#my $result = $service->login( SOAP::Data->name('user' => 'user-name' ) , SOAP::Data->name('password' =>
#                                 \SOAP::Data->value(
#                                     SOAP::Data->name('intern' => 'intern-data' )
#                                   )
#                               ) );

#my $hdr = SOAP::Header
#    ->name( 'package_header' )
#    ->attr( { 'xmlns' => 'http://www.swsoft.com/webservices/vza/WSDL/3.0.3/mailc' } )
#    ;

my $login  = SOAP::Data
    ->name( "login" )
    ->attr( {'xmlns' => $URI_TICKETM } )
    ;
   
my @loginParam =   (
#                         $hdr,
                          SOAP::Data->name('ip' =>  ) ,
                          SOAP::Data->name('user' => $USER ) ,
                          SOAP::Data->name('password' => $PWD64  )  
                   );
   
   
#my $loginParam = SOAP::Data
#               
#                  ->value(
#                         $hdr,
#                         SOAP::Data->name('user' => $USER ) ,
#                         SOAP::Data->name('password' => $PWD64  )  
#                  );
    
   
my $result = $service->call( $login => @loginParam );
if( $result->fault )
{
    print "ERROR:".$result->faultstring."\n";
    die;
}
my $ticket = $result->valueof( '//loginResponse/ticket' );
print "Ticket=";
print $ticket;
print "\n";

######################### LIST_VE ##########################
my $hdr = SOAP::Header
    ->name( 'packet_header' => \SOAP::Header->name( 'session' => $ticket  ) )
    ->attr( { 'xmlns' => $URI_HEADER } )
    ;

my $list_ve  = SOAP::Data
    ->name( "list_ve" )
    ->attr( {'xmlns' => $URI_HWM } )
    ;
   
my @list_veParam =   (
                          $hdr,
                          SOAP::Data->name('count' => 999 )
                   );

print "list_ve:";
my $ves = $service->call( $list_ve => @list_veParam );
if( $ves->fault )
{
    print "ERROR:".$result->faultstring."\n";
    die;
}
print "... [Ok]\n";

for my $i ($ves->valueof('//list_veResponse/veid'))
{
    print "veid[$i]\n";
}
######################## VE_INFO ##########################
my $ve_info  = SOAP::Data
    ->name( "ve_info" )
    ->attr( {'xmlns' => $URI_VEM } )
    ;
my @ve_infoParam =   (
                          $hdr,
                          SOAP::Data->name('status' => ),
                          SOAP::Data->name('config' =>
                           (
                              \SOAP::Data->name( 'ip' => ),
                              \SOAP::Data->name( 'base_set' => )
                           )
                         )   
                   );
print "ve_info ";
my $vi = $service->call( $ve_info => @ve_infoParam );
if( $vi->fault )
{
    print "ERROR:".$result->faultstring."\n";
    die;
}
print "... [Ok]\n";
for my $i ($vi->valueof('//ve_infoResponse/ve'))
{
    print "veid[".$i->{veid}."]"                     if $i->{veid};
    print " status=[".$i->{status}->{state}. "]"     if $i->{status}->{state};
    print " base_set=[".$i->{config}->{base_set}."]" if $i->{config}->{base_set};
    print " ip=[".$i->{config}->{ip}."]"             if $i->{config}->{ip};
    print "\n";
}

1348db476c8a5844ffbef8d503db9c15 965b49118115a610e93635d21c5694a8 d02f9caf3e11b191a38179103495106f 2897d76d56d2010f4e3a28f864d69223

Email subscription for changes to this article
Save as PDF