[Xml-compile] Async HTTP SOAP requests

Mark Overmeer mark at overmeer.net
Fri Oct 8 08:29:52 GMT 2010


* Aleksey Mashanov (aleksey.mashanov at gmail.com) [101008 00:05]:
> I'm writting a daemon, which operate on large amount of SOAP-connections to
> different servers. So I want all HTTP-request to be done asynchronously
> using AnyEvent::HTTP.

You are afraid to start hundreds of processes?  Don't bother! Event-driven
programming is a very different style of programming which does never
come easy. You like a challange?

I have used IO::Multiplex (based in IO::Select) to implement an single
process multi-client webserver in HTTP::Server::Multiplex.  Of course,
it is possible to program event-driven.

> Of cource, I can compile sender and receiver
> separatelly and do HTTP-request manually, but it's ugly. Can we integrate
> async-calls support to XML::Compile::SOAP? In my mind these modifications
> will be quite enougth:
> 1. Add to XML::Compile::SOAP::Client->compileClient() argument "async". If
> it's true, then compiled subroutine must accept "callback" parameter and
> call it with results of request instead of returning them from sub.

Any parameter which you pass to compile client will be passed to all
the objects it creates. So that is just a documentation issue.

> 2. The same ability to XML::Compile::Transport

No, the option is only needed to the extension which extends the
transporter, so no need to add it to the base class.

> 3. Add to XML::Compile::Transport::SOAPHTTP (or some subclass)
> abillity to make requests through AnyEvent::HTTP.

The SOAPHTTP transporter is based on LWP, which on itself is not
event-driven.  Probably the easiest way for you to start is:

   package XML::Compile::Transport::AsyncSOAPHTTP;
   use base 'XML::Compile::Transport::SOAPHTTP';

   # your sync is registered later than the base
   __PACKAGE__->register(SOAP11HTTP);

   sub userAgent(...)
   {   # replace use of LWP with your async version
   }
   1;

   #main program
   use XML::Compile::Transport::AsyncSOAPHTTP;

That's all you need: just create a new transporter. Most of the
async-callback handling can be hidden within this module.

If you need some methods of Transport::SOAPHTTP or ::Transport to be
split-up to reduce your code, it is negotiable. I am interested in adding
(the logic of) your code to the XML::Compile suite.
-- 
Regards,

               MarkOv

------------------------------------------------------------------------
       Mark Overmeer MSc                                MARKOV Solutions
       Mark at Overmeer.net                          solutions at overmeer.net
http://Mark.Overmeer.net                   http://solutions.overmeer.net



More information about the Xml-compile mailing list