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

unable to find methods in objects

Expand Messages
  • Mental Patient
    Hello, perhaps I m simply not configuring things properly, but I m having a hard time using the OO aspect of SOAP::Lite. I m setting up a mod_perl server, I ve
    Message 1 of 2 , Aug 13 8:41 AM
    • 0 Attachment
      Hello, perhaps I'm simply not configuring things properly, but I'm
      having a hard time using the OO aspect of SOAP::Lite.

      I'm setting up a mod_perl server, I've registered Apache::SOAP as the
      handler via a location directive (forgive the broken formatting):
      <Location /soap>
      PerlSetEnv PERL5LIB \
      "/home/mental/source/java-stuff/hmsonline/htdocs/soap"

      SetHandler perl-script

      PerlHandler Apache::SOAP

      PerlSetVar dispatch_to \
      "/home/mental/source/java-stuff/hmsonline/htdocs/soap, \
      HMS::CCL::Transaction, HMS::CCL::Transaction::clean"

      PerlSetVar options "compress_threshold => 10000"
      </Location>
      #################################################################################################

      That _seems_ to work. I can write a client and get a new Transaction
      object. However, I am unable to call the clean method. I should be able
      to instantiate a remote object, then call methods on it, correct? I'm
      trying to start simple, then work my way forward. The service is this at
      the moment:

      package HMS::CCL::Transaction;
      use strict;
      sub new
      {
      my $class = shift;
      my $self = {};
      bless $self,$class;
      my $args = shift;
      $self->{'type'} = $args->{'type'};
      $self->{'instance_opts'} = $args->{'opts'};
      return $self;
      }



      sub clean
      {
      my ($self) = @_;
      return $self->{'type'};
      }

      1;
      __END__
      ##################################################################################################

      Client code looks like:
      #!/usr/bin/perl -w
      use strict;
      use SOAP::Lite
      #+trace=>'all',
      proxy=>'http://crabby.hmsonline.com/soap/',
      on_fault => sub { my ($soap,$res) = @_;
      die ref $res ? $res->faultdetail : $soap->transport->status,"\n";
      }
      ;
      use Data::Dumper;
      my $soap = SOAP::Lite->new()->uri('/HMS/CCL/Transaction');
      my $args = get_constructor_opts();
      my $obj = $soap->call(new => $args)->result;
      print "returned object:",$obj,"\n";
      print Dumper($obj);
      my $str = $soap->clean($obj)->result;
      print $str;


      sub get_constructor_opts
      {
      my %foo;
      $foo{'type'} = "hms.phone.us";
      return \%foo;
      }

      ############################################################################################

      It prints the following:
      returned object:HMS::CCL::Transaction=HASH(0x86bac7c)
      $VAR1 = bless( {
      'instance_opts' => undef,
      'type' => 'hms.phone.us'
      }, 'HMS::CCL::Transaction' );



      So, I'm getting the right object type back, but when I call clean, I get
      this in the apache error log:
      (eval): HMS::CCL::Transaction=HASH(0x87b7b7c)
      SOAP::Server::handle:
      SOAP::SOM::DESTROY: ()
      SOAP::Serializer::envelope: ()
      SOAP::Serializer::envelope: Client Failed to locate method (clean) in
      class (HMS::CCL::Transaction) at /usr/share/perl5/SOAP/Lite.pm line
      2195.



      Now, if I change clean to be something like:
      sub clean
      { return "foo";}

      I get the string foo back. So there's some sort of problem with $self
      being deserialized or something. I've tried objects_by_reference, that
      yeilds:
      SOAP::SOM::DESTROY: ()
      SOAP::Serializer::envelope: ()
      SOAP::Serializer::envelope: Server Object with specified id couldn't be
      found

      Can someone please give me a hint, or some insight as to what I'm doing
      wrong? I swear I've seen this sort of thing work before. Something like:
      $obj = Package->new();
      $obj->setData($x);
      ......
      my $x = $obj->getData();

      Should be doable, no?

      --

      Mental (Mental@...)

      CARPE NOCTEM, QUAM MINIMUM CREDULA POSTERO.

      GPG public key: http://www.neverlight.com/pas/Mental.asc
    • Mental Patient
      To follow up on my own issue... It turns out it was an issue of brain not being fully engaged. I was mixing up some autodispatch style code with
      Message 2 of 2 , Aug 13 11:35 AM
      • 0 Attachment
        To follow up on my own issue... It turns out it was an issue of brain
        not being fully engaged. I was mixing up some autodispatch style code
        with non-autodispatch code. I completely forgot the whole
        $soap->call(method => $object,$arg) syntax. Its been ages since I used
        this stuff, sorry for the faq :)


        --

        Mental (Mental@...)

        CARPE NOCTEM, QUAM MINIMUM CREDULA POSTERO.

        GPG public key: http://www.neverlight.com/pas/Mental.asc
      Your message has been successfully submitted and would be delivered to recipients shortly.