Loading ...
Sorry, an error occurred while loading the content.

Re: SOAP using Daemon

Expand Messages
  • Paul Kulchenko
    Hi, Garrett! ... It s the same Demo.pm as in 3.b example ( http://guide.soaplite.com/#service dispatch (different services on one server) ). ... That example
    Message 1 of 1 , May 1, 2001
    • 0 Attachment
      Hi, Garrett!

      > o it doesn't include the Demo.pm file
      It's the same Demo.pm as in 3.b example
      ('http://guide.soaplite.com/#service dispatch (different services on
      one server)').

      > o it never sets $daemon to anything...
      That example is wrong, I'm about to fix it. Correct example is:

      my $daemon = SOAP::Transport::HTTP::Deamon
      -> new (LocalPort => 80)
      -> dispatch_to('/home/soaplite/modules')
      ;

      > o has no complimentary client example
      nothing is changed on client side. You may use whatever client
      example you have, changing only proxy(). For example:

      >perl SOAPsh.pl http://localhost/ http://my.uri/Demo hi bye

      -- or --

      use SOAP::Lite;

      print SOAP::Lite
      -> proxy('http://localhost/')
      -> uri('http://my.uri/Demo')
      -> hi
      -> result;


      Considering your examples:

      > #!perl -w
      > use SOAP::Transport::HTTP;
      > my $daemon = SOAP::Transport::HTTP::Daemon
      > -> new (LocalPort => 4980)
      > -> dispatch_to('longecho');
      > print "Contact to SOAP server at ", $daemon->url, "\n";
      > $daemon->handle;
      >
      > sub longecho {
      > shift;
      > return join '', "echo says: ", echo(@_);
      -----------------------------------^^^^^^^^ there is no echo()
      function availabe. Just make:
      return join '', "echo says: ", @_;
      > }
      > 1;

      And you need to run your daemon code with

      perl name_of_your_daemon.pl

      Client:

      > use SOAP::Lite;
      > my $host = 'my_computer_name';
      > my $port = 4980;
      > my $proxy = "http://$host:$port/";
      > my ($s, $r);
      >
      > $s = SOAP::Lite
      > ->uri('http://my.site/') # <<<<<<< here is the difference
      > ->proxy($proxy)
      > ->on_fault(sub{});
      > $r = $s->test_connection;
      > unless (defined $r && defined $r->envelope) {
      > print "Skip: ", $s->transport->status, "\n";
      > exit;
      > }
      >
      > my $hi = $s->call('echo', {a => 1, b => 2})->result || '';
      > print "hi: $hi\n";
      > 1;

      Should work now, but it'll return you HASH, so you should see HASH on
      the screen.

      Better use SOAPsh.pl to see:

      perl SOAPsh.pl http://localhost:4980/ http://my.site/
      "echo({a=>1,b=>2})"

      Hope it helps.

      Best wishes, Paul.

      --- Garrett Goebel <garrett@...> wrote:
      > Admittedly... I'm at about sea level on the SOAP learning curve.
      >
      > I'm looking for a simple example of a SOAP HTTP daemon and
      > complimentary
      > client. Something that will execute on the local host and allow me
      > to begin
      > tinkering toward enlightenment.
      >
      > Your tutorial lists an example HTTP daemon server
      >
      > #!perl -w
      > use SOAP::Transport::HTTP;
      > use Demo;
      >
      > # don't want to die on 'Broken pipe' or Ctrl-C
      > $SIG{PIPE} = $SIG{INT} = 'IGNORE';
      > SOAP::Transport::HTTP::CGI
      > -> new (LocalPort => 80)
      > -> dispatch_to('/home/soaplite/modules')
      > ;
      > print "Contact to SOAP server at ", $daemon->url, "\n";
      > $daemon->handle;
      > __END__
      >
      >
      > But:
      > o it doesn't include the Demo.pm file
      > o it never sets $daemon to anything...
      > o has no complimentary client example
      >
      >
      > I culled the following example from the mailing list:
      >
      > #!perl -w
      > use SOAP::Transport::HTTP;
      > my $daemon = SOAP::Transport::HTTP::Daemon
      > -> new (LocalPort => 4980)
      > -> dispatch_to('longecho');
      > print "Contact to SOAP server at ", $daemon->url, "\n";
      > $daemon->handle;
      >
      > sub longecho {
      > shift;
      > return join '', "echo says: ", echo(@_);
      > }
      > 1;
      > __END__
      >
      >
      > Could you provide a complimentary Client example? Or alternatively
      > explain,
      > what is wrong with this? Note: I'm using WinNT 4.0 sp6a w/ AS Perl
      > 623.
      >
      > use SOAP::Lite;
      > use SOAP::Transport::HTTP;
      > my $host = 'my_computer_name';
      > my $port = 4980;
      > my $proxy = "http://$host:$port";
      > my ($s, $r);
      >
      > $s = SOAP::Lite
      > ->uri($proxy)
      > ->proxy($proxy)
      > ->on_fault(sub{});
      > $r = $s->test_connection;
      > unless (defined $r && defined $r->envelope) {
      > print "Skip: ", $s->transport->status, "\n";
      > exit;
      > }
      >
      > my $hi = $s->call('echo', {a => 1, b => 2})->result || '';
      > print "hi: $hi\n";
      > 1;
      > __END__
      >
      >
      > When I try it, $hi is always '';
      >
      > Also, if I bother to check $s->transport->status when (defined $r
      > and
      > defined $r->envelope), it returns "500 Internal Server Error". This
      > doesn't
      > seem right.
      >
      > thanks,
      >
      > Garrett
      >
      >


      __________________________________________________
      Do You Yahoo!?
      Yahoo! Auctions - buy the things you want at great prices
      http://auctions.yahoo.com/
    Your message has been successfully submitted and would be delivered to recipients shortly.