Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

I do not understand how to write a SOAP server.

by Plankton (Vicar)
on Mar 25, 2012 at 02:57 UTC ( [id://961455]=perlquestion: print w/replies, xml ) Need Help??

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

Dear Monks,

I am trying to understand the sample code that is used to document SOAP::Transport::HTTP. Shown here:

#!/usr/bin/perl -w use strict; use Data::Dumper; use SOAP::Transport::HTTP; # change LocalPort to 81 if you want to test it with soapmark.pl my $daemon = SOAP::Transport::HTTP::Daemon -> new (LocalAddr => 'localhost', LocalPort => 81) # specify list of objects-by-reference here -> objects_by_reference(qw(My::PersistentIterator My::SessionItera +tor My::Chat)) # specify path to My/Examples.pm here -> dispatch_to('/Your/Path/To/Deployed/Modules', 'Module::Name', ' +Module::method') ; print "Contact to SOAP server at ", $daemon->url, "\n"; $daemon->handle;
Here is the output I get when I execute it:
$ sudo ./soap_server.pl Contact to SOAP server at http://localhost:81/
I really do not know what is suppose to happen but I did find the perl script perlmark.pl that is suppose to test soap servers. Here is the modified version of perlmark.pl I am running:
$ cat perlmark.pl #!/usr/bin/perl -w #!d:\perl\bin\perl.exe # -- SOAP::Lite -- soaplite.com -- Copyright (C) 2001 Paul Kulchenko - +- use strict; use Benchmark; use SOAP::Lite on_fault => sub {my($soap, $res) = @_; die ref $res ? $ +res->faultdetail : $soap->transport->status, "\n"}; #use My::Examples; my %dests = ( # local => ['local://localhost/cgi-bin/soap.cgi' => 'htt +p://www.soaplite.com/My/Examples'], # mod_perl => ['http://localhost/soap/' => 'http://www.soap +lite.com/My/Examples'], # CGI => ['http://localhost/cgi-bin/soap.cgi' => 'http +://www.soaplite.com/My/Examples'], daemon => ['http://localhost:81/' => 'http://www.soaplit +e.com/My/Examples'], # daemon => ['http://localhost:81/' => 'http://www.soapli +te.com/My/Examples'], # 'Apache::Registry' => ['http://localhost/mod_perl/soap.mod_cgi' => +'http://www.soaplite.com/My/Examples'], # tcpip => ['tcp://localhost:82' => 'http://www.soaplite +.com/My/Examples'], # direct => ['' => 'My::Examples'], ); my $s; my %tests = ( simple => sub {$s->getStateName(1)}, array => sub {$s->getStateName((1) x 100)}, string => sub {$s->getStateName(1 x 100)}, ); my $testnum = 3; my $testtime = 5; my %result; print STDERR <<DISCLAIMER; This test should be used only for comparison different Perl server implementations running in your environment. DISCLAIMER print STDERR "All tests may take up to ", keys(%dests) * keys(%tests) +* $testnum * $testtime, " sec\n"; foreach my $dest (keys %dests) { my($proxy, $uri) = @{$dests{$dest}}; $s = $proxy ? SOAP::Lite->proxy($proxy)->uri($uri) : $uri; foreach my $test (keys %tests) { printf STDERR "%s [%s] ", $dest, $test; eval {$tests{$test}->()}; warn('skipped, ', $@), next if $@; my($tps) = 0; for (1..$testnum) { my $r = Benchmark::countit($testtime => $tests{$test}); my($pu, $ps, $n) = @{$r}[1,2,5]; $tps += $n / ($pu + $ps); print STDERR "."; } printf STDERR " %.5s call/s\n", $result{$dest}{$test} = $tps / $te +stnum; } }
When execute perlmark.pl I get this output:
$ ./perlmark.pl This test should be used only for comparison different Perl server implementations running in your environment. All tests may take up to 45 sec daemon [array] skipped, daemon [simple] skipped, daemon [string] skipped,
Why is it skipping tests? I suspect it has something to do with this bit of the server code ...
# specify list of objects-by-reference here -> objects_by_reference(qw(My::PersistentIterator My::SessionItera +tor My::Chat)) # specify path to My/Examples.pm here -> dispatch_to('/Your/Path/To/Deployed/Modules', 'Module::Name', ' +Module::method')
... what are object-by-reference and what are "Deploy Modules"? I am certain that there are many Monks here that can enlighten me. THANKS!

Replies are listed 'Best First'.
Re: I do not understand how to write a SOAP server.
by Khen1950fx (Canon) on Mar 25, 2012 at 08:21 UTC
    I stopped using SOAP::Lite when my ISP totally broke my localhost. How they managed to do that is beyond me, but I thought that I'd give it another try. Here's the server:
    #!/usr/bin/perl use strict; use warnings; use SOAP::Transport::HTTP; my $daemon = SOAP::Transport::HTTP::Daemon->new( 'LocalAddr' => 192.5.6.30, 'LocalPort' => 81, 'Reuse' => 1, 'Listen' => 128 )->objects_by_reference( qw( My::Stuff) )->dispatch_to( '/Your/Path/To/Deployed/Modules', 'Module::Name', 'Module::method' ) ->options( { compress_threshold => 10000 } ); print "Contact to SOAP server at ", $daemon->url, "\n"; $daemon->handle;
    Here's the client:
    #!/usr/bin/perl -l use strictures 1; no strict qw/refs subs/; no warnings qw/uninitialized deprecated/; use SOAP::Test; SOAP::Test::run_for('http://192.5.6.30:81'); use SOAP::Lite +autodispatch => 'uri' => 'http://192.5.6.30:81', 'proxy' => 'http://www.example.com', 'on_fault' => sub { my ( $soap, $res ) = @_; print ref $res ? print $res->faultdetail : print $soap->transport->status; };
    It returns "200 OK, 1". I hope that it works for you:).
Re: I do not understand how to write a SOAP server.
by Anonymous Monk on Mar 25, 2012 at 07:58 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 10:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found