sub build_SOAP_connection { my $self = shift; my $ns = $self->{'data'}->{'namespace'}; my $ep = $self->{'data'}->{'proxy'}; my $lite = SOAP::Lite->uri($ns)->proxy($ep)->on_action( sub { join "", @_ } ); $lite->autotype(0); $lite->soapversion('1.1'); $lite->serializer()->namespaces({ 'http://schemas.xmlsoap.org/soap/envelope/' => 'soap', 'http://schemas.xmlsoap.org/soap/envelope/' => 'soapenv', 'http://schemas.xmlsoap.org/soap/encoding/' => 'soapenc', 'http://www.w3.org/2001/XMLSchema' => 'xsd', 'http://www.w3.org/2001/XMLSchema-instance' => 'xsi' }); $self->{'SOAP'} = $lite; return $lite; } sub SOAP_execute { my $self = shift; my $method = shift; my $datagram = shift; my $SOAP; if (exists($self->{'SOAP'})) { $SOAP = $self->{'SOAP'}; } else { $SOAP = $self->build_SOAP_connection(); } my $doc = SOAP::Data->name($method)->uri($self->{'data'}->{'namespace'})->prefix(''); my $response; eval { $response = $SOAP->call($doc => $datagram); }; if ($@) { print "Error: $method SOAP call died: $@.\n"; return 1; } if ($response->fault) { print "Fault code: ", $response->faultcode, "\n"; print "Fault string: ", $response->faultstring, "\n"; print "Fault actor: ", $response->faultactor, "\n"; return $response->faultcode; } else { my $body = $response->result; # returns the first object unless ($body == 0) { $self->{'data'}->{'ERROR'} = "ERROR: method $method failed: $body"; } return $body; } }