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

Re: [soaplite] Problems with objects_by_reference and clients

Expand Messages
  • Randy J. Ray
    ... Duncan Isn t the above syntax wrong, it s mixing in the autodispatch Duncan syntax. Should it be something like: my $soap =
    Message 1 of 1 , May 18, 2002
      >>>>> "Duncan" == Duncan Cameron <dcameron@...>
      >>>>> wrote the following on Sat, 18 May 2002 18:25:54 +0000

      Duncan> Isn't the above syntax wrong, it's mixing in the autodispatch
      Duncan> syntax. Should it be something like:

      my $soap = SOAP::Lite->uri('urn:/WishListCustomer')
      -> proxy($endpoint);

      my $ref_to_remote_obj = $soap->SOAP::new($user, $passwd);

      my $result = $soap->Wishlist($ref_to_remote_obj);

      I had also tried that syntax, with the same results. That is, both versions
      return a valid object blessed into the remote class.

      This is the WishListCustomer::SOAP class. I recently added the line in the
      BEGIN block to do the 'eval "sub $method";' like SOAP::Lite does in a few
      places, thinking that maybe the problem was a UNIVERSAL::can() test that was
      failing, but it didn't help:

      package WishListCustomer::SOAP;

      use strict;
      use vars qw(@ISA %COOKIES);
      use subs qw();

      use SOAP::Lite;
      use WishListCustomer;

      @ISA = qw(WishListCustomer);

      BEGIN {
      no strict 'refs';

      for my $method qw(GetBook BooksByAuthor BooksByTitle
      Wishlist AddBook RemoveBook
      CanPurchase PurchaseBooks) {
      eval "sub $method";
      *$method = sub {
      my $self = shift->new;
      return SOAP::Fault->faultcode('ServerError')->
      faultstring('Could not get object')
      unless $self;

      my $smethod = "SUPER::$method";
      my $res = $self->$smethod(@_);
      ref($res) ? $res :
      SOAP::Fault->faultcode('ServerError')->
      faultstring($res);
      };
      }
      }

      1;

      sub new {
      my $class = shift;
      return $class if ref($class);

      my $self;
      # If there are no arguments, but available cookies, then
      # that is the signal to work the cookies into play
      if ((! @_) and (keys %COOKIES)) {
      # Start by getting the basic, bare object
      $self = $class->SUPER::new();
      # Then call SetUser with no arguments
      return undef unless ref($self->SetUser);
      } else {
      $self = $class->SUPER::new(@_);
      }

      $self;
      }

      sub SetUser {
      my $self = shift->new;
      my %args = @_;

      return $self->SUPER::SetUser(%args) if (%args);

      my ($user, $cookie) = @COOKIES{qw(user userpass)};
      return $self unless ($user and $cookie);

      ref($self->SUPER::SetUser(user => $user,
      cookie => $cookie))
      ? $self : undef;
      }


      Randy
      --
      """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
      Randy J. Ray rjray@...
      Campbell, CA rjray@...
      <A HREF="http://www.svsm.org">Silicon Valley Scale Modelers</A>
    Your message has been successfully submitted and would be delivered to recipients shortly.