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

Yet another dumb question

Expand Messages
  • Joe Landman
    Thanks to those who suggested reading portions of the man page. I did misread them. The suggested changes worked for my example. Thank you all. And this
    Message 1 of 3 , Mar 14, 2002
      Thanks to those who suggested reading portions of the man page. I did
      misread them.

      The suggested changes worked for my example. Thank you all.

      And this leads me to another question. The tests were my about the 10th
      codes I worked on, the others seemingly functioning perfectly. In fact,
      all I had done was to copy of the stuff that had been working so nicely
      for me for the last 6 months or so.

      In those codes I am doing things like this on the server side:

      my $daemon= SOAP::Transport::HTTP::Daemon
      -> new (
      LocalPort => 10101,
      Listen => 10,
      Reuse => 1
      )
      ->dispatch_to('ximple')
      ->objects_by_reference(qw(ximple));
      print "ximple server at ", join(':', $daemon->sockhost, $daemon->sockport), "\n";
      print "waiting for connection ...\n";
      $daemon ->handle;

      and like this on the client side


      $soap = SOAP::Lite
      -> uri('http://localhost/ximple')
      -> proxy('http://localhost:10101/');

      $rc = $soap
      -> call(qw(new))
      -> result;
      .
      .
      .
      %header=(...);
      .
      .
      .

      $rc = $soap
      -> receive_filename_and_header(%header)
      -> result ;

      and it works perfectly. So I am trying to get my mind around why I need
      to use the other method

      $obj = $soap->call(qw(new))->result;
      $rc = $soap->call(some_other_method => $obj)->result;

      For sanity-checking sake, I reran my older codes, which did the former,
      and they worked perfectly. For the latter model, I cannot figure out
      how to pass arguments to the some_other_method from the man page. Does
      someone have a really simple example I can look at? I am just missing
      something critical.

      Moreover, I cannot for the life of me figure out the differences in the
      codes between the old server and new server (actually the new server is
      identical to the old one), and the new client and the old client. The
      only thing I can think of is that I am building my SOAP objects in the
      main program in the old client, and building them in a module/package in
      the new program. I seem to remember having all manner of bad luck in
      the past building SOAP objects inside other perl modules (and not
      main::) using SOAP::Lite. Is there any special utterances I need for
      the envelopes, or the headers, or whatnot else?

      Just trying to understand this... really confused.

      Joe
    • Duncan Cameron
      ... You dont *have* to use it, I thought that you wanted to use it! The first approach is non OO (Object-Oriented) as the result of the new() method is not an
      Message 2 of 3 , Mar 14, 2002
        On 2002-03-14 Joe Landman wrote:
        >Thanks to those who suggested reading portions of the man page. I did
        >misread them.
        >
        >The suggested changes worked for my example. Thank you all.
        >
        >And this leads me to another question. The tests were my about the 10th
        >codes I worked on, the others seemingly functioning perfectly. In fact,
        >all I had done was to copy of the stuff that had been working so nicely
        >for me for the last 6 months or so.
        >
        >In those codes I am doing things like this on the server side:
        >
        > my $daemon= SOAP::Transport::HTTP::Daemon
        > -> new (
        > LocalPort => 10101,
        > Listen => 10,
        > Reuse => 1
        > )
        > ->dispatch_to('ximple')
        > ->objects_by_reference(qw(ximple));
        > print "ximple server at ", join(':', $daemon->sockhost, $daemon->sockport), "\n";
        > print "waiting for connection ...\n";
        > $daemon ->handle;
        >
        >and like this on the client side
        >
        >
        > $soap = SOAP::Lite
        > -> uri('http://localhost/ximple')
        > -> proxy('http://localhost:10101/');
        >
        > $rc = $soap
        > -> call(qw(new))
        > -> result;
        > .
        > .
        > .
        > %header=(...);
        > .
        > .
        > .
        >
        > $rc = $soap
        > -> receive_filename_and_header(%header)
        > -> result ;
        >
        >and it works perfectly. So I am trying to get my mind around why I need
        >to use the other method
        You dont'*have* to use it, I thought that you wanted to use it!

        The first approach is non OO (Object-Oriented) as the result of the new()
        method is not an object in your client. So when you invoke a further method
        such as receive_filename_and_header(%header), that call is not in the
        context of the value returned from new();
        >
        > $obj = $soap->call(qw(new))->result;
        > $rc = $soap->call(some_other_method => $obj)->result;
        >
        This approach is kind-of OO, as your 'object' returned by new() is
        now passed back to the server and can be used within your server's
        methods, usually as the $self variable

        sub method1 {
        my ($self, %params) = @_;
        # do something based on $self
        }

        >For sanity-checking sake, I reran my older codes, which did the former,
        >and they worked perfectly. For the latter model, I cannot figure out
        >how to pass arguments to the some_other_method from the man page. Does
        >someone have a really simple example I can look at? I am just missing
        >something critical.
        To pass parameters in the second approach:
        $obj = $soap->call('new')->result;
        $rc = $soap->call(some_other_method => $obj, $p1, $p2)->result;

        Your server method then should be something like:
        sub some_other_method {
        my ($self, $p1, $p2) = @_;
        # do something based on $self
        }
        >
        >Moreover, I cannot for the life of me figure out the differences in the
        >codes between the old server and new server (actually the new server is
        >identical to the old one), and the new client and the old client. The
        >only thing I can think of is that I am building my SOAP objects in the
        >main program in the old client, and building them in a module/package in
        >the new program. I seem to remember having all manner of bad luck in
        >the past building SOAP objects inside other perl modules (and not
        >main::) using SOAP::Lite. Is there any special utterances I need for
        >the envelopes, or the headers, or whatnot else?

        Maybe it's the local/remote object approach that's causing the difficulty.
        I guess that the docs assume that the reader is up to speed on that.
        I would guess that most applications don't need to pass objects around,
        simple remote method calls would suffice.

        Regards,
        Duncan Cameron
      • Jim Dixon
        ... You aren t passing any arguments to new(). The qw is at least unnecessary. Pass arguments like this: $rc = $soap- call(new = @parameters) ... You can of
        Message 3 of 3 , Mar 15, 2002
          On 14 Mar 2002, Joe Landman wrote:

          > In those codes I am doing things like this on the server side:
          >
          > my $daemon= SOAP::Transport::HTTP::Daemon
          > -> new (
          > LocalPort => 10101,
          > Listen => 10,
          > Reuse => 1
          > )
          > ->dispatch_to('ximple')
          > ->objects_by_reference(qw(ximple));
          > print "ximple server at ", join(':', $daemon->sockhost, $daemon->sockport), "\n";
          > print "waiting for connection ...\n";
          > $daemon ->handle;
          >
          > and like this on the client side
          >
          > $soap = SOAP::Lite
          > -> uri('http://localhost/ximple')
          > -> proxy('http://localhost:10101/');
          >
          > $rc = $soap
          > -> call(qw(new))

          You aren't passing any arguments to new(). The qw is at least
          unnecessary.

          Pass arguments like this:

          $rc = $soap->call(new => @parameters)

          > -> result;

          You can of course replace @parameters with the actual parameters.

          --
          Jim Dixon jdd@... tel +44 117 982 0786 mobile +44 797 373 7881
          ---------- THAT'S A CHANGE OF ADDRESS: I'm no longer jdd@... --------
        Your message has been successfully submitted and would be delivered to recipients shortly.