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

Re: [soaplite] does result have to be a hash ref

Expand Messages
  • Paul Kulchenko
    Hi, Joseph! ... Yes, because you already did - method() call. You don t need it: $response = SOAP::Lite - uri( http://tempuri.org/message/ ) -
    Message 1 of 7 , Sep 12, 2001
    • 0 Attachment
      Hi, Joseph!

      > Can't call method "valueof" on unblessed reference at GetShip line
      > 23.
      Yes, because you already did ->method() call. You don't need it:

      $response = SOAP::Lite
      -> uri('http://tempuri.org/message/')
      ->
      proxy('http://comac.litorders.com/SOAP/ListShipments.ASP')
      ->
      on_action(sub{'"http://tempuri.org/action/Shipments.ListShipments"'})
      -> ListShipments(SOAP::Data->type(xml => qq!$xml!))
      ;

      @array = $response->valueof('//SOAP-ENV:Body');

      result(), valueof(), dataof() and other methods operate on SOAP::SOM
      object which is returned by method call (ListShipments) in your case.

      '//SOAP-ENV:Body' will not work as expected. Either use '//Body' to
      match all Body elements, or use
      '//{http://schemas.xmlsoap.org/soap/envelope/}Body' to match based on
      namespace and localname. In any case valueof('//Body') will return
      only one element (unless you have multiple bodies), which is
      different from what you want. If you want to get immediate children
      of Body, you may write something like:

      @array = $response->valueof('//Body/[>0]');

      or if you know names (for example, 'item'), you can write:

      @array = $response->valueof('//item');

      Hope it helps.

      Best wishes, Paul.

      --- Joseph Norris <jozefn@...> wrote:
      >
      > Thanks Paul. However I run into this situation:
      >
      > I have built a very simple script to test the information in
      > the page you sent me.
      >
      > use SOAP::Lite;
      >
      > $response = SOAP::Lite
      > -> uri('http://tempuri.org/message/')
      > ->
      > proxy('http://comac.litorders.com/SOAP/ListShipments.ASP')
      > ->
      >
      on_action(sub{'"http://tempuri.org/action/Shipments.ListShipments"'})
      > -> ListShipments(SOAP::Data->type(xml => qq!$xml!))
      > -> method();
      >
      >
      > @array = $response->valueof('//SOAP-ENV:Body');
      > for (@array){
      > print "$_\n";
      > }
      >
      > when I run this script I get
      >
      > Can't call method "valueof" on unblessed reference at GetShip line
      > 23.
      >
      > 2 returned
      >
      > Where do I go from here?
      >
      >
      > #Joseph Norris (Perl - what else is there?/Linux/CGI/Mysql)
      > print @c=map chr
      > $_+100,(6,17,15,16,-68,-3,10,11,16,4,1,14,-68,12,1,14,8,
      > -68,4,-3,-1,7,1,14,-68,-26,11,15,1,12,4,-68,-22,11,14,14,5,15,-90);
      >
      >
      > On Tue, 11 Sep 2001, Paul Kulchenko wrote:
      >
      > > Hi, Joseph!
      > >
      > > Take a look here, it may answer your question
      > > http://groups.yahoo.com/group/soaplite/message/550
      > >
      > > You may also find useful section that describes SOAP::SOM in
      > > SOAP::Lite documentation. Hope it helps.
      > >
      > > Best wishes, Paul.
      > >
      > > --- Joseph Norris <jozefn@...> wrote:
      > > >
      > > > I have had some real success with my most recent soap projects,
      > but
      > > > still
      > > > a real newbie in use of Soap::Lite - so please bare with me.
      > > >
      > > > I have the following piece of soap code
      > > >
      > > >
      > > >
      > > > $xml =
      > > >
      > qq!<XMLQuery><ListShipment><SOAPClientID>XXX</SOAPClientID><where
      > > > col='OrderDes
      > > > cription' comp='Equals'
      > > > value='$value'/></ListShipment></XMLQuery>!;
      > > >
      > > >
      > > >
      > > > use SOAP::Lite;
      > > >
      > > > $soap_response = SOAP::Lite
      > > > -> uri('http://tempuri.org/message/')
      > > > ->
      > > > proxy('http://comac.litorders.com/SOAP/ListShipments.ASP')
      > > > ->
      > > >
      > >
      >
      on_action(sub{'"http://tempuri.org/action/Shipments.ListShipments"'})
      > > > -> ListShipments(SOAP::Data->type(xml => qq!$xml!))
      > > > -> result;
      > > >
      > > >
      > > > $soap_response is a hash ref that I can get at with
      > Data::Dumper.
      > > > However
      > > > this returns hashes. It just so happens that the return of this
      > > > data has
      > > > multiple tags of the same name. I need to get the data from all
      > of
      > > > the
      > > > tags but because these tags become keys in the hash - I am only
      > > > getting the
      > > > last set of tag data that I need. I am not sure how (or if) I
      > get
      > > > the
      > > > soap_response as an array ref so that I can get all of the
      > > > information.
      > > >
      > > > Any and all suggestions would be appreciated.
      > > >
      > > > Thanks.
      > > >
      > > >
      > > > #Joseph Norris (Perl - what else is there?/Linux/CGI/Mysql)
      > > > print @c=map chr
      > > > $_+100,(6,17,15,16,-68,-3,10,11,16,4,1,14,-68,12,1,14,8,
      > > >
      > -68,4,-3,-1,7,1,14,-68,-26,11,15,1,12,4,-68,-22,11,14,14,5,15,-90);
      > > >
      > > >
      > > >
      > > > ------------------------ 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!?
      > > Get email alerts & NEW webcam video instant messaging with Yahoo!
      > Messenger
      > > http://im.yahoo.com
      > >
      > >
      > > 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!?
      Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
      http://im.yahoo.com
    • J Landman
      I am using SOAP::Lite for a project, and it is wonderful. Of course, I ran into something that I hoped would not be hard to solve. What I want to do is quite
      Message 2 of 7 , Sep 12, 2001
      • 0 Attachment
        I am using SOAP::Lite for a project, and it is wonderful. Of course, I
        ran into something that I hoped would not be hard to solve. What I want
        to do is quite simple to state. I want to (within SOAP::Lite) send an
        object to a method, and simply have the call return right away without
        waiting for the method to return a result. That is, the method has
        desireable side effects, and no real return information.

        Currently I have to look at either polling a queue that the method places
        an entry into, or forking a process. I want something more like "fire and
        forget", or basic messaging. Can this be done easily within SOAP::Lite?
        Suppose we had a method named return_immediately rather than result, so
        that our calls might look like

        SOAP::Lite
        ->uri(/.../)->dispatch_to(/.../)->method(@args)->return_immediately

        Clues/hints welcome. Thanks!




        --
        Joe Landman,
        landman@...
      • Duncan Cameron
        Joe Bearing in mind that http is a send/receive protocol and that the client probably wants to know that a message did reach the server then this can be
        Message 3 of 7 , Sep 13, 2001
        • 0 Attachment
          Joe

          Bearing in mind that http is a send/receive protocol and that the client probably wants to know that a message did reach the server then this can be handled on the server in a slightly crude way. Override the handle() method in SOAP::Transport::HTTP::Daemon so that a response (200 OK) is sent back immediately, e.g. in your soapd.pl include the following:

          package SOAP::Transport::HTTP::Daemon;

          sub handle {
          my $self = shift->new;
          while (my $c = $self->accept) {
          while (my $r = $c->get_request) {
          $self->request($r);
          $c->send_response(HTTP::Response->new(200));
          $self->SUPER::handle;
          }
          $c->close;
          undef $c;
          }
          }

          package main;

          Your client needs to then test for that particular return code

          $s->echo(SOAP::Data->name(text => $value));
          die 'dying ...', $s->transport->status
          unless $s->transport->status =~ m/200 OK/i;
          print "it seems to have worked!\n";

          If you really want to handle this on the client, then you can look at overriding the send_receive() method in SOAP::Transport:HTTP::Client so that it only sends. If you're really not worried about responses or even errors then you might want to use the tcp transport instead of http.

          I imagine Paul will have a cleaner way of handling this.

          Duncan Cameron

          On 12/09/2001 J Landman <landman@...> wrote:
          >I am using SOAP::Lite for a project, and it is wonderful. Of course, I
          >ran into something that I hoped would not be hard to solve. What I want
          >to do is quite simple to state. I want to (within SOAP::Lite) send an
          >object to a method, and simply have the call return right away without
          >waiting for the method to return a result. That is, the method has
          >desireable side effects, and no real return information.
          >
          >Currently I have to look at either polling a queue that the method places
          >an entry into, or forking a process. I want something more like "fire and
          >forget", or basic messaging. Can this be done easily within SOAP::Lite?
          >Suppose we had a method named return_immediately rather than result, so
          >that our calls might look like
          >
          > SOAP::Lite
          >->uri(/.../)->dispatch_to(/.../)->method(@args)->return_immediately
          >
          > Clues/hints welcome. Thanks!
          >
          >
          >
          >
          > --
          > Joe Landman,
          > landman@...
        • Paul Kulchenko
          Hi, Joe! ... As Duncan already pointed it depends on transport protocols. HTTP is request/response protocol by nature, so you need to return something. It
          Message 4 of 7 , Sep 14, 2001
          • 0 Attachment
            Hi, Joe!

            > object to a method, and simply have the call return right away
            > without waiting for the method to return a result.
            As Duncan already pointed it depends on transport protocols. HTTP is
            request/response protocol by nature, so you need to return something.
            It might be 202 ACCEPTED or 204 NO CONTENT code, but something must
            be returned, otherwise client won't be able to distinguish between
            broken connection and legitimate lack of response. To do that, you
            may override make_response method on server side that which returns
            HTTP::Response object and put any information you need there. You
            will need to check status on client side
            ($soap->transport->is_success will return true when 2xx status code
            returned).

            Let me know if you still have a questions or need examples on how to
            do that.

            Best wishes, Paul.

            --- J Landman <landman@...> wrote:
            > I am using SOAP::Lite for a project, and it is wonderful. Of
            > course, I
            > ran into something that I hoped would not be hard to solve. What I
            > want
            > to do is quite simple to state. I want to (within SOAP::Lite) send
            > an
            > object to a method, and simply have the call return right away
            > without
            > waiting for the method to return a result. That is, the method has
            > desireable side effects, and no real return information.
            >
            > Currently I have to look at either polling a queue that the method
            > places
            > an entry into, or forking a process. I want something more like
            > "fire and
            > forget", or basic messaging. Can this be done easily within
            > SOAP::Lite?
            > Suppose we had a method named return_immediately rather than
            > result, so
            > that our calls might look like
            >
            > SOAP::Lite
            > ->uri(/.../)->dispatch_to(/.../)->method(@args)->return_immediately
            >
            > Clues/hints welcome. Thanks!
            >
            >
            >
            >
            > --
            > Joe Landman,
            > landman@...
            >
            >
            >
            > ------------------------ 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/
            >
            >


            __________________________________________________
            Terrorist Attacks on U.S. - How can you help?
            Donate cash, emergency relief information
            http://dailynews.yahoo.com/fc/US/Emergency_Information/
          Your message has been successfully submitted and would be delivered to recipients shortly.