Click to See Complete Forum and Search --> : Using Perl and Soap SOAP::Lite


Mike Burdick
10-07-2005, 01:49 PM
Hi,

I'm just starting with SOAP, so I went to the `net to see if I could
find an example to get something to work.

Okay here's what I did. I have three files and I put them on my
website server and put them in the directories stated:

File Hello.pm - Put this in directory /lib

# Hello.pm - simple Hello module
package Hello;
sub sayHello {
shift; # remove class name
return "Hello " . shift;
}
1;

File helloworld.cgi – Put this in directory /cgi-bin

#!/usr/bin/perl -w

# helloworld.cgi - Hello SOAP handler
use lib '/lib';
use SOAP::Transport::HTTP;
SOAP::Transport::HTTP::CGI
dispatch_to('Hello::(?:sayHello)')
-> handle
;

File hw_client.pl - Put this in directory /cgi-bin

#!/usr/bin/perl -w

# hw_client.pl - Hello client
use SOAP::Lite;
my $name = shift;
print "\n\nCalling the SOAP Server to say hello\n\n";
print "The SOAP Server says: ";
print SOAP::Lite
-> uri('urn:Example1')
-> proxy('http://localhost/cgi-bin/helloworld.cgi')
-> sayHello($name)
result . "\n\n";

The original example came from:

http://aspn.activestate.com/ASPN/docs/ActivePerl/5.8/site/lib/SOAP/Lite.html

When I run hw_client it doesn't do what it should. Does anyone know
what my problem is?

Any help would be appreciated!

Mike

Ultimater
10-07-2005, 02:18 PM
The module is non-standard and will need to be installed on your server.
Here is the module on CSPAN:
http://search.cpan.org/~byrne/SOAP-Lite-0.60a/lib/SOAP/Lite.pm
Here is the source of Lite.pm: (which can be found in the above link)
http://search.cpan.org/src/BYRNE/SOAP-Lite-0.60a/lib/SOAP/Lite.pm

Do you know how to install it on your server? If not, creating a directory called "SOAP" in each directory that uses the module and uploading the file "Lite.pm" into it can substitute for now.

Anyways, you should be using the CGI module and "fatalsToBrowser" so you can catch errors like that when a module isn't found rather than an "internal serer error" error which doesn't help you at all.

use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);

Ultimater
10-07-2005, 02:27 PM
Oh yeah, and for the module SOAP::Transport::HTTP
http://search.cpan.org/~byrne/SOAP-Lite-0.60a/lib/SOAP/Transport/HTTP.pm
source:
http://search.cpan.org/src/BYRNE/SOAP-Lite-0.60a/lib/SOAP/Transport/HTTP.pm

That should be all the modules you will need to install, the rest of the module are standard.

Mike Burdick
10-07-2005, 03:06 PM
Ultimater,

SOAP::Lite is already installed on my server!

Can you see why the example given doesn't work for me. Here's the link to the example again.

http://www.oreilly.com/catalog/progwebsoap/chapter/ch03.html

Thanks for the help, I really appreciate it!!!

Do you know of any other sites that have some examples I could try?

Mike

Ultimater
10-07-2005, 03:19 PM
It's hard to work without knowing what's wrong, give this a test and tell me what errors it encounters when run:

Example 3-5: hw_client.pl

#!/usr/bin/perl -w
# hw_client.pl - Hello client
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use SOAP::Lite;
print header;
my $name = shift;
print "\n\nCalling the SOAP Server to say hello\n\n";
print "The SOAP Server says: ";
print SOAP::Lite
-> uri('urn:Example1')
-> proxy('http://localhost/cgi-bin/helloworld.cgi')
-> sayHello($name)
-> result . "\n\n";

Mike Burdick
10-07-2005, 03:29 PM
Ultimater,

Okay, I ran what you gave me and here is the output:

Calling the SOAP Server to say hello The SOAP Server says: Content-type: text/html
Software error:
syntax error at line 1, column 49, byte 49 at /usr/local/lib/perl5/site_perl/5.8.6/mach/XML/Parser.pm line 187

Please send mail to this site's webmaster for help. Content-type: text/html
Software error:
[Fri Oct 7 12:26:53 2005] hw_client.pl: [Fri Oct 7 12:26:53 2005] hw_client.pl: syntax error at line 1, column 49, byte 49 at /usr/local/lib/perl5/site_perl/5.8.6/mach/XML/Parser.pm line 187

Please send mail to this site's webmaster for help. Content-type: text/html
Software error:
404 Not Found at hw_client.pl line 10

- Mike

Ultimater
10-07-2005, 04:51 PM
Sorry dude, that error went right over my head, Wooooooooosh. lol. I admit I'm stumped as well -- that error is saying that there is a problem with the module and since the module is written-well, the "real" error rests elsewhere.... Hopefully I sped-up the process for others to answer.

Mike Burdick
10-07-2005, 04:55 PM
Ultimater,

Okay...I appreciated your help! :)

-Mike