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

1823Getting HTTP Headers

Expand Messages
  • Simon West
    Sep 12, 2002
    • 0 Attachment
      Hi all

      Firstly i'm pretty new to Perl so please bear with me :-)

      The WebService i'm talking to send an ID as part of the HTTP
      headers. How do I get this id and then resend it on further requests?

      The code is below (as I said I'm still new to perl...) The service
      is an ASP.NET address book sample. How would I extend this to read a
      HTTP header when a SOAP reply is returned??????


      Thanks in advance....

      Simon



      use SOAP::Lite;

      $SERVICE
      = 'http://MSSoapSampleServer:8080/MSSoapSamples/AddrBook/Service/Rpc/I
      sapiVb/AddrBook.WSDL';

      sub dumpHash {
      local($x) = @_;
      foreach $i (sort keys %$x) {
      printf "$i : $$x{$i} \n";
      }
      }

      sub dumpArray {
      local($x) = @_;
      $i = 0;
      foreach (@$x) { # Access the entire array.
      printf "$$x[$i++]\n";
      }
      }

      sub prompt {
      local($text) = @_;
      print "\n$text : ";
      $reply = <STDIN>;
      chop $reply;
      return $reply;
      }


      sub connectSoap {
      my $soapObject = SOAP::Lite
      -> service($SERVICE);
      return $soapObject;
      }


      sub getNames {
      local($soap) = shift;
      my $soap_response = $soap
      -> GetNames();
      return $soap_response;
      }

      sub getAddr {
      local ($soap) = shift;
      local ($name) = shift;
      my $soap_response = $soap
      -> GetAddr("$name");
      return $soap_response;
      }

      sub printAddr{
      local ($addr) = shift;
      print "\nName : $$addr{name}";
      print "\nStreet : $$addr{street}";
      print "\nCity : $$addr{city}";
      print "\nState : $$addr{state}";
      print "\nZip : $$addr{'zip-code'}";

      $i = 0;
      $x = $$addr{'phone-numbers'};

      foreach (@$x) { # Access the entire array.
      if ($i == 0) {
      print "\nPhone# : ";
      }
      else {
      print " : ";
      }
      printf "$$x[$i++]\n";
      }
      }

      $connection = connectSoap();
      #$names = getNames($connection);
      #dumpArray($names);
      #$choice = prompt("Select a name");
      #$addr = getAddr($connection, $choice);
      $addr = getAddr($connection, "Kim");
      printAddr($addr);
    • Show all 6 messages in this topic