Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For the server script, the dispatch_to method takes the path to the package to load, and the name of the package itself. If you pass a third parameter, it will limit the names of the methods made visible by the server. (e.g. 2 methods named <code>memory</code> and <code>time</code>, passing <code>Demo::time</code> as the 3rd param will make <code>memory</code> invisible to the client service.)</p> <p>File server.pl</p> <pre><code>my $daemon = SOAP::Transport::HTTP::Daemon -&gt; new (LocalPort =&gt; 801) -&gt; dispatch_to('/home/soaplite/modules', 'Demo') ; </code></pre> <p>Your Demo package should be a package with methods that return the values. I couldn't get Sys::MemInfo compiled on my system, so I just used localtime instead. I'm not sure why you named your package Demo.py, but Perl packages must have the extension pm, otherwise they won't be properly loaded.</p> <p>File Demo.pm</p> <pre><code>#!/usr/bin/perl package Demo; #use Sys::MemInfo qw(totalmem freemem totalswap); sub memory { #print "total memory: ".(&amp;totalmem / 1024)."\n"; return "Can't load Sys::MemInfo, sorry"; } sub time { my $time = localtime; return $time; } 1; </code></pre> <p>For the client code, there's 2 important pieces that must be properly specified to work, the <code>proxy</code> and the <code>uri</code>. The proxy is the url path to the soap web service. Since you are running the server script as a daemon process, your path is just the web site's url. My computer doesn't have a url, so I used <code>http://localhost:801/</code>. The 801 is the port you specified above. If you were running as a cgi script inside of a different web server (such as Apache), then you would need to specify the cgi script to call (e.g. <code>http://localhost/cgi-bin/server.pl</code>, changing the package in server.pl to <code>SOAP::Transport::HTTP::CGI</code>.</p> <p><code>uri</code> is probably the most confusing, but it's the namespace of the xml files returned by the web service. Turn on <code>+trace =&gt; 'debug'</code> to see the xml file returned by the web service. The uri should just be the name of the server. Even if you switch ports or to a cgi dispatch method, this uri stays the same. </p> <p>File test.pl</p> <pre><code>#!perl -w use SOAP::Lite +trace =&gt; 'debug'; # Frontier http://www.userland.com/ $s = SOAP::Lite-&gt;new(proxy =&gt; 'http://superhonker.userland.com:801/', uri =&gt; 'http://superhonker.userland.com/'); #might be http://www.userland.com/ #but I could not test sub-domains print $s-&gt;time()-&gt;result; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload