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

RE: [soaplite] persistent server-side state

Expand Messages
  • Sean.Meisner@VerizonWireless.com
    Hi Greg, You really haven t provided enough code to do more than guess at the problem. But, at a guess, I wonder if you are using object_by_reference here. If
    Message 1 of 5 , Sep 30, 2002
    • 0 Attachment
      Hi Greg,

      You really haven't provided enough code to do more than
      guess at the problem.

      But, at a guess, I wonder if you are using object_by_reference
      here. If not, you probably should.

      Cheers,

      Sean


      > -----Original Message-----
      > From: Gregory C. Harfst [mailto:gch@...]
      > Sent: Saturday, September 28, 2002 6:44 PM
      > To: soaplite@yahoogroups.com
      > Subject: [soaplite] persistent server-side state
      >
      >
      >
      > Hello,
      >
      > I want to write a TCP server that
      > maintains persistent state on the
      > server. For example, I want to
      > dispatch to a module:
      >
      > package ORNet::DBServer;
      >
      > use strict;
      >
      > my $foo = 1;
      >
      > sub inc {
      > return $foo++;
      > }
      >
      >
      > 1;
      >
      > So $foo should be incremented by
      > 1 on the server each time inc() is
      > called from any client.
      >
      > This works when I use use autodispatch
      > on the client. It doesn't work when
      > I use OO-style on the client.
      >
      > Can somebody tell me what's going on
      > here?
      >
      > Thanks,
      > Greg Harfst
      >
      >
      >
      > ------------------------ Yahoo! Groups Sponsor
      > ---------------------~-->
      > Plan to Sell a Home?
      > http://us.click.yahoo.com/J2SnNA/y.lEAA/MVfIAA/W6uqlB/TM
      > --------------------------------------------------------------
      > -------~->
      >
      > 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/
    • Keanan Smith
      The problem with keeping server-side state is that HTTP requests are by definition stateless, if you need to maintain state, you ll have to do it externally,
      Message 2 of 5 , Sep 30, 2002
      • 0 Attachment
        The problem with keeping server-side state is that HTTP requests are by
        definition stateless, if you need to maintain state, you'll have to do it
        externally, or through some 'special' means (Like the Apache:: modules) if
        your service is created via CGI, you have an entirely new copy of the
        iterpreter, (Hence no way to maintain state between invocations, without
        doing it yourself)

        To really have any kind of reasonable way to do what you want (I'm assuming
        you want a 'general' state rather than a session-dependant state, because it
        would be easy enough to tuck your session-dependant state into objects that
        get passed with each call) You'll need to keep track of it server-side, and
        it will have to be proof against race conditions (Where multiple calls hit
        the server at the same moment)

        So:

        one way to keep state is to dump it all out to a file and make sure you
        flock it (Thereby insuring only one of your services has access to it at a
        time)

        Another is to use a database (Pretty common, great for long-term flexibility
        and interactivity)

        Another is to use mod_perl and keep your 'state' somewhere safe (Like in the
        server namespace or something)

        In any case, there's no "quick and dirty" way to do what you want to simply.

        -----Original Message-----
        From: Gregory C. Harfst [mailto:gch@...]
        Sent: Saturday, September 28, 2002 4:44 PM
        To: soaplite@yahoogroups.com
        Subject: [soaplite] persistent server-side state



        Hello,

        I want to write a TCP server that
        maintains persistent state on the
        server. For example, I want to
        dispatch to a module:

        package ORNet::DBServer;

        use strict;

        my $foo = 1;

        sub inc {
        return $foo++;
        }


        1;

        So $foo should be incremented by
        1 on the server each time inc() is
        called from any client.

        This works when I use use autodispatch
        on the client. It doesn't work when
        I use OO-style on the client.

        Can somebody tell me what's going on
        here?

        Thanks,
        Greg Harfst




        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/
      • Gregory C. Harfst
        Okay, here is a more detailed example of what I m seeing. I have a simple server that provides an inc() function, as mentioned in my previous post. I do not
        Message 3 of 5 , Oct 2, 2002
        • 0 Attachment
          Okay, here is a more detailed example
          of what I'm seeing. I have a simple
          server that provides an inc() function,
          as mentioned in my previous post. I do
          not understand the output that I'm seeing
          from my OO-style client.

          Client with autodispatch (dbclient.pl):
          ------------------------------------------

          use SOAP::Lite +autodispatch =>
          uri => 'http://www.soaplite.com/ORNet/DBServer',
          proxy => 'tcp://localhost:8002', # local tcp server
          on_fault => sub { my($soap, $res) = @_;
          die ref $res ? $res->faultdetail :
          $soap->transport->status, "\n";
          }
          ;

          print inc(1), "\n\n";
          print inc(1), "\n\n";

          ------------------------------------------


          Client with OO-style (dbclientoo.pl):
          ------------------------------------------
          use SOAP::Lite;
          my $client = SOAP::Lite->
          new(uri => 'http://www.soaplite.com/ORNet/DBServer',
          proxy => 'tcp://localhost:8002', # local tcp server
          on_fault => sub { my($soap, $res) = @_;
          die ref $res ? $res->faultdetail : $soap->transport->status, "\n";
          }
          );


          print $client->inc(1), "\n\n";
          print $client->inc(1), "\n\n";
          ------------------------------------------

          If I run "./dbclient.pl", followed by "./dbclientoo.pl",
          followed by dbclient, I see:

          $ ./dbclient.pl
          2

          4

          $ ./dbclientoo.pl
          1

          1

          $ ./dbclient.pl
          10

          12


          Why am I not seeing 6 and 8 from the
          dbclientoo, as I expect, even though
          the variable is being updated on the
          server.

          Also, I have two other issues. First, I'm getting
          the error:

          "Use of inherited AUTOLOAD for non-method main::inc()
          is deprecated at ./dbclient.pl line 13."

          Second, if I don't supply a parameter to the inc()
          function I get the error:

          "Use of uninitialized value in string eq at
          /usr/lib/perl5/site_perl/5.6.1/SOAP/Lite.pm line 2602."


          Thank you,
          Greg Harfst



          On Mon, 30 Sep 2002 Sean.Meisner@... wrote:

          > Hi Greg,
          >
          > You really haven't provided enough code to do more than
          > guess at the problem.
          >
          > But, at a guess, I wonder if you are using object_by_reference
          > here. If not, you probably should.
          >
          > Cheers,
          >
          > Sean
          >
          >
          > > -----Original Message-----
          > > From: Gregory C. Harfst [mailto:gch@...]
          > > Sent: Saturday, September 28, 2002 6:44 PM
          > > To: soaplite@yahoogroups.com
          > > Subject: [soaplite] persistent server-side state
          > >
          > >
          > >
          > > Hello,
          > >
          > > I want to write a TCP server that
          > > maintains persistent state on the
          > > server. For example, I want to
          > > dispatch to a module:
          > >
          > > package ORNet::DBServer;
          > >
          > > use strict;
          > >
          > > my $foo = 1;
          > >
          > > sub inc {
          > > return $foo++;
          > > }
          > >
          > >
          > > 1;
          > >
          > > So $foo should be incremented by
          > > 1 on the server each time inc() is
          > > called from any client.
          > >
          > > This works when I use use autodispatch
          > > on the client. It doesn't work when
          > > I use OO-style on the client.
          > >
          > > Can somebody tell me what's going on
          > > here?
          > >
          > > Thanks,
          > > Greg Harfst
          > >
          > >
          > >
          > > ------------------------ Yahoo! Groups Sponsor
          > > ---------------------~-->
          > > Plan to Sell a Home?
          > > http://us.click.yahoo.com/J2SnNA/y.lEAA/MVfIAA/W6uqlB/TM
          > > --------------------------------------------------------------
          > > -------~->
          > >
          > > 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/
          >
          >
          >
          > 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/
          >
          >
        • Paul Kulchenko
          Hi Gregory, ... since you re not using autodispatch in this case, the code should look like this: print $client- inc(1)- result, n n ; What you see is the
          Message 4 of 5 , Oct 2, 2002
          • 0 Attachment
            Hi Gregory,

            > print $client->inc(1), "\n\n";
            since you're not using autodispatch in this case, the code should
            look like this:

            print $client->inc(1)->result, "\n\n";

            What you see is the result of SOAP::SOM object beeing evaluated in
            scalar/list context.

            > "Use of inherited AUTOLOAD for non-method main::inc()
            > is deprecated at ./dbclient.pl line 13."
            You can't really do anything about this warning (and I'm not sure
            what I can do either), only perhaps wrap it into the block with
            disabled warnings:

            { local $^W;
            # your call here
            }

            > "Use of uninitialized value in string eq at
            > /usr/lib/perl5/site_perl/5.6.1/SOAP/Lite.pm line 2602."
            is it on client or server side? I need to look at it. What version of
            SOAP::Lite are you using?

            Best wishes, Paul.

            --- "Gregory C. Harfst" <gch@...> wrote:
            >
            > Okay, here is a more detailed example
            > of what I'm seeing. I have a simple
            > server that provides an inc() function,
            > as mentioned in my previous post. I do
            > not understand the output that I'm seeing
            > from my OO-style client.
            >
            > Client with autodispatch (dbclient.pl):
            > ------------------------------------------
            >
            > use SOAP::Lite +autodispatch =>
            >
            > uri => 'http://www.soaplite.com/ORNet/DBServer',
            > proxy => 'tcp://localhost:8002', # local tcp server
            > on_fault => sub { my($soap, $res) = @_;
            > die ref $res ? $res->faultdetail :
            > $soap->transport->status, "\n";
            >
            >
            > }
            > ;
            >
            > print inc(1), "\n\n";
            > print inc(1), "\n\n";
            >
            > ------------------------------------------
            >
            >
            > Client with OO-style (dbclientoo.pl):
            > ------------------------------------------
            > use SOAP::Lite;
            >
            > my $client = SOAP::Lite->
            > new(uri => 'http://www.soaplite.com/ORNet/DBServer',
            > proxy => 'tcp://localhost:8002', # local tcp server
            > on_fault => sub { my($soap, $res) = @_;
            > die ref $res ? $res->faultdetail : $soap->transport->status,
            > "\n";
            > }
            > );
            >
            >
            > print $client->inc(1), "\n\n";
            > print $client->inc(1), "\n\n";
            > ------------------------------------------
            >
            > If I run "./dbclient.pl", followed by "./dbclientoo.pl",
            > followed by dbclient, I see:
            >
            > $ ./dbclient.pl
            > 2
            >
            > 4
            >
            > $ ./dbclientoo.pl
            > 1
            >
            > 1
            >
            > $ ./dbclient.pl
            > 10
            >
            > 12
            >
            >
            > Why am I not seeing 6 and 8 from the
            > dbclientoo, as I expect, even though
            > the variable is being updated on the
            > server.
            >
            > Also, I have two other issues. First, I'm getting
            > the error:
            >
            > "Use of inherited AUTOLOAD for non-method main::inc()
            > is deprecated at ./dbclient.pl line 13."
            >
            > Second, if I don't supply a parameter to the inc()
            > function I get the error:
            >
            > "Use of uninitialized value in string eq at
            > /usr/lib/perl5/site_perl/5.6.1/SOAP/Lite.pm line 2602."
            >
            >
            > Thank you,
            > Greg Harfst
            >
            >
            >
            > On Mon, 30 Sep 2002 Sean.Meisner@... wrote:
            >
            > > Hi Greg,
            > >
            > > You really haven't provided enough code to do more than
            > > guess at the problem.
            > >
            > > But, at a guess, I wonder if you are using object_by_reference
            > > here. If not, you probably should.
            > >
            > > Cheers,
            > >
            > > Sean
            > >
            > >
            > > > -----Original Message-----
            > > > From: Gregory C. Harfst [mailto:gch@...]
            > > > Sent: Saturday, September 28, 2002 6:44 PM
            > > > To: soaplite@yahoogroups.com
            > > > Subject: [soaplite] persistent server-side state
            > > >
            > > >
            > > >
            > > > Hello,
            > > >
            > > > I want to write a TCP server that
            > > > maintains persistent state on the
            > > > server. For example, I want to
            > > > dispatch to a module:
            > > >
            > > > package ORNet::DBServer;
            > > >
            > > > use strict;
            > > >
            > > > my $foo = 1;
            > > >
            > > > sub inc {
            > > > return $foo++;
            > > > }
            > > >
            > > >
            > > > 1;
            > > >
            > > > So $foo should be incremented by
            > > > 1 on the server each time inc() is
            > > > called from any client.
            > > >
            > > > This works when I use use autodispatch
            > > > on the client. It doesn't work when
            > > > I use OO-style on the client.
            > > >
            > > > Can somebody tell me what's going on
            > > > here?
            > > >
            > > > Thanks,
            > > > Greg Harfst
            > > >
            > > >
            > > >
            > > > ------------------------ Yahoo! Groups Sponsor
            > > > ---------------------~-->
            > > > Plan to Sell a Home?
            > > > http://us.click.yahoo.com/J2SnNA/y.lEAA/MVfIAA/W6uqlB/TM
            > > > --------------------------------------------------------------
            > > > -------~->
            > > >
            > > > 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/
            > >
            > >
            > >
            > > 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/
            > >
            > >
            >
            >
            > ------------------------ 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!?
            New DSL Internet Access from SBC & Yahoo!
            http://sbc.yahoo.com
          Your message has been successfully submitted and would be delivered to recipients shortly.