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

SOAP-call without doing HTTP

Expand Messages
  • Marten Lehmann
    Hello, I d like to change the following code so that SOAP::Lite generates the xml-message, but doesn t post them. Instead I want to do the http-connection
    Message 1 of 3 , Sep 6, 2002
    • 0 Attachment
      Hello,

      I'd like to change the following code so that SOAP::Lite generates the
      xml-message, but doesn't post them. Instead I want to do the
      http-connection handling and feed SOAP::Lite with the response I get.

      use SOAP::Lite;
      use strict;

      my ($domain, $soap, $code, $msg);

      $soap = SOAP::Lite
      -> uri('DomainTools')
      -> proxy('http://soap.variomedia.de/public/');

      $domain = shift @ARGV;
      ($code, $message) = @{$soap->getDomainStatus($domain)->result};
      print "$domain: [$code] [$msg]";

      Wherefor I need this is as follows: I want to do several SOAP-calls at
      the same time, but with SOAP::Lite I have to wait until I receive a
      response for the current SOAP-call. So I want to syswrite the
      xml-message on my own to the http-servers and sysread the responses as
      they come - nonblocked of course. After fully retrieved the response I
      again want to use SOAP::Lite to do the parsing.

      Regards
      Marten
    • Duncan Cameron
      ... Have a look at the call() method in the SOAP::Lite package. It may give you some ideas about how to create the SOAP envelope for sending and how to handle
      Message 2 of 3 , Sep 6, 2002
      • 0 Attachment
        On 2002-09-06 Marten Lehmann wrote:
        >Hello,
        >
        >I'd like to change the following code so that SOAP::Lite generates the
        >xml-message, but doesn't post them. Instead I want to do the
        >http-connection handling and feed SOAP::Lite with the response I get.
        >
        >use SOAP::Lite;
        >use strict;
        >
        >my ($domain, $soap, $code, $msg);
        >
        >$soap = SOAP::Lite
        > -> uri('DomainTools')
        > -> proxy('http://soap.variomedia.de/public/');
        >
        >$domain = shift @ARGV;
        >($code, $message) = @{$soap->getDomainStatus($domain)->result};
        >print "$domain: [$code] [$msg]";
        >
        >Wherefor I need this is as follows: I want to do several SOAP-calls at
        >the same time, but with SOAP::Lite I have to wait until I receive a
        >response for the current SOAP-call. So I want to syswrite the
        >xml-message on my own to the http-servers and sysread the responses as
        >they come - nonblocked of course. After fully retrieved the response I
        >again want to use SOAP::Lite to do the parsing.
        >

        Have a look at the call() method in the SOAP::Lite package. It may
        give you some ideas about how to create the SOAP envelope for
        sending and how to handle the received envelope.

        Regards,
        Duncan Cameron
      • jpeyser
        Marten, The following program solves the first part of your dilemma. This will create the XML code for each request without sending out anything. Jonathan
        Message 3 of 3 , Sep 10, 2002
        • 0 Attachment
          Marten,
          The following program solves the first part of your dilemma. This
          will create the XML code for each request without sending out
          anything.

          Jonathan

          #!/usr/local/bin/perl -w

          # -- SOAP::Lite -- guide.soaplite.com -- Copyright (C) 2001 Paul
          Kulchenko --
          # My packages by J. Peyser

          use SOAP::Lite;
          use SOAP::Transport::HTTP;


          sub BEGIN {
          package My::Transport;

          @ISA = qw(SOAP::Transport);

          ### Sub proxy redefined to eliminate lines searching for transport
          module.
          sub proxy {
          my $self = shift->new;
          my $class = ref $self;

          return $self->{_proxy} unless @_;
          $_[0] =~ /^(\w+):/ or die "proxy: transport protocol not
          specified\n";
          my $protocol = uc "$1"; # untainted now
          # https: should be done through Transport::HTTP.pm
          for ($protocol) { s/^HTTPS$/HTTP/ }

          (my $protocol_class = "${class}::$protocol") =~ s/-/_/g;
          no strict 'refs';
          unless (defined %{"$protocol_class\::Client::"} &&
          UNIVERSAL::can("$protocol_class\::Client" => 'new')) {
          # eval "require $protocol_class";
          # die "Unsupported protocol '$protocol'\n" if $@ =~ m!
          ^Can't locate SOAP/Transport/!;
          # die if $@;
          }
          $protocol_class .= "::Client";
          return $self->{_proxy} = $protocol_class->new(endpoint => shift,
          @_);
          }


          package My::Transport::HTTP::Client;

          @ISA = qw(SOAP::Transport::HTTP::Client);
          @xml = ();

          ### Sub send_receive redefined to bypass HTTP or any other transport
          protocol.
          sub send_receive {
          my($self, %parameters) = @_;
          my($envelope, $endpoint, $action, $encoding) =
          @parameters{qw(envelope endpoint action encoding)};

          push @xml, $envelope;
          $self->is_success(1);

          return;
          }

          } #End BEGIN


          die "Usage: $0 <symbol>...\n" unless $#ARGV > -1;

          my ($domain, $soap, $code, $msg, $message);

          $soap = SOAP::Lite
          -> uri('DomainTools')
          -> transport(My::Transport->new)
          -> proxy('http://soap.variomedia.de/public/');

          while ($domain = shift) {

          $soap->getDomainStatus($domain);
          # ($code, $message) = @{$soap->getDomainStatus($domain)-
          >result};
          # print "$domain: [$code] [$msg]";

          }

          foreach (@My::Transport::HTTP::Client::xml) {print $_, "\n";};


          --- In soaplite@y..., Marten Lehmann <lehmann@c...> wrote:
          > Hello,
          >
          > I'd like to change the following code so that SOAP::Lite generates
          the
          > xml-message, but doesn't post them. Instead I want to do the
          > http-connection handling and feed SOAP::Lite with the response I
          get.
          >
          > use SOAP::Lite;
          > use strict;
          >
          > my ($domain, $soap, $code, $msg);
          >
          > $soap = SOAP::Lite
          > -> uri('DomainTools')
          > -> proxy('http://soap.variomedia.de/public/');
          >
          > $domain = shift @ARGV;
          > ($code, $message) = @{$soap->getDomainStatus($domain)->result};
          > print "$domain: [$code] [$msg]";
          >
          > Wherefor I need this is as follows: I want to do several SOAP-calls
          at
          > the same time, but with SOAP::Lite I have to wait until I receive a
          > response for the current SOAP-call. So I want to syswrite the
          > xml-message on my own to the http-servers and sysread the responses
          as
          > they come - nonblocked of course. After fully retrieved the
          response I
          > again want to use SOAP::Lite to do the parsing.
          >
          > Regards
          > Marten
        Your message has been successfully submitted and would be delivered to recipients shortly.