6

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!

RobEarl
  • 7,862
  • 6
  • 35
  • 50
jtv4k
  • 224
  • 2
  • 7

2 Answers2

1

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

asdf
  • 11
  • 1
0

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

vayay
  • 86
  • 2
  • Unfortunately, the transport is empty until I do a call. If I had access to the transport, I'd have access to the headers. What I'm trying to accomplish is populating the transport before doing a service call. – jtv4k Aug 15 '11 at 16:57