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

Re: [soaplite] SSH as a transport

Expand Messages
  • Scott Bolte
    Hi Christer, ... Yes and no. The methods the server loads are portable for use with HTTP, et. al. Only the server invocation is tied to my SOAP::Transport::Cmd
    Message 1 of 1 , May 2, 2002
    • 0 Attachment
      Hi Christer,

      > However, although it would probably not be very hard to use the IO
      > transport to set up stdin/stdout piped through SSH as the transport, you
      > will miss one of the key reasons to use SOAP in the first place, which
      > is interoperability. You can't expect Java, Visual Basic, etc. to allow
      > you to do the same thing. At least not easily.

      Yes and no. The methods the server loads are portable
      for use with HTTP, et. al. Only the server invocation
      is tied to my SOAP::Transport::Cmd module. (See sample
      server invocation below.)

      > The performance would also not be very good, because the SSH server
      > would have to start up your Perl server program for every transaction,
      > just like a CGI server. In my experience, it takes about a second to
      > compile and start the SOAP::Lite server.

      You're absolutely right about the cost of setup. That's
      why, as I described in another mail message, I added support
      to send multiple requests and process multiple responses
      over the same connection. (See full server handler below)

      > Based on that, I would say that SSL or HTTPS is a better solution. If
      > you don't have a certificate you just generate one, just as you would
      > generate an SSH key pair.

      I find it much easier to manage multiple ssh certificates.
      On the other hand, my purpose is a secure, dedicated
      infrastructure so general purpose access (via SSL) is not
      a priority.

      Scott



      _______ sample server invocation:
      /
      | use SOAP::Transport::Cmd::Server;
      | SOAP::Transport::Cmd::Server::LOG($LOG);
      | use GCG::SOAP::WWW qw(SOAP_methods_prod SOAP_methods_dev);
      |
      | my(@methods) = GCG::SOAP::WWW::SOAP_methods_prod();
      | push(@methods, GCG::SOAP::WWW::SOAP_methods_devel()) if $devel;
      | SOAP::Transport::Cmd::Server
      | ->new
      | ->dispatch_to("$ENV{HOME}/cells/live/lib/perl5/GCG/SOAP", @methods)
      | ->handle;
      | exit(0);


      _______ Handler for SOAP::Transport::Server
      /
      | #
      | # Modeled after SOAP::Transport::IO::Server::handle. The difference is
      | # that this handle() does not require a full buffer of data before it
      | # proceeds. (In other words, it does not do a "join('', <>)".) Instead,
      | # it peels off each envelope as it arrives and deals with it
      | # immediately.
      | #
      | sub handle {
      | my $self = shift->new;
      |
      | $self->in(*STDIN)->out(*STDOUT) unless defined $self->in;
      | my $in = $self->in;
      | my $out = $self->out;
      |
      | #
      | # Must be unbuffered output.
      | #
      | if (defined($out)) {
      | my($oldfh) = select($out);
      | $| = 1;
      | select($oldfh)
      | };
      |
      | #
      | # Accumulate data until the other side is closed and sysread()
      | # returns undef.
      | #
      | my($bytes) = "";
      | my($line);
      | my($red);
      | while($red = sysread(STDIN, $line, 4096)) {
      | $bytes .= $line;
      | #
      | # Peel off each full envelope as we receive it and have
      | # the base server handle it.
      | #
      | while ($bytes =~ s%(<\?xml[^>]+\?>\s*<([^\s>]+).*?</\2>)%%s) {
      | my($env) = $1;
      |
      | my $result = SOAP::Server::handle($self, $env);
      |
      | print {$out} $result if defined $out;
      | }
      | }
      | }
    Your message has been successfully submitted and would be delivered to recipients shortly.