Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

SOAP::Lite games.

by rfb (Sexton)
on Oct 24, 2001 at 00:43 UTC ( #120902=perlquestion: print w/replies, xml ) Need Help??

rfb has asked for the wisdom of the Perl Monks concerning the following question:

my journeys into soap have been quite sucessful lately, until I ran into this wall..
the soap service:
use strict; use SOAP::Transport::HTTP; my $daemon = SOAP::Transport::HTTP::Daemon->new (LocalAdd => 'localhost', LocalPort => 8082); $daemon->dispatch_to("BenderRemote")->handle; package BenderRemote; sub ping { print "ping called\n"; return scalar(localtime()); } sub new { my ($pkg) = @_; print "new!\n"; my $self = {}; return bless $self, $pkg; } sub loadData { my ($self) = @_; print "loaddata!\n"; $self->{data} = "fobars"; return 1; }
and my client script:
use strict; use Data::Dumper; use SOAP::Lite; my $soap = SOAP::Lite ->uri("http://host/BenderRemote") ->proxy("http://host:8082"); my $br = $soap->call("new")->result(); $br->loadData(); print Dumper $br;
It seem to be having trouble running the second method, which I'm not starting via call()..
any input?

Replies are listed 'Best First'.
Re: SOAP::Lite games.
by jwest (Friar) on Oct 24, 2001 at 01:38 UTC
    You might want to look at the autodispatch functionality of SOAP::Lite. It will set up an AUTOLOAD for you that should dispatch the method over the SOAP link.

    Hope this helps!


    -><- -><- -><- -><- -><-
    All things are Perfect
        To every last Flaw
        And bound in accord
             With Eris's Law
     - HBT; The Book of Advice, 1:7
      use strict; use Data::Dumper; use SOAP::Lite +autodispatch=> uri=>("http://host/BenderRemote"), proxy=>("http://host:8082"); my $br = BenderRemote->new(); $br->loadData(); print Dumper $br;
      works prefectly, makes my code simpler too, thanks jwest!

Re: SOAP::Lite games.
by rfb (Sexton) on Oct 24, 2001 at 02:30 UTC
    my perception of soap: the object is created and maintained on the service side, and the client would just make calls and get results.. is this correct?

      Basically, yes. The real object lives on the server and its code is executed there. You get a handle (sometimes called a proxy object since it stands in as the proxy for the real, remote instance) on the client side that takes care of marshalling the arguments (rolling them up into the XML wire format) and getting them sent to the server where the actual method runs. Any return value is again marshalled back into XML and returned to the caller, which turns things back into perl values.

        Actually, I'm not sure that's true. I don't believe the object really exists on the server side. When I call methods on my local object, it looks like SOAP::Lite is sending the state of the object via XML each time, and the server then bless's that object, and calls the method on it. Also, you can run a SOAP::Lite server via a simple CGI transport. If you are running CGI with Apache, those "servers" are all running in different processes. How could it maintain a persistent object across multiple processes? -Mike

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://120902]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (2)
As of 2021-11-28 11:37 GMT
Find Nodes?
    Voting Booth?

    No recent polls found