The HTTP layer is abstracted away from the developer in SOAP::Lite. But knowing a few simple things about how SOAP::Lite was written can help open up a lot of functionality. For example, many users are not clear about how to set the HTTP timeout for a given request. Let's take a look at some sample code that allows a user to do this:
my $soap = SOAP::Lite
->uri($uri)
->proxy($proxyUrl, timeout => 5 );
print "timeout: ".$soap->proxy->timeout."\n";
$soap->proxy->timeout(100);
print "timeout: ".$soap->proxy->timeout."\n";
print $soap->c2f(SOAP::Data->name('temperature' => 100));
This code works because SOAP::Lite->proxy returns an instance of the current transport layer/client. And in SOAP::Lite, the HTTP client transport layer (SOAP::Transport::HTTP::Client class) extends LWP::UserAgent. Therefore, all methods available in LWP::UserAgent are also available to users of SOAP::Lite's SOAP::Transport::HTTP::Client class. Which includes the timeout subroutine.
Comments