[Xml-compile] getting started with XML-Compile

Dave Howorth dhoworth at mrc-lmb.cam.ac.uk
Mon Aug 23 09:50:59 GMT 2010


Mark Overmeer wrote:
> * Ted Pedersen (duluthted at gmail.com) [100822 16:35]:
>> My goal is to allow remote users to call the methods that are
>> available in the module in more or less the same way they would use
>> them if they had the module locally installed.
> 
> Typical Client-Server wish.
> 
>> Is this something that would be reasonable to do with XML::Compile,
>> and if so, are there any examples of how to take an existing module
>> and "convert it" into something that will run as I'm describing?
> 
> For client-server applications, you need at leaset the following:
> 
>   server functionality     (your current code)
>   server protocol-adapter
>          messages
>   client protocol-adapter
>   client code
> 
> First you need to design your messages.
[snip]

I fully agree with what Mark said in terms of good design and
cross-language usability. But I thought I should point out that if you
only care about Perl and you're willing to accept hackery, TIMTOWTDI.

It's possible to hack together a module that will wrap any other module
and turn it into a server that exports all its methods, and a companion
module that imports the methods into a client application. There's no
need to have any knowledge of what passes over the wire.

I rough coded a pair of modules like this to help my testing. They have
some restrictions on method signatures (e.g. passing references) and you
need to think about round trips when designing server methods in order
to get acceptable performance. OTOH, it's also possible to dynamically
migrate client methods to the server and execute them there.

I can post them if there's any interest. They use SOAP::Lite for
historical reasons.

Cheers, Dave

# server

  use SoapDaemon (
      class   => 'Some::Class',
      debug   => 1,
      init    => \&init_server,
      inject  => { root => \&root },
      options => { LocalAddr => 'serverhost', LocalPort => 81 },
  );


# client

  use SoapClient (
      class   => 'Some::Class',
      url     => 'http://serverhost:81/url',
      );

  # Now we can use methods in the remote class and remote objects
  $remote_obj = Some::Class->some_existing_method( some => $args );
  $remote_obj->some_other_existing_method;




More information about the Xml-compile mailing list