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

Hi

Im trying to set up a soap server uing http daemon instead of the cgi kind. And im having some problems. here is the code for my server:

use Demo; use SOAP::Transport::HTTP; my $daemon = SOAP::Transport::HTTP::Daemon -> new (LocalPort => 9091) -> dispatch_to('/perl/site/lib') ; print "Contact to SOAP server at ", $daemon->url, "\n"; $daemon->handle;

and the code for the client

use SOAP::Lite; print SOAP::Lite -> uri('http://localhost/') -> proxy('http://localhost::9091') -> hi() -> result;

Ok, I know it connect to the server ok, because when the server is not running it gives me an error that it can't find it and times out. But it is not finding my Demo package that i wrote. It is located in "c:\perl\site\lib" . i think i am messing up the dispatch_to part. I have tried different combinations of directories but nothings seems to work.

one thing that might make a difference is that my program in on the e: drive. But when i changed it over to the c: it still didn't work. Any Help will be greatly apprecaite I new at Perl and trying to learn as much as possible. Thanks !

Replies are listed 'Best First'.
(jeffa) Re: dispatch_to problems setting up soap server
by jeffa (Bishop) on Aug 09, 2001 at 22:50 UTC
    Funny, i am having the same problem as well . . . i have been following the tutorials at perl.com with moderate success, but the Daemon part is confusing me.

    One thing i tried was to include the path where the modules are stored before using Demo:

    use lib qw(/perl/site/lib); use Demo;
    but this seems . . . wrong. I'll be working on this for the rest of the day, if i find some answers i'll update this node. In the meantime, maybe a SOAP::Lite guru will wander into this thread.

    UPDATE:
    shotgunefx has the right answer. This tutorial clearly states to use the package, even though you don't need to. If you try my suggestion, the daemon server will run, but clients will not be able to successfully communicate with it (why i don't know yet). Here is my server:

    use strict; use SOAP::Transport::HTTP; my $daemon = SOAP::Transport::HTTP::Daemon -> new (LocalPort => 8080) -> dispatch_to('/usr/local/apache/soap') ; print "Contact to SOAP server at ", $daemon->url, "\n"; $daemon->handle;
    (Demo.pm is located in /usr/local/apache/soap) and here is the client:
    use SOAP::Lite; my $soap = SOAP::Lite ->uri('http://neo.acymtech.com/Demo') ->proxy('http://neo.acymtech.com:8080');
    Cool! SOAP rules!!

    perl -le '$x="jeff";$x++ for(0..4482550);print $x'

Re: dispatch_to problems setting up soap server
by shotgunefx (Parson) on Aug 09, 2001 at 22:59 UTC
    I don't think you should have
    use Demo;
    And I believe dispatch_to should have the Package name to dispatch. Below is the example from soaplite.com

    #!perl -w # -- SOAP::Lite -- guide.soaplite.com -- Copyright (C) 2001 Paul Kulch +enko -- use SOAP::Transport::HTTP; SOAP::Transport::HTTP::CGI -> dispatch_to('Demo') -> handle; package Demo; sub hi { return "hello, world"; } sub bye { return "goodbye, cruel world"; } sub languages { return ("Perl", "C", "sh"); }
    -Lee

    "To be civilized is to deny one's nature."
      HI

      Thanks for the information

      But what if i want to use packages that i have already wrote ie) use test::world; . I was reading some where that you could set it up so that it could dispatch to a directory where the modules that you worte were.

      dispatch_to( 'PATH/', # dynamic: load anything from there, any module, + any method 'MODULE', # static: any method from this module 'MODULE::method', # static: specified method from this module 'method', # static: specified method from main:: );

      I found this on line telling me how i can specify what method I want. Does any one know if i have a syntax error? Thanks for the Help

        You're right. I think the problem may be with the client.

        From soaplite cookbook:
        Dynamic

        As you can see in both Static internal and Static external modes the name of the module is hardcoded in the server's code. But what if you want to be able to add new modules dynamically without changing the code? Dynamic dispatch allows you to do that. Specify the directory and any module in this directory becomes available for dispatching: 3.c. server (Dynamic) (hibyedyn.cgi)
        #!perl -w use SOAP::Transport::HTTP; SOAP::Transport::HTTP::CGI -> dispatch_to('/home/soaplite/modules') -> handle;
        Then put Demo.pm in /home/soaplite/modules directory:

        That's it. The any module you put in /home/soaplite/modules is now available, but don't forget that the URI on the client side should match the module/class name you want to dispatch your call to.

        Hope this helps.

        -Lee

        "To be civilized is to deny one's nature."