Project Links

Recommended Books

Donate


Unlocking 0.65: Direct access to the HTTP::Request and HTTP::Response objects

I had no idea what I was getting myself into when I said I would take the reigns of the SOAP::Lite project. SOAP::Lite is an extensive module that feels like it grew quite organically. It is infused with some of the most creative Perl I have ever seen, and it took me two years of sporadic and at times intense development to even begin to unravel and make sense of the code. As a result, most SOAP::Lite releases have focused on areas of code which I was already intimately familiar, i.e. the MIME section, or with relatively minor bug fixes. But with 0.65 I pledged to tackle some of the issues that have long frustrated me. Over the next couple of weeks I will introduce a series of articles that explores some of the enhancements I have made to SOAP::Lite 0.65.

Continue reading "Unlocking 0.65: Direct access to the HTTP::Request and HTTP::Response objects" »

Intercepting the request and/or response before and after processing

A common question in the SOAP::Lite Newsgroup is about intercepting the request prior to handling, and the response prior to it being returned. SOAP::Lite v0.65 enables this on the client side pretty easily using the http_request and http_response methods on SOAP::Transport::HTTP::Client, but the server side is still a relative black art. I have friends who have used SOAP::Trace to log, or write to a file, the SOAP payload, but that is not entirely sufficient for all their needs. In future versions, SOAP::Lite will introduce the concept of handler chains, similar to Java Servlets, but for now, one still needs to do a little more work. The following code sample shows how one can extend SOAP::Transport::HTTP:CGI to intercept both the HTTP request and the HTTP response prior to it being processed and/or returned respectively.

Continue reading "Intercepting the request and/or response before and after processing" »

Setting HTTP Timeouts for a SOAP client

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.

Don't Hate the Ads

Recent Comments

Recent Posts

Blog powered by TypePad