jtv4k
jtv4k

Reputation: 224

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!

Upvotes: 6

Views: 826

Answers (2)

asdf
asdf

Reputation: 11

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

Upvotes: 1

vayay
vayay

Reputation: 86

Add a handler to the transport, see LWP::Debug for example, see LWP::UserAgent for documentation, or perlmonks.org/?node_id=904166 for example

Upvotes: 0

Related Questions