SOAP

Client

use warnings;
use strict;
 
use SOAP::Lite;
use Getopt::Long;
use Data::Dumper;
 
my $opt  = {};
 
GetOptions($opt,
        'server=s',
        'command=s',
        'urn=s',
);
 
my $NS     = "urn:". ($opt->{urn} || "SOAPServer::Handler");
my $HOST = 'http://'.$opt->{server};
 
my $soap = SOAP::Lite
  ->readable(1)
  ->uri($NS)
  ->proxy($HOST);
 
my $soapd = new SOAP::Data->type(hash => $opt);
my $som = $soap->command($soapd);
 
print Dumper $som->result;

Server

apache config

Listen 8088
<VirtualHost _default_:8088>
  DocuemtRoot    /var/www/
  ServerName     soap
  ErrorLog       /var/log/apache2/soap_error.log
  TransferLog    /var/log/apache2/soap_transfer.log
  <Location /soap>
        SetHandler perl-script
        PerlHandler Apache2::SOAP
        PerlSetVar dispatch_to SOAPServer::Handler
  </Location>
</VirtualHost>

handler script

package SOAPServer::Handler;
 
use SOAP::Lite;
 
sub command {
  my ($class, $soap_hash) = @_;
  $data = SOAP::Data->new;
  $data->type(hash => {result => 'hiho'});
  print STDERR "huhu\n";
  return $data;
}
 
1;
 
wiki/soap.txt · Last modified: 10.08.2011 23:57 by root