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

Re: SOAP::Lite and attachments...

Expand Messages
  • jigsaw9876
    In the same context I have another silly question: The server returns data and an attachment like: return SOAP::Data- name( whatToEcho = $STRING),$ent; How
    Message 1 of 12 , Oct 31, 2003
      In the same context I have another silly question:
      The server returns data and an attachment like:
      return SOAP::Data->name("whatToEcho" => $STRING),$ent;
      How does the client recieve this?
      $som->result returns the SOAP::Data but how do I extract the MIME::entity bit??

      - JS
    • Byrne Reese
      The SOAP::SOM object returned by SOAP::Lite has a subroutine called parts - which contains the array of MIME::Entity objects. ... ^byrne :/
      Message 2 of 12 , Oct 31, 2003
        The SOAP::SOM object returned by SOAP::Lite has a subroutine called
        'parts' - which contains the array of MIME::Entity objects.

        >
        >
        >
        >
        > In the same context I have another silly question:
        > The server returns data and an attachment like:
        > return SOAP::Data-
        > How does the client recieve this?
        > $som-
        >
        > - JS
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        > Yahoo! Groups Sponsor
        >
        >
        > ADVERTISEMENT
        >
        >
        >
        >
        >
        >
        >
        >
        >
        > To unsubscribe from this group, send an email to:
        > soaplite-unsubscribe@yahoogroups.com
        >
        >
        >
        >
        >
        > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
        >
        >
        >
        >
        >


        ^byrne :/
      • jpeyser
        OK!!!!!! Finally found the problem. I stand corrected a second time. The parts subroutine is defined in SOAP::SOM, but it has a bug. for my $method (qw(parts))
        Message 3 of 12 , Oct 31, 2003
          OK!!!!!!

          Finally found the problem. I stand corrected a second time.
          The parts subroutine is defined in SOAP::SOM, but it has a bug.

          for my $method (qw(parts)) {
          my $field = '_' . $method;
          *$method = sub {
          ### my $self = shift->new;
          my $self = shift;
          @_ ? ($self->{$field} = shift, return $self) : return $self->
          {$field};
          }
          }

          (The parts subroutine was defined in a new instance of SOAP::SOM.)


          A second problem in package SOAP::MIMEParser.

          sub decode {
          my $self = shift;
          my $entity = eval { $self->parse_data(shift) }
          or die "Something wrong with MIME message: @{[$@ || $self-
          >last_error]}\n";

          # initialize with empty array; autovivification doesn't work in
          this case --PK
          ### $self->parts([]) if $entity->parts;
          $self->{_parts} = [] if $entity->parts;

          (This was initializing the array with an empty array
          as it's first element.)

          --- In soaplite@yahoogroups.com, "Byrne Reese" <byrne@m...> wrote:
          > The SOAP::SOM object returned by SOAP::Lite has a subroutine called
          > 'parts' - which contains the array of MIME::Entity objects.
          >
          > >
          > >
          > >
          > >
          > > In the same context I have another silly question:
          > > The server returns data and an attachment like:
          > > return SOAP::Data-
          > > How does the client recieve this?
          > > $som-
          > >
          > > - JS
          > >
          > >
          > >
          > >
          > >
          > >
          > >
          > >
          > >
          > >
          > > Yahoo! Groups Sponsor
          > >
          > >
          > > ADVERTISEMENT
          > >
          > >
          > >
          > >
          > >
          > >
          > >
          > >
          > >
          > > To unsubscribe from this group, send an email to:
          > > soaplite-unsubscribe@yahoogroups.com
          > >
          > >
          > >
          > >
          > >
          > > Your use of Yahoo! Groups is subject to the Yahoo! Terms of
          Service.
          > >
          > >
          > >
          > >
          > >
          >
          >
          > ^byrne :/
        • techrg99
          Here is a complete and working example of attachemnt download: Here is the server side - MIME_Test.pm - I am using Apache/mod_perl server: package MIME_Test;
          Message 4 of 12 , Nov 4, 2003
            Here is a complete and working example of attachemnt download:
            Here is the server side - MIME_Test.pm - I am using Apache/mod_perl
            server:

            package MIME_Test;

            use strict;
            use SOAP::Lite;
            use MIME::Entity;
            use IO::File;
            use Digest::MD5 qw(md5_base64);

            use vars qw(@ISA);
            @ISA = qw(SOAP::Server::Parameters);

            sub echo3 {
            my $self = shift;
            my $envelope = pop;
            my ($info, $md5_check) = @_;

            my $file = "/usr/local/jci/gim/tmp/anim.gif";

            my $ent = MIME::Entity->build(Type => "image/gif",
            Encoding => "base64",
            Path => $file,
            Filename => "anim.gif",
            Disposition => "attachment",
            Mode => 1);

            my $checksum = `GET_CHECKSUM.pl $file`;

            return SOAP::Data->name("checksum" => $checksum), $ent;
            }


            where $checksum is a MD5 checksum - this is not really needed but I
            threw it in my example - here is the code for GET_CHECKSUM.pl and the
            reason I wrote it is because if I call this in the echo3 code
            directly, I do not get the correct checksum - not sure where the
            conflict is, but if anyone can advise on this - I would greatly
            appreciate it...

            # GET_CHECKSUM.pl:
            use strict;
            use Digest::MD5 qw(md5_base64);

            my $checksum = "";
            if(open(FILE, $ARGV[0])) {
            binmode(FILE);
            $checksum = md5_base64(*FILE);
            close FILE;
            }
            print $checksum;




            Here is the client side:


            use strict;
            use SOAP::Lite +trace => qw(debug);
            use MIME::Entity;
            use Digest::MD5 qw(md5 md5_hex md5_base64);

            my $soap = SOAP::Lite
            -> readable(1)
            -> uri("http://$host:$port/MIME_Test")
            -> proxy("http://$host:$port/$proxy");

            my $som = $soap->echo3;
            my $part = $som->parts->[0];

            my $checksum = $som->result;

            print "SOAP = $soap\n";
            print "SOM = $som\n";
            print "SOM REF = " . ref($som->parts) . "\n";
            print "PART = $part\n";
            print "CHECKSUM= $checksum\n";

            my $bh;
            my $io;
            my $buf;

            open FILE, "> anim3.gif";
            binmode FILE;

            if($bh = $$part->bodyhandle) {
            $io = $bh->open;

            while($io->read($buf, 1024)) {
            print FILE $buf;
            }

            $io->close;
            }

            my $checksum2 = md5_base64(*FILE);
            close FILE;

            print "CHECKSUM= $checksum2\n";

















            --- In soaplite@yahoogroups.com, "Byrne Reese" <byrne@m...> wrote:
            > The SOAP::SOM object returned by SOAP::Lite has a subroutine called
            > 'parts' - which contains the array of MIME::Entity objects.
            >
            > >
            > >
            > >
            > >
            > > In the same context I have another silly question:
            > > The server returns data and an attachment like:
            > > return SOAP::Data-
            > > How does the client recieve this?
            > > $som-
            > >
            > > - JS
            > >
            > >
            > >
            > >
            > >
            > >
            > >
            > >
            > >
            > >
            > > Yahoo! Groups Sponsor
            > >
            > >
            > > ADVERTISEMENT
            > >
            > >
            > >
            > >
            > >
            > >
            > >
            > >
            > >
            > > To unsubscribe from this group, send an email to:
            > > soaplite-unsubscribe@yahoogroups.com
            > >
            > >
            > >
            > >
            > >
            > > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
            > >
            > >
            > >
            > >
            > >
            >
            >
            > ^byrne :/
          • Byrne Reese
            Thank you for finding this patch. I have made the changes to the source base, and am checking them in now. This will go out in the next release. ... ^byrne :/
            Message 5 of 12 , Nov 12, 2003
              Thank you for finding this patch. I have made the changes to the source
              base, and am checking them in now. This will go out in the next release.
              >
              >
              >
              >
              > OK!!!!!!
              >
              > Finally found the problem. I stand corrected a second time.
              > The parts subroutine is defined in SOAP::SOM, but it has a bug.
              >
              > for my $method (qw(parts)) {
              > my $field = '_' . $method;
              > *$method = sub {
              > ### my $self = shift-


              ^byrne :/
            Your message has been successfully submitted and would be delivered to recipients shortly.