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

Persistent objects using call() syntax

Expand Messages
  • Michael Percy
    Hello, I have a question about Persistent server-side objects without using the autodispatch mode. In the SOAP::Lite POD Docs, it says, under implementation
    Message 1 of 5 , Aug 3, 2001
    • 0 Attachment
      Hello,
      I have a question about Persistent server-side objects without using the
      autodispatch mode.

      In the SOAP::Lite POD Docs, it says, under "implementation of OO interface"
      that you can have a remote object on the server as well as make local calls
      to it using the alternative "call" interface. I have pasted the example for
      using the call() interface below:

      # you should specify uri()
      my $soap = SOAP::Lite
      -> uri('http://my.own.site/CLASS') # <<< CLASS goes here
      # ..... other parameters
      ;
      my $obj = $soap->call(new => @parameters)->result;
      print $soap->call(method => $obj)->result;
      # $obj object will be updated here if necessary,
      # as if you call $obj->method() and method() updates $obj
      # Update of modified object MAY not work if server on another side
      # is not SOAP::Lite

      This is clear until it calls the "method" method, and I want to make sure I
      understand it fully.

      This is what I understand so far, please correct me if I am confused:
      (1) $soap is obviously a reference to a blessed SOAP::Lite object and
      remains so.

      (2) $obj is an actual object (reference) of the server-side class "CLASS".

      (3) The new() method of CLASS is invoked very similar to:
      (a) my $obj = CLASS->new(@parameters);
      because you do not have to pass the object as the first parameter.

      (4) The method() method of $obj (blessed CLASS) is invoked somehow
      differently, sort of like:
      (b) CLASS::method($obj, @parameters);
      even though the call() syntax looks like (a) above, suggesting it
      means this:
      (c) CLASS->method($obj, @parameters);
      or maybe
      (d) $obj->method($obj, @parameters);

      The reason I ask is because the interface is the same for Class methods (3)
      and Object methods (4) but the only code that seems like it would work in
      normal perl is (a) and (b). Still, it looks like either (c) or (d) is really
      being called for Object methods.

      Is SOAP::Lite doing some kind of argument-munging magic on the server side
      in the Object method cases?
      Please help me understand how this OO-syntax call method works, so I can
      avoid autodispatch if possible.

      Thanks a lot,
      Mike
    • Paul Kulchenko
      Hi, Michael! ... That basically means that execution of any method call MAY have a side effect as modification of object itself: $a = bless {a = 1} = A ;
      Message 2 of 5 , Aug 3, 2001
      • 0 Attachment
        Hi, Michael!

        --- Michael Percy <mpercy@...> wrote:
        > my $obj = $soap->call(new => @parameters)->result;
        > print $soap->call(method => $obj)->result;
        > # $obj object will be updated here if necessary,
        > # as if you call $obj->method() and method() updates $obj
        > # Update of modified object MAY not work if server on another side
        >
        > # is not SOAP::Lite
        >
        > This is clear until it calls the "method" method, and I want to
        > make sure I understand it fully.
        That basically means that execution of any method call MAY have a
        side effect as modification of object itself:

        $a = bless {a => 1} => 'A';
        $a->update_a(2);

        say will update property 'a' and return old value '1'.

        In SOAP call you will see only result '1', but you're loosing side
        effect. SOAP::Lite executes this code on server side as:

        $a->update_a(2); # regardless of using mode on client,
        # autodispatch or ->call() interface

        AND it'll also return modified object back, so your application will
        see $a as modified object. Other SOAP implementations WILL NOT return
        you object back, so you're loosing this side effect. It is NOT a
        problem if you application returns object itself on any property
        modifications (as SOAP::Lite does ;)), because then object will be
        returned as a result and you can write:

        $a = $a->update_a(2);

        to get desired effect.

        > (1) $soap is obviously a reference to a blessed SOAP::Lite object
        > and remains so.
        Correct.

        > (2) $obj is an actual object (reference) of the server-side class
        > "CLASS".
        $obj is something returned by server that is blessed into class
        CLASS.

        > (3) The new() method of CLASS is invoked very similar to:
        > (a) my $obj = CLASS->new(@parameters);
        > because you do not have to pass the object as the first
        > parameter.
        Correct. Here is the small difference comparing to what Perl does.
        SOAP::Lite DOES NOT pass class name as the first parameter during
        this call. This information is extracted on server side from URI and
        call is still executed as CLASS method call: CLASS->method

        > (4) The method() method of $obj (blessed CLASS) is invoked
        > somehow differently, sort of like:
        > (b) CLASS::method($obj, @parameters);
        > even though the call() syntax looks like (a) above,
        > suggesting it means this:
        > (c) CLASS->method($obj, @parameters);
        > or maybe
        > (d) $obj->method($obj, @parameters);
        It's always invoked as

        $obj->method(@parameters);

        Let me know if something is still unclear, I'll give you more
        details.

        On related side. I plan to introduce option on client and server side
        that will allow you to execute calls "as is" on server side, without
        any parameters modifications. It'll allow you to do direct calls for
        functions (it require wrappers right now, because all calls are
        method calls) and allow to implement remote inheritance.

        Best wishes, Paul.

        --- Michael Percy <mpercy@...> wrote:
        > Hello,
        > I have a question about Persistent server-side objects without
        > using the
        > autodispatch mode.
        >
        > In the SOAP::Lite POD Docs, it says, under "implementation of OO
        > interface"
        > that you can have a remote object on the server as well as make
        > local calls
        > to it using the alternative "call" interface. I have pasted the
        > example for
        > using the call() interface below:
        >
        > # you should specify uri()
        > my $soap = SOAP::Lite
        > -> uri('http://my.own.site/CLASS') # <<< CLASS goes here
        > # ..... other parameters
        > ;
        > my $obj = $soap->call(new => @parameters)->result;
        > print $soap->call(method => $obj)->result;
        > # $obj object will be updated here if necessary,
        > # as if you call $obj->method() and method() updates $obj
        > # Update of modified object MAY not work if server on another side
        >
        > # is not SOAP::Lite
        >
        > This is clear until it calls the "method" method, and I want to
        > make sure I understand it fully.
        >
        > This is what I understand so far, please correct me if I am
        > confused:
        > (1) $soap is obviously a reference to a blessed SOAP::Lite object
        > and
        > remains so.
        >
        > (2) $obj is an actual object (reference) of the server-side class
        > "CLASS".
        >
        > (3) The new() method of CLASS is invoked very similar to:
        > (a) my $obj = CLASS->new(@parameters);
        > because you do not have to pass the object as the first
        > parameter.
        >
        > (4) The method() method of $obj (blessed CLASS) is invoked
        > somehow
        > differently, sort of like:
        > (b) CLASS::method($obj, @parameters);
        > even though the call() syntax looks like (a) above,
        > suggesting it
        > means this:
        > (c) CLASS->method($obj, @parameters);
        > or maybe
        > (d) $obj->method($obj, @parameters);
        >
        > The reason I ask is because the interface is the same for Class
        > methods (3)
        > and Object methods (4) but the only code that seems like it would
        > work in
        > normal perl is (a) and (b). Still, it looks like either (c) or (d)
        > is really
        > being called for Object methods.
        >
        > Is SOAP::Lite doing some kind of argument-munging magic on the
        > server side
        > in the Object method cases?
        > Please help me understand how this OO-syntax call method works, so
        > I can
        > avoid autodispatch if possible.
        >
        > Thanks a lot,
        > Mike
        >
        > ------------------------ Yahoo! Groups Sponsor
        >
        > 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!?
        Make international calls for as low as $.04/minute with Yahoo! Messenger
        http://phonecard.yahoo.com/
      • Michael Percy
        Paul, Thanks for all your help, that was useful... But the main question I had was related to these statements in the example: my $obj = $soap- call(new =
        Message 3 of 5 , Aug 3, 2001
        • 0 Attachment
          Paul,
          Thanks for all your help, that was useful... But the main question I had was
          related to these statements in the example:

          my $obj = $soap->call(new => @parameters)->result;
          print $soap->call(method => $obj)->result;

          How would I pass parameters to the object method call in the 2nd line? If I
          just pass them in as parameters after the object reference, then how does
          SOAP::Lite know I want it to use the object as the "invoker" for the method
          call instead of just using it as the first argument to a class method call
          from URI?

          Also, on a semi-related note, you gave me another question :) ...

          > you object back, so you're loosing this side effect. It is NOT a
          > problem if you application returns object itself on any property
          > modifications (as SOAP::Lite does ;)), because then object will be
          > returned as a result and you can write:
          >
          > $a = $a->update_a(2);

          In this situation, how would you get the result of the method call itself
          after doing this? just $a->result ?

          What if you are using the call() syntax? Similar code? (I'd like to write
          wrappers and factories for my soap objects that are also interoperable with
          apache soap, possibly client and server.)

          Thanks again!
          Mike


          > -----Original Message-----
          > From: Paul Kulchenko [mailto:paulclinger@...]
          > Sent: Friday, August 03, 2001 1:35 PM
          > To: soaplite@yahoogroups.com
          > Subject: Re: [soaplite] Persistent objects using call() syntax
          >
          >
          > Hi, Michael!
          >
          > --- Michael Percy <mpercy@...> wrote:
          > > my $obj = $soap->call(new => @parameters)->result;
          > > print $soap->call(method => $obj)->result;
          > > # $obj object will be updated here if necessary,
          > > # as if you call $obj->method() and method() updates $obj
          > > # Update of modified object MAY not work if server on
          > another side
          > >
          > > # is not SOAP::Lite
          > >
          > > This is clear until it calls the "method" method, and I want to
          > > make sure I understand it fully.
          > That basically means that execution of any method call MAY have a
          > side effect as modification of object itself:
          >
          > $a = bless {a => 1} => 'A';
          > $a->update_a(2);
          >
          > say will update property 'a' and return old value '1'.
          >
          > In SOAP call you will see only result '1', but you're loosing side
          > effect. SOAP::Lite executes this code on server side as:
          >
          > $a->update_a(2); # regardless of using mode on client,
          > # autodispatch or ->call() interface
          >
          > AND it'll also return modified object back, so your application will
          > see $a as modified object. Other SOAP implementations WILL NOT return
          > you object back, so you're loosing this side effect. It is NOT a
          > problem if you application returns object itself on any property
          > modifications (as SOAP::Lite does ;)), because then object will be
          > returned as a result and you can write:
          >
          > $a = $a->update_a(2);
          >
          > to get desired effect.
          >
          > > (1) $soap is obviously a reference to a blessed SOAP::Lite object
          > > and remains so.
          > Correct.
          >
          > > (2) $obj is an actual object (reference) of the server-side class
          > > "CLASS".
          > $obj is something returned by server that is blessed into class
          > CLASS.
          >
          > > (3) The new() method of CLASS is invoked very similar to:
          > > (a) my $obj = CLASS->new(@parameters);
          > > because you do not have to pass the object as the first
          > > parameter.
          > Correct. Here is the small difference comparing to what Perl does.
          > SOAP::Lite DOES NOT pass class name as the first parameter during
          > this call. This information is extracted on server side from URI and
          > call is still executed as CLASS method call: CLASS->method
          >
          > > (4) The method() method of $obj (blessed CLASS) is invoked
          > > somehow differently, sort of like:
          > > (b) CLASS::method($obj, @parameters);
          > > even though the call() syntax looks like (a) above,
          > > suggesting it means this:
          > > (c) CLASS->method($obj, @parameters);
          > > or maybe
          > > (d) $obj->method($obj, @parameters);
          > It's always invoked as
          >
          > $obj->method(@parameters);
          >
          > Let me know if something is still unclear, I'll give you more
          > details.
          >
          > On related side. I plan to introduce option on client and server side
          > that will allow you to execute calls "as is" on server side, without
          > any parameters modifications. It'll allow you to do direct calls for
          > functions (it require wrappers right now, because all calls are
          > method calls) and allow to implement remote inheritance.
          >
          > Best wishes, Paul.
          >
        • Paul Kulchenko
          Hi, Michael! ... $soap- call(method = $obj, @parameters)- result; ... Good question. I m checking the first parameter and compare it with CLASS info provided
          Message 4 of 5 , Aug 3, 2001
          • 0 Attachment
            Hi, Michael!

            --- Michael Percy <mpercy@...> wrote:
            > Thanks for all your help, that was useful... But the main question
            > I had was
            > related to these statements in the example:
            >
            > my $obj = $soap->call(new => @parameters)->result;
            > print $soap->call(method => $obj)->result;
            >
            > How would I pass parameters to the object method call in the 2nd
            > line? If I
            $soap->call(method => $obj, @parameters)->result;

            > just pass them in as parameters after the object reference, then
            > how does
            > SOAP::Lite know I want it to use the object as the "invoker" for
            > the method
            > call instead of just using it as the first argument to a class
            > method call from URI?
            Good question. I'm checking the first parameter and compare it with
            CLASS info provided in URI. If it's object of correcponding type, I'm
            making an object call, if not, class call with provided class info.

            > > $a = $a->update_a(2);
            >
            > In this situation, how would you get the result of the method call
            > itself after doing this? just $a->result ?
            It IS the result. I gave you an example in autodispatch syntax.
            Summary:

            AD:

            1. update_a returns OLD value:

            $value = $a->update_a(2);

            object $a is ALSO updated if server is SOAP::Lite implementation

            2. update_a returns modified object:

            $a = $a->update_a(2);

            object $a is updated regardless of server implementation, because it
            IS the result itself.

            OO:

            1. update_a returns OLD value:

            $value = $soap->call(update_a => $a, 2)->result;

            again, object $a is updated if server is SOAP::Lite implementation

            2. update_a returns modified object:

            $a = $soap->call(update_a => $a, 2)->result;

            again, object $a is updated regardless of server implementation,
            because it IS the result itself.

            > What if you are using the call() syntax? Similar code? (I'd like to
            > write
            > wrappers and factories for my soap objects that are also
            > interoperable with apache soap, possibly client and server.)
            The only piece that is not interoperable is the magic that updates an
            object itself as a side effect (AD.1. and OO.1.). Everything else
            should work with any implementations (as soon as object
            representations are similar on wire).

            Let me know if you face any problems.

            Best wishes, Paul.

            > > -----Original Message-----
            > > From: Paul Kulchenko [mailto:paulclinger@...]
            > > Sent: Friday, August 03, 2001 1:35 PM
            > > To: soaplite@yahoogroups.com
            > > Subject: Re: [soaplite] Persistent objects using call() syntax
            > >
            > >
            > > Hi, Michael!
            > >
            > > --- Michael Percy <mpercy@...> wrote:
            > > > my $obj = $soap->call(new => @parameters)->result;
            > > > print $soap->call(method => $obj)->result;
            > > > # $obj object will be updated here if necessary,
            > > > # as if you call $obj->method() and method() updates $obj
            > > > # Update of modified object MAY not work if server on
            > > another side
            > > >
            > > > # is not SOAP::Lite
            > > >
            > > > This is clear until it calls the "method" method, and I want to
            > > > make sure I understand it fully.
            > > That basically means that execution of any method call MAY have a
            > > side effect as modification of object itself:
            > >
            > > $a = bless {a => 1} => 'A';
            > > $a->update_a(2);
            > >
            > > say will update property 'a' and return old value '1'.
            > >
            > > In SOAP call you will see only result '1', but you're loosing
            > side
            > > effect. SOAP::Lite executes this code on server side as:
            > >
            > > $a->update_a(2); # regardless of using mode on client,
            > > # autodispatch or ->call() interface
            > >
            > > AND it'll also return modified object back, so your application
            > will
            > > see $a as modified object. Other SOAP implementations WILL NOT
            > return
            > > you object back, so you're loosing this side effect. It is NOT a
            > > problem if you application returns object itself on any property
            > > modifications (as SOAP::Lite does ;)), because then object will
            > be
            > > returned as a result and you can write:
            > >
            > > $a = $a->update_a(2);
            > >
            > > to get desired effect.
            > >
            > > > (1) $soap is obviously a reference to a blessed SOAP::Lite
            > object
            > > > and remains so.
            > > Correct.
            > >
            > > > (2) $obj is an actual object (reference) of the server-side
            > class
            > > > "CLASS".
            > > $obj is something returned by server that is blessed into class
            > > CLASS.
            > >
            > > > (3) The new() method of CLASS is invoked very similar to:
            > > > (a) my $obj = CLASS->new(@parameters);
            > > > because you do not have to pass the object as the first
            > > > parameter.
            > > Correct. Here is the small difference comparing to what Perl
            > does.
            > > SOAP::Lite DOES NOT pass class name as the first parameter during
            > > this call. This information is extracted on server side from URI
            > and
            > > call is still executed as CLASS method call: CLASS->method
            > >
            > > > (4) The method() method of $obj (blessed CLASS) is invoked
            > > > somehow differently, sort of like:
            > > > (b) CLASS::method($obj, @parameters);
            > > > even though the call() syntax looks like (a) above,
            > > > suggesting it means this:
            > > > (c) CLASS->method($obj, @parameters);
            > > > or maybe
            > > > (d) $obj->method($obj, @parameters);
            > > It's always invoked as
            > >
            > > $obj->method(@parameters);
            > >
            > > Let me know if something is still unclear, I'll give you more
            > > details.
            > >
            > > On related side. I plan to introduce option on client and server
            > side
            > > that will allow you to execute calls "as is" on server side,
            > without
            > > any parameters modifications. It'll allow you to do direct calls
            > for
            > > functions (it require wrappers right now, because all calls are
            > > method calls) and allow to implement remote inheritance.
            > >
            > > Best wishes, Paul.
            > >
            >
            > ------------------------ Yahoo! Groups Sponsor
            >
            > 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!?
            Make international calls for as low as $.04/minute with Yahoo! Messenger
            http://phonecard.yahoo.com/
          • Michael Percy
            Paul, You re awesome! Thanks for your patience in answering all my questions. Regards, Mike
            Message 5 of 5 , Aug 3, 2001
            • 0 Attachment
              Paul,
              You're awesome! Thanks for your patience in answering all my questions.

              Regards,
              Mike

              > -----Original Message-----
              > From: Paul Kulchenko [mailto:paulclinger@...]
              > Sent: Friday, August 03, 2001 3:28 PM
              > To: soaplite@yahoogroups.com
              > Subject: RE: [soaplite] Persistent objects using call() syntax
              >
              >
              > Hi, Michael!
              >
              > --- Michael Percy <mpercy@...> wrote:
              > > Thanks for all your help, that was useful... But the main question
              > > I had was
              > > related to these statements in the example:
              > >
              > > my $obj = $soap->call(new => @parameters)->result;
              > > print $soap->call(method => $obj)->result;
              > >
              > > How would I pass parameters to the object method call in the 2nd
              > > line? If I
              > $soap->call(method => $obj, @parameters)->result;
              >
              > > just pass them in as parameters after the object reference, then
              > > how does
              > > SOAP::Lite know I want it to use the object as the "invoker" for
              > > the method
              > > call instead of just using it as the first argument to a class
              > > method call from URI?
              > Good question. I'm checking the first parameter and compare it with
              > CLASS info provided in URI. If it's object of correcponding type, I'm
              > making an object call, if not, class call with provided class info.
              >
              > > > $a = $a->update_a(2);
              > >
              > > In this situation, how would you get the result of the method call
              > > itself after doing this? just $a->result ?
              > It IS the result. I gave you an example in autodispatch syntax.
              > Summary:
              >
              > AD:
              >
              > 1. update_a returns OLD value:
              >
              > $value = $a->update_a(2);
              >
              > object $a is ALSO updated if server is SOAP::Lite implementation
              >
              > 2. update_a returns modified object:
              >
              > $a = $a->update_a(2);
              >
              > object $a is updated regardless of server implementation, because it
              > IS the result itself.
              >
              > OO:
              >
              > 1. update_a returns OLD value:
              >
              > $value = $soap->call(update_a => $a, 2)->result;
              >
              > again, object $a is updated if server is SOAP::Lite implementation
              >
              > 2. update_a returns modified object:
              >
              > $a = $soap->call(update_a => $a, 2)->result;
              >
              > again, object $a is updated regardless of server implementation,
              > because it IS the result itself.
              >
              > > What if you are using the call() syntax? Similar code? (I'd like to
              > > write
              > > wrappers and factories for my soap objects that are also
              > > interoperable with apache soap, possibly client and server.)
              > The only piece that is not interoperable is the magic that updates an
              > object itself as a side effect (AD.1. and OO.1.). Everything else
              > should work with any implementations (as soon as object
              > representations are similar on wire).
              >
              > Let me know if you face any problems.
              >
              > Best wishes, Paul.
              >
              > > > -----Original Message-----
              > > > From: Paul Kulchenko [mailto:paulclinger@...]
              > > > Sent: Friday, August 03, 2001 1:35 PM
              > > > To: soaplite@yahoogroups.com
              > > > Subject: Re: [soaplite] Persistent objects using call() syntax
              > > >
              > > >
              > > > Hi, Michael!
              > > >
              > > > --- Michael Percy <mpercy@...> wrote:
              > > > > my $obj = $soap->call(new => @parameters)->result;
              > > > > print $soap->call(method => $obj)->result;
              > > > > # $obj object will be updated here if necessary,
              > > > > # as if you call $obj->method() and method()
              > updates $obj
              > > > > # Update of modified object MAY not work if server on
              > > > another side
              > > > >
              > > > > # is not SOAP::Lite
              > > > >
              > > > > This is clear until it calls the "method" method, and I want to
              > > > > make sure I understand it fully.
              > > > That basically means that execution of any method call MAY have a
              > > > side effect as modification of object itself:
              > > >
              > > > $a = bless {a => 1} => 'A';
              > > > $a->update_a(2);
              > > >
              > > > say will update property 'a' and return old value '1'.
              > > >
              > > > In SOAP call you will see only result '1', but you're loosing
              > > side
              > > > effect. SOAP::Lite executes this code on server side as:
              > > >
              > > > $a->update_a(2); # regardless of using mode on client,
              > > > # autodispatch or ->call() interface
              > > >
              > > > AND it'll also return modified object back, so your application
              > > will
              > > > see $a as modified object. Other SOAP implementations WILL NOT
              > > return
              > > > you object back, so you're loosing this side effect. It is NOT a
              > > > problem if you application returns object itself on any property
              > > > modifications (as SOAP::Lite does ;)), because then object will
              > > be
              > > > returned as a result and you can write:
              > > >
              > > > $a = $a->update_a(2);
              > > >
              > > > to get desired effect.
              > > >
              > > > > (1) $soap is obviously a reference to a blessed SOAP::Lite
              > > object
              > > > > and remains so.
              > > > Correct.
              > > >
              > > > > (2) $obj is an actual object (reference) of the server-side
              > > class
              > > > > "CLASS".
              > > > $obj is something returned by server that is blessed into class
              > > > CLASS.
              > > >
              > > > > (3) The new() method of CLASS is invoked very similar to:
              > > > > (a) my $obj = CLASS->new(@parameters);
              > > > > because you do not have to pass the object as the first
              > > > > parameter.
              > > > Correct. Here is the small difference comparing to what Perl
              > > does.
              > > > SOAP::Lite DOES NOT pass class name as the first parameter during
              > > > this call. This information is extracted on server side from URI
              > > and
              > > > call is still executed as CLASS method call: CLASS->method
              > > >
              > > > > (4) The method() method of $obj (blessed CLASS) is invoked
              > > > > somehow differently, sort of like:
              > > > > (b) CLASS::method($obj, @parameters);
              > > > > even though the call() syntax looks like (a) above,
              > > > > suggesting it means this:
              > > > > (c) CLASS->method($obj, @parameters);
              > > > > or maybe
              > > > > (d) $obj->method($obj, @parameters);
              > > > It's always invoked as
              > > >
              > > > $obj->method(@parameters);
              > > >
              > > > Let me know if something is still unclear, I'll give you more
              > > > details.
              > > >
              > > > On related side. I plan to introduce option on client and server
              > > side
              > > > that will allow you to execute calls "as is" on server side,
              > > without
              > > > any parameters modifications. It'll allow you to do direct calls
              > > for
              > > > functions (it require wrappers right now, because all calls are
              > > > method calls) and allow to implement remote inheritance.
              > > >
              > > > Best wishes, Paul.
              > > >
              > >
              >
            Your message has been successfully submitted and would be delivered to recipients shortly.