Perl SOAP :: Lite and service description for requesting an object

I am using Perl SOAP::Lite to access a remote web service defined by WSDL. This means that I have:

 use strict; use Data::Dumper; use SOAP::Lite +trace => 'debug'; my $service = SOAP::Lite->service('http://path/wsdl'); 

Good. The problem is that I need access to the HTTP::Request object to send custom headers for HTTP requests (and I'm not talking about authentication headers). It looks like I can access the request object after a successful call:

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

This will 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 autoDispatch (part of $service->getClient ), the transport object is empty and I have no way to change the request. It seems that everything will work fine if I go the SOAP::Lite->proxy path, but this will defeat the usefulness of defining a predefined service.

Any ideas on how I intend to access the request object from the service definition without first making calls? The problem with the chicken and the egg is really ...

Thanks!

+6
source share
2 answers

What I'm trying to do is populate the transport before making a service call.

And you do just that , adding the appropriate handler, because the transport is not empty.

+1
source

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

0
source

Source: https://habr.com/ru/post/894890/


All Articles