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

3344Re: Apache, mod_perl and objects_by_reference

Expand Messages
  • Thorsten
    Feb 5, 2004
    • 0 Attachment
      Hi Andre,

      although i'm not completely sure, i think i know what's happening. A
      solution is not in my mind currently, perhaps someone else may know
      how to use objects_by_reference in combination with Apache.

      The configurations and scripts themselves look good to me, so the
      reason seems to be elsewhere.
      Now, what i think is going on:
      - You object is created successfully on Apache-Server-side, and as a
      proof you'll get a correct 'id' back from the server to your client
      (which you dumped).
      - Now, the Apache-Child-Process serving your process, dies, also with
      its created SOAP-Object.
      - You try to call the method 'test' on the object with the returned
      id, and Apache receives this request from your client, *but on a new
      process*
      - This Process looks for an object with that id, but as the creating
      process died, there is no object with that id, and you get back an
      error from your Apache-Server.

      The whole thing bugging you is, that the objects on server-side won't
      stay persistent, across all Apache-Processes. And honestly i don't
      have a clue either on how to accomplish this, sorry :(

      Perhaps someone else on this list may know this??

      Kind regards,
      Thorsten

      --- In soaplite@yahoogroups.com, Andre Bonhote <andre@b...> wrote:
      > Hi!
      >
      > This might be a very stupid question, but I didn't find the answer
      to it
      > anywhere. I have problems using remote objects by reference using
      > Apache's mod_perl. I am able to create the object, but as soon as I
      want
      > to access methods in it it says 'Object with specific id not found'.
      > That's my test setup:
      >
      > - Mac OS X 10.3
      > - Apache 1.3.29 from source
      > - mod_perl 1.29 from source
      > - SOAP::Lite 0.55
      > - These lines inside httpd.conf:
      >
      > --->8---
      > <Location /soap>
      > SetHandler perl-script
      > PerlHandler SOAP::Apache
      > </Location>
      > --->8---
      >
      > - inside @INC, I created a dir called SOAP and placed this Apache.
      pm
      > into it:
      >
      > --->8---
      > package SOAP::Apache;
      > use SOAP::Transport::HTTP;
      > my $server = SOAP::Transport::HTTP::Apache
      > -> objects_by_reference(qw(A::Test))
      > -> dispatch_to(qw(/Users/andre/sec/dev/soap A::Test A::Test::new A:
      :Test::test))
      > -> options({compress_threshold => 10000})
      > ;
      > sub handler { $server->handler(@_) }
      > 1;
      > --->8---
      >
      > - In /Users/andre/sec/dev/soap, there's a directory called 'A' with
      > this simple piece inside:
      >
      > --->8---
      > package A::Test;
      >
      > use Class::MethodMaker
      > get_set => [qw(
      > test
      > )],
      > new => 'new';
      >
      > 1;
      > --->8---
      >
      > - After a restart of Apache, I try this code:
      >
      > --->8---
      > se strict;
      > use Data::Dumper;
      > use SOAP::Lite +autodispatch =>
      > uri => 'http://www.soaplite.com/',
      > proxy => 'http://localhost/soap',
      > on_fault => sub { my($soap, $res) = @_;
      > print Dumper($res);
      > die ref $res ? $res->faultdetail : $soap->transport->status,
      "\n";
      > }
      > ;
      >
      > my $p = A::Test->SOAP::new; # same thing remotely
      > $p->SOAP::test(100); ## [1]
      > print $p->SOAP::test(); ## [2]
      > print Dumper($p);
      > --->8---
      >
      > (you might know these code fragments, they are almost 1:1 out of
      the
      > User's guide)
      >
      > Now, commenting out the two lines [1] and [2], the output of $p
      looks
      > good IMHO:
      >
      > ---8<---
      > $VAR1 = bless( {
      > 'id' => '10759909909814200'
      > }, 'A::Test' );
      >
      > ---8<---
      >
      > But as soon as I want to access the method 'test', it doesn't work
      > anymore. SOAP::Lite calls the on_fault coderef and dumps $res, which
      > shows (among other things) this:
      >
      > 'faultstring' => 'Failed to locate method (new) in class (A::Test)
      at
      > /Library/Perl/5.8.1/SOAP/Lite.pm line 2195.
      >
      >
      > Ok, now flame me. What am I doing wrong? I checked the mailing
      list's
      > archive, without success. Has anyone had the same problem and
      resolved
      > it?
      >
      > Almost the same pieces of code work fine, without any problem, when
      I
      > create a standalone http daemon, like the ./examples/soap.daemon
      thing.
      > No problem at all.
      >
      > Any hints? Rants?
      >
      > Thanks a lot in advance!
      >
      > André
      >
      > --
      > :(){ :|:&};:
    • Show all 3 messages in this topic