Loading ...
Sorry, an error occurred while loading the content.

RE: [soaplite] mod_perl-2: partial solution; small issue

Expand Messages
  • Dan Grigsby
    Hi Paul, Attached please find an HTTP.pm that includes a SOAP::Transport::HTTP::Apache that should work with mod_perl-1 and mod_perl-2. I used $ENV{MOD_PERL}
    Message 1 of 4 , Jan 23, 2003
    • 0 Attachment
      Hi Paul,

      Attached please find an HTTP.pm that includes a
      SOAP::Transport::HTTP::Apache that should work with mod_perl-1 and
      mod_perl-2. I used $ENV{MOD_PERL} as the basis for selection of
      requires and API calls. This seemed the most reliable, since I suppose
      you could have mod_perl packages present on the disk for both versions
      (i.e., files not determinate).

      I'm sure this can be optimized. I have only tested it with mod_perl-2.

      -Dan

      -----Original Message-----
      From: Paul Kulchenko [mailto:paulclinger@...]
      Sent: Thursday, January 23, 2003 2:17 PM
      To: dcgrigsby <dan@...>; soaplite@yahoogroups.com
      Subject: Re: [soaplite] mod_perl-2: partial solution; small issue


      Hi Dan,

      > "Can't locate object method "new" via package "ModPerl2SOAP" at
      > C:/Perl/site/lib/Apache2/Apache/SoapLink.pm line 24."
      >
      > I'm sorry, and I have poured over the archives here before asking,
      > but I can't figure out why it wouldn't call the base-class' new and
      > go up the chain like any other package would do.
      No inheritance? I guess it's because of this:

      package ModPerl2SOAP;

      @ISA = qw(SOAP::Transport::HTTP::Server);

      ISA doesn't belong to this package. It has to be ModPerl2SOAP::ISA or
      'use vars qw(ISA)'. use strict? -w? ;))

      Perl doesn't see that ModPerl2SOAP is inherited from
      SOAP::Transport:... and complains. I don't see any reason why it
      shouldn't work otherwise. I'd still prefer to have one version that
      can server both mod_perl's. I'm willing to play with if's and
      require's to make it work. Thanks for your help, Dan; would you send
      me the version that works for mod_perl2, I'll try to combine both in
      one file?

      Best wishes, Paul.

      --- "dcgrigsby <dan@...>" <dan@...> wrote:
      > Hello,
      >
      > I decided to take a crack at writing a module to work with Apache-2
      >
      > and mod_perl-2. Before I loose you, let me say that I made it
      > work; I want to do it "the right way" though, and ask for
      > assistance.
      >
      > First thing I did was add a package to SOAP/Transport/HTTP.pm
      > called
      > SOAP::Transport::HTTP::Apache2. I cut and paste the mod_perl-1
      > code, changed the "requires" and ported the mod_perl-1 API calls to
      >
      > mod_perl-2. At this point it works.
      >
      > I want, however, to do this right, and it seems to me that I should
      >
      > not be playing inside Paul's files, and instead I should subclass
      > SOAP::Transport::HTTP::Server. I have attempted to do so
      > in an mod_perl-2 handler included below.
      >
      > Problem is that perl spits up when "$self =
      > $class->SUPER::new(@_);"
      > is executed. Message is:
      >
      > "Can't locate object method "new" via package "ModPerl2SOAP" at
      > C:/Perl/site/lib/Apache2/Apache/SoapLink.pm line 24."
      >
      > I'm sorry, and I have poured over the archives here before asking,
      > but I can't figure out why it wouldn't call the base-class' new and
      >
      > go up the chain like any other package would do.
      >
      > Any help greatly appreciated.
      >
      > -Dan
      >
      >
      >
      > package Apache::SoapLink;
      >
      > my $server = new ModPerl2SOAP -> dispatch_to('/soap/modules');
      >
      > sub handler { $server->handler(@_) }
      >
      > # Hacked up Apache2/Mod_Perl-2 Transport:
      > BEGIN {
      > use SOAP::Lite;
      >
      > package ModPerl2SOAP;
      >
      > @ISA = qw(SOAP::Transport::HTTP::Server);
      >
      > sub dispatch_to { SOAP::Server::dispatch_to(@_); }
      >
      > sub DESTROY { SOAP::Trace::objects('()') }
      >
      > sub new { require Apache2; require Apache::Const;
      > my $self = shift;
      >
      > unless (ref $self) {
      > my $class = ref($self) || $self;
      > $self = $class->SUPER::new(@_);
      > SOAP::Trace::objects('()');
      > }
      > return $self;
      > }
      >
      > sub handler {
      > my $self = shift->new;
      > my $r = shift || Apache->request;
      >
      > $self->request(HTTP::Request->new(
      > $r->method => $r->uri,
      > HTTP::Headers->new($r->headers_in),
      > do { my $buf; $r->read($buf, $r->headers_in->{'Content-
      > length'}); $buf; }
      > ));
      > $self->SUPER::handle;
      >
      > # we will specify status manually for Apache, because
      > # if we do it as it has to be done, returning SERVER_ERROR,
      > # Apache will modify our content_type to 'text/html; ....'
      > # which is not what we want.
      > # will emulate normal response, but with custom status code
      > # which could also be 500.
      > $r->status($self->response->code);
      >
      > $self->response->headers->scan(sub { $r->headers_out->{@_} });
      > $r->content_type(join '; ', $self->response->content_type);
      > $r->print($self->response->content);
      > &Apache::OK;
      > }
      >
      > sub configure {
      > my $self = shift->new;
      > my $config = shift->dir_config;
      > foreach (%$config) {
      > $config->{$_} =~ /=>/
      > ? $self->$_({split /\s*(?:=>|,)\s*/, $config->{$_}})
      > : ref $self->$_() ? () # hm, nothing can be done here
      > : $self->$_(split /\s+|\s*,\s*/,
      > $config->
      > {$_})
      > if $self->can($_);
      > }
      > $self;
      > }
      >
      > { sub handle; *handle = \&handler } # just create alias
      > }
      > 1;
      >
      >
      > To unsubscribe from this group, send an email to:
      > soaplite-unsubscribe@yahoogroups.com
      >
      >
      >
      > Your use of Yahoo! Groups is subject to
      > http://docs.yahoo.com/info/terms/
      >
      >


      __________________________________________________
      Do you Yahoo!?
      Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
      http://mailplus.yahoo.com
    Your message has been successfully submitted and would be delivered to recipients shortly.