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

1196Re: [soaplite] Re: Using SOAP::Transport::IO::Server to process request

Expand Messages
  • Paul Kulchenko
    Jan 29, 2002
      Hi, Ian!

      > Obviously, I don't want to have to write the SOAP request to a file
      > before I process it. Can someone suggest an alternative?
      It depends on what do you want to do ;).

      > -> in ( *CLIENT )
      > -> out( *CLIENT )
      This won't work. You can't easily read from and write to the same
      filehandle. From IPC::Open2:

      This whole affair is quite dangerous, as you may block forever. It
      assumes it's going to talk to something like B<bc>, both writing
      to it and reading from it. This is presumably safe because you
      "know" that commands like B<bc> will read a line at a time and
      output a line at a time. Programs like B<sort> that read their
      entire input stream first, however, are quite apt to cause deadlock.

      If you have file or stream you can use SOAP::Transport::IO to handle
      that. If you have HTTP, you can use SOAP::Transport::HTTP::* module
      to handle that. If you use combination of those and want to handle
      transport level yourself, you can use SOAP::Server to handle payload:

      $response_xml = SOAP::Server
      ->dispatch_to(...)
      ->handle($request_xml);

      In this case you don't need to create a file and then process it with
      ::IO transport. Hope it helps. Please provide little bit more details
      if you still have problems.

      Best wishes, Paul.

      --- iancrogers <ian@...> wrote:
      > I've sorted this out, somewhat.
      >
      > SOAP::Transport::IO::Server
      > -> new( )
      > -> in ( CLIENT )
      > -> out( CLIENT )
      > -> dispatch_to( 'MuseClient' )
      > -> handle
      > ;
      >
      > writes output to a file 'CLIENT'.
      >
      > The following gives the desired result by first writing the request
      >
      > to a file:
      >
      > open ( SO, "> INPUT.xml" );
      > $msg_body = "";
      > LINE: while ( recv( CLIENT, $buf, 1, 0 ) ) {
      > print SO $buf;
      > $msg_body .= $buf;
      > last LINE if ( $msg_body =~ /</SOAP-ENV:Envelope>/ );
      > }
      > close SO;
      >
      > print CLIENT "HTTP/1.1 200 OK
      ";
      > print CLIENT "Content-Type: text/xml

      ";
      >
      > SOAP::Transport::IO::Server
      > -> new( )
      > -> in ( 'INPUT.xml' )
      > -> out( *CLIENT )
      > -> dispatch_to( 'MuseClient' )
      > -> handle
      > ;
      >
      > This, however, blocks forever:
      >
      > SOAP::Transport::IO::Server
      > -> new( )
      > -> in ( *CLIENT )
      > -> out( *CLIENT )
      > -> dispatch_to( 'MuseClient' )
      > -> handle
      > ;
      >
      > Client is making the SOAP request as in the previous post:
      >
      > print SOAP::Lite
      > -> uri($soap_uri)
      > -> proxy($soap_proxy)
      > -> test_routine( $email, $password, $XML )
      > -> result . "
      ";
      >
      > I assume this is a buffering issue. The client doesn't send a
      > newline at the end of the request, and the read waits forever for
      > this last record separator. This is why while( <CLIENT> ) wasn't
      > working for me, I think, and I had to resort to reading one
      > character at a time.
      >
      > Obviously, I don't want to have to write the SOAP request to a file
      >
      > before I process it. Can someone suggest an alternative?
      >
      > Thanks in advance,
      > ian
      >
      >
      > ------------------------ 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!?
      Great stuff seeking new owners in Yahoo! Auctions!
      http://auctions.yahoo.com
    • Show all 5 messages in this topic