home *** CD-ROM | disk | FTP | other *** search
-
- <HTML>
- <HEAD>
- <TITLE>SOAP::Transport::HTTP::Apache - SOAP mod_perl handler</TITLE>
- <LINK REL="stylesheet" HREF="../../../../../Active.css" TYPE="text/css">
- <LINK REV="made" HREF="mailto:">
- </HEAD>
-
- <BODY>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> SOAP::Transport::HTTP::Apache - SOAP mod_perl handler</P></STRONG>
- </TD></TR>
- </TABLE>
-
- <A NAME="__index__"></A>
- <!-- INDEX BEGIN -->
-
- <UL>
-
- <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
-
- <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
- <LI><A HREF="#description">DESCRIPTION</A></LI>
- <UL>
-
- <LI><A HREF="#handler(safeclasshash, optionaldispatcher)">handler(SafeClassHash, OptionalDispatcher)</A></LI>
- </UL>
-
- <LI><A HREF="#dependencies">DEPENDENCIES</A></LI>
- <LI><A HREF="#author">AUTHOR</A></LI>
- </UL>
- <!-- INDEX END -->
-
- <HR>
- <P>
- <H1><A NAME="name">NAME</A></H1>
- <P>SOAP::Transport::HTTP::Apache - SOAP mod_perl handler</P>
- <P>
- <HR>
- <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
- <UL>
- <LI>Linux</LI>
- <LI>Solaris</LI>
- <LI>Windows</LI>
- </UL>
- <HR>
- <H1><A NAME="synopsis">SYNOPSIS</A></H1>
- <P>Use this class to expose SOAP endpoints using Apache and mod_perl.
- Here's an example of a class that would like to receive SOAP
- packets. Note that it implements a single interesting function,
- handle_request, that takes there arguments: an array of headers,
- a body, and an EnvelopeMaker for creating the response:</P>
- <PRE>
- package Calculator;
- use strict;</PRE>
- <PRE>
- sub new {
- bless {}, shift;
- }</PRE>
- <PRE>
- sub handle_request {
- my ($self, $headers, $body, $envelopeMaker) = @_;</PRE>
- <PRE>
- $body->{extra_stuff} = "heres some extra stuff";</PRE>
- <PRE>
- foreach my $header (@$headers) {
- $header->{extra_stuff} = "heres some more extra stuff";
- $envelopeMaker->add_header(undef, undef, 0, 0, $header);
- }
- $envelopeMaker->set_body(undef, 'myresponse', 0, $body);
- }</PRE>
- <PRE>
- 1;</PRE>
- <P>In order to translate HTTP requests into calls on your Calculator
- class above, you'll need to write an Apache handler. This is where
- you'll use the SOAP::Transport::HTTP::Apache class:</P>
- <PRE>
- package ServerDemo;
- use strict;
- use SOAP::Transport::HTTP::Apache;</PRE>
- <PRE>
- sub handler {
- my $safe_classes = {
- Calculator => undef,
- };
- SOAP::Transport::HTTP::Apache->handler($safe_classes);
- }</PRE>
- <P>1;</P>
- <P>As you can see, this class basically does it all - parses the HTTP
- headers, reads the request, and sends a response. All you have to do
- is specify the names of classes that are safe to dispatch to.</P>
- <P>Of course, in order to tell Apache about your handler class above,
- you'll need to modify httpd.conf. Here's a simple example that shows
- how to set up an endpoint called ``/soap'' that maps to your ServerDemo
- handler above:</P>
- <PRE>
- <Location /soap>
- SetHandler perl-script
- PerlHandler ServerDemo
- </Location></PRE>
- <P>(I leave it up to you to make sure ServerDemo is in
- Perl's @INC path - see Writing Apache Modules
- with Perl and C by O'Reilly for help with mod_perl,
- or just man mod_perl)</P>
- <P>
- <HR>
- <H1><A NAME="description">DESCRIPTION</A></H1>
- <P>This class encapsulates the details of hooking up to mod_perl,
- and then calls SOAP::Transport::HTTP::Server to do the SOAP-specific
- stuff. This way the Server class can be reused with any web server
- configuration (including CGI), by simply composing it with a different
- front-end (for instance, SOAP::Transport::HTTP::CGI).</P>
- <P>
- <H2><A NAME="handler(safeclasshash, optionaldispatcher)">handler(SafeClassHash, OptionalDispatcher)</A></H2>
- <P>This is the only method on the class, and you must pass a
- hash reference whose keys contain the collection of classes
- that may be invoked at this endpoint. If you specify class
- FooBar in this list, for instance, and a client sends a SOAP
- request to <A HREF="http://yourserver/soap?class=FooBar,">http://yourserver/soap?class=FooBar,</A> then the
- SOAP::Transport::HTTP::Server class will eventually attempt
- to load FooBar.pm, instatiate a FooBar, and call
- its handle_request function (see SOAP::Transport::HTTP::Server
- for more detail). If you don't include a class in this hash,
- SOAP/Perl won't run it. I promise.</P>
- <P>By the way, only the keys in this hash are important, the
- values are ignored.</P>
- <P>Also, nothing is stopping you from messing around with the request
- object yourself if you'd like to add some headers or whatever;
- you can always call Apache-><CODE>request()</CODE> to get the request object
- inside your handle_request function. Just make sure you finish
- what you're doing before you return to SOAP::Transport::HTTP::Server,
- because at that point the response is marshaled and sent back.</P>
- <P>See SOAP::Transport::HTTP::Server for a description of the
- OptionalDispatcher argument.</P>
- <P>
- <HR>
- <H1><A NAME="dependencies">DEPENDENCIES</A></H1>
- <P>SOAP::Transport::HTTP::Server</P>
- <P>
- <HR>
- <H1><A NAME="author">AUTHOR</A></H1>
- <P>Keith Brown</P>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> SOAP::Transport::HTTP::Apache - SOAP mod_perl handler</P></STRONG>
- </TD></TR>
- </TABLE>
-
- </BODY>
-
- </HTML>
-