I'm looking to expose some Perl programs I have as web services via SOAP.
The trick is, I would like to expose them as *real* web services - WSDL included.
I am aware that this is not the first time this question has come up - I am familiar with the SOAP and SOAP::Lite modules. I have checked out UDDI, Pod::WSDL, WSDL::Generator and SOAP::WSDL.
- UDDI does not make test on Win32 or Linux (Fedora 4).
- WSDL::Generator does not get past make test on Win32 or Linux (Fedora 4).
- Pod::WSDL builds correctly on Win32 (requires v5.8.5 but my Linux has v5.8.3)
I was unable to find a single module in CPAN for BPEL or Xlang.
ebXML exists, but it has a dependency on XML::Xerces. Installing XML::Xerces via RPM from rpmfind.net does not set up the variables XERCESROOT, XERCES_LIB, XERCES_INCLUDE and XERCES_CONFIG, so XML::Xerces still won't install even after installing the Xerces library rpm. Apparently you have to compile Xerces.
So I set out to install Xerces from the source available at
http://xml.apache.org.
Fedora 4 does not include autoconf or g++, and cpp doesn't understand the -c directive, so it bails out. At this point I decided to write off ebXML as well.
Installing the SOAP module via CPAN tries to install Apache (not Apache2).
After a successful SOAP install (via CPAN) the following happens:
[root@mailer2-sb root]# perl -MSOAP -e 'print "Hello, with SOAP!"'
Can't locate SOAP/Transport.pm in @INC (@INC contains: ....
So what else would you do?
cpan> install SOAP::Transport
CPAN: Storable loaded ok
Going to read /root/.cpan/Metadata
Database was generated on Mon, 10 Apr 2006 18:46:07 GMT
Warning: Cannot install SOAP::Transport, don't know what it is.
Try the command
i /SOAP::Transport/
to find objects with matching identifiers.
Running that command, one can glean that SOAP::Transport is part of SOAP::Lite - along with over a dozen other distributions.
I set out to install SOAP::Lite.
SOAP::Lite did not test correctly. Most tests that involved server tests failed. I installed with force. A quick test from the command line showed that SOAP::Lite loads fine - good enough for me.
At this point I have spent almost an hour just installing modules, most of which did not work at all. I could understand if I were running some fringe OS or a minimal install, however, the machine I am using has Fedora Core 4 with everything installed - not exactly a fringe case.
Pod::WSDL turned out to be
Really Great Stuff. So having that working, the next step is a mod_perl handler that would serve the WSDL dynamically. Sure, I could just dump the WSDL to a static file whenever I update my Perl modules, but what fun would that be?
package MyApp::WSDL;
use strict;
use Pod::WSDL;
sub handler : method
{
my ($s, $r) = @_;
my ($package) = $r->uri =~ m/^\/([^\?]+)/;
$package =~ s/\//::/g;
my $pod = Pod::WSDL->new(
source => $package,
location => "http://$ENV{HTTP_HOST}" . $r->uri,
pretty => 1,
withDocumentation => 1,
);
print "content-type: text/xml\n\n";
print $pod->WSDL;
return 0;
}# end handler()
1;# return true:
Then on top of that I figure Apache2::SOAP would do the trick.
- There is no Apache2::SOAP ppm from ActiveState.
- Apache2::SOAP requires ModPerl::MM.
- ModPerl::MM is part of the mod_perl2 distribution.
**If you're using Win32 to run this**, and you already have had the good fortune of plowing your way through Google, httpd.apache.org, PerlMonks, per.apache.org, and perhaps several others just to find a working Apache2 + mod_perl2 + SSL binary (who has time to compile it??) then Apache2::SOAP will work great right out of the box.
If you are not one of the fortunate, then sadly you're on your own.
This task has opened my eyes to the world of problems associated with installing Perl software, especially when it links against external libraries. I didn't even get far enough with this to *do* any SOAP - and I have been dinking with this most of the morning.
I think it's time we put together even 1 page that lists a how-to document that would get indexed by Google and point some folks in the right direction.
Any takers?
Moved from Seekers of Perl Wisdom to Meditations by planetscape