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

Re: dynamically build SOAP envelope with Perl ???

Expand Messages
  • jonthorwilliams
    thanks Duncan... your answer to my question worked perfectly... ill attach my sourcecode. it reads in a text file, builds a SOAP envelope out of the file ,
    Message 1 of 3 , May 28 10:20 AM
    • 0 Attachment
      thanks Duncan... your answer to my question worked perfectly... ill
      attach my sourcecode. it reads in a text file, builds a SOAP
      envelope out of the file , sends the request, and prints out the
      answer from the response envelope.

      jon

      ****************

      #!perl -w

      use strict;
      use SOAP::Lite +'trace';

      my %headers;
      my %body;
      my $record;
      my @thisline;
      my @params;

      my $apifile = shift || die "Enter a API file name as an argument.\n";

      my $soap = SOAP::Lite
      -> uri('http://www.domainname.com')
      -> proxy('http://localhost:8080/'); #proxy to MSSoapTrace

      open (APIFILE, $apifile) || die "couldn't open the file!";
      while ($record = <APIFILE>) {

      chomp($record);

      if ( substr( $record, 0, 3 ) eq '_H_' ) {
      @thisline = split(/=/, $record);
      my $hashkey = $thisline[0];
      my $key = substr($hashkey, 3);
      my $val = $thisline[1];
      $headers{$key} = $val;
      } elsif ( substr( $record, 0, 1 ) eq '#' ) {
      } elsif ( $record eq '' ) {
      } elsif ( $record ) {
      @thisline = split(/=/, $record);
      $body{$thisline[0]}= $thisline[1];
      my $key = $thisline[0];
      my $val = $thisline[1];
      $body{$key} = $val;
      }

      }
      close(APIFILE);

      print "\n--------\n";

      while( my ($key, $value) = each(%headers) ) {
      push @params, SOAP::Header->name($key)->type(string =>
      $value);
      }

      while( my ($key, $value) = each(%body) ) {
      push @params, SOAP::Data->name($key)->type(string => $value);
      }

      my $som = $soap->CatLookup( @params );

      print "Res=".$som->result."\n\n";
      print "--------\n\n";



      --- In soaplite@y..., Duncan Cameron <dcameron@b...> wrote:
      > On 2002-05-27 jonthorwilliams wrote:
      > >I know that there must be a way to accomplish this.
      >
      > >stated simply, i cannot get this to work, because it wont take a
      > >straight string argument:
      > >
      > >my $som = $soap->getStateName( $argstring );
      >
      > Why do you think that it should? Your argstring is a piece of Perl
      code that needs
      > to be evaluated.
      > If you want to build a SOAP message dynamically then something like
      this is probably a
      > better approach:
      >
      > while( my ($key, $value) = each(%body) ) {
      > push @params, SOAP::Data->name($key)->type(int => $value);
      > }
      >
      > my $som = $soap->getStateName( @params );
      >
      >
      > Regards,
      > Duncan Cameron
    Your message has been successfully submitted and would be delivered to recipients shortly.