Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl SOAP::Lite and Service Description to Request Object

I'm using Perl's SOAP::Lite to access a remote web service defined by a WSDL. That means I have:

use strict;
use Data::Dumper;
use SOAP::Lite +trace => 'debug';

my $service = SOAP::Lite->service('http://path/wsdl');

Ok so far. Problem is that I need access to the HTTP::Request object to send along custom HTTP request headers (and I'm not talking about authentication headers). It looks like I can access the request object after doing a successful call:

my $result = $service->getClient('parameters');
print Dumper($service->transport->http_request);

That'll give me the correct HTTP::Request object:

$VAR1 = bless( {
             '_content' => '',
             '_uri' => undef,
             '_headers' => bless( {}, 'HTTP::Headers' ),
             '_method' => undef
           }, 'HTTP::Request' );

If I try to access the request object before doing an autoDispatch (the $service->getClient part), the transport object is empty and I have no way of modifying the request. It seems like everything would work fine if I were going the SOAP::Lite->proxy way -- but that defeats the helpfulness of having a pre-defined service definition.

Any ideas how I'm suppose to access the request object from a service definition without first having to make a call? Chicken and egg problem really...

Thanks!

like image 501
jtv4k Avatar asked Aug 12 '11 01:08

jtv4k


People also ask

What is soap Lite?

DESCRIPTION. SOAP::Lite is a collection of Perl modules which provides a simple and lightweight interface to the Simple Object Access Protocol (SOAP) both on client and server side.

How do you call a SOAP web service in Perl?

Bookmark this question. Show activity on this post. I am calling SOAP web services by using Perl with the SOAP::Lite module as follows: my $soap = SOAP::Lite->on_action( sub { join '/', @_ } ) ->readable( 1 ) ->uri( $uri ) ->proxy( $proxy ) ->ns( $ns ); $soap->call( 'method' => ( SOAP::Data->name( ... ) ) );


1 Answers

What I'm trying to accomplish is populating the transport before doing a service call.

And you do exactly that by adding the appropriate handler, because the transport is not empty

like image 76
asdf Avatar answered Oct 16 '22 20:10

asdf