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

Re: [soaplite] Re: SOAP::Lite and attachments...

Expand Messages
  • Tim Jenness
    I was under the impression that SOAP::Lite 0.60 (which is *still* not on CPAN!!!!!) did not require SOAP::MIME since that functionality had been integrated
    Message 1 of 12 , Oct 28, 2003
    • 0 Attachment
      I was under the impression that SOAP::Lite 0.60 (which is *still* not on
      CPAN!!!!!) did not require SOAP::MIME since that functionality had been
      integrated into the core.

      Tim

      --
      Tim Jenness
      JAC software
      http://www.jach.hawaii.edu/~timj


      On Tue, 28 Oct 2003, jpeyser wrote:

      > Bill,
      > You also need the SOAP-MIME package (I believe the latest
      > version is SOAP-MIME-0.55-7). The SOAP-MIME package contains a
      > directory of examples, including a client module and a server module.
      > I had to modify both to get them to work. (This is not an Apache
      > example.)
      >
      > Client Module compose.pl
      >
      > I had to change a couple of lines.
      >
      > my @parts = ($ent);
      >
      > my $som = SOAP::Lite
      > ->readable(1)
      > ->uri($SOME_NAMESPACE)
      > ->proxy($SOME_HOST)
      > # ->parts([ $ent ])
      > ->parts(@parts)
      > ->on_debug(sub {&My::Trace::defaultlog;})
      > ->echo(SOAP::Data->name("whatToEcho" => "GREAT"));
      >
      > Server Module mime_server.cgi
      >
      > I modified the beginning including changing the server type from CGI
      > to Daemon.
      >
      > use SOAP::Lite;
      > use SOAP::MIME;
      > use SOAP::Transport::HTTP;
      >
      > my $port = shift || 8765;
      >
      > my $daemon = SOAP::Transport::HTTP::Daemon
      > -> new ('LocalPort' => $port, 'Reuse' => 1)
      > -> dispatch_to('SOAP_MIME_Test')
      > -> handle;
      >
      > Jonathan
      >
      > --- In soaplite@yahoogroups.com, bhess@t... wrote:
      > > I am working with SOAP::Lite 0.60 which I obtained from SourceForge
      > and cannot get MIME attachments to work properly. I have seen this
      > topic on this list many times before but cannot find a COMPLETE AND
      > WORKING example of how to do this from both client and server sides.
      > Is this possible? If yes, can someone please submit an example. My
      > server side is using Apache/mod_perl/mod_soap configuration...
      > >
      > > Thanks in advance...
      > >
      > > --
      > >
      > > Bill Hess
      > > Technology Resource Group
      >
      >
      >
      > To unsubscribe from this group, send an email to:
      > soaplite-unsubscribe@yahoogroups.com
      >
      >
      >
      > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
      >
      >
      >
    • Byrne Reese
      Oy... what a horrible oversight. I will add it to CPAN now. ... ^byrne :/
      Message 2 of 12 , Oct 28, 2003
      • 0 Attachment
        Oy... what a horrible oversight. I will add it to CPAN now.

        >
        >
        >
        >
        >
        > I was under the impression that SOAP::Lite 0.60 (which is *still* not on
        > CPAN!!!!!) did not require SOAP::MIME since that functionality had been
        > integrated into the core.
        >
        > Tim
        >
        > --
        > Tim Jenness
        > JAC software
        > http://www.jach.hawaii.edu/~timj
        >
        >
        > On Tue, 28 Oct 2003, jpeyser wrote:
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        > http://docs.yahoo.com/info/terms/
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        > 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
        Let me continue - you are correct, the functionality has been merged. SOAP::Lite 0.60 should be more than sufficient for your needs. Would you mind sending
        Message 3 of 12 , Oct 28, 2003
        • 0 Attachment
          Let me continue - you are correct, the functionality has been merged.
          SOAP::Lite 0.60 should be more than sufficient for your needs.

          Would you mind sending some of your code samples and server config's? It
          may help me track down your problem. Also - if you could put a trace on
          the message payload (all I need to see is the MIME and SOAP stuff... by
          all means, hide the attachment content if it is sensitive data.

          > I was under the impression that SOAP::Lite 0.60 (which is *still* not on
          > CPAN!!!!!) did not require SOAP::MIME since that functionality had been
          > integrated into the core.
          >
          > Tim
          >
          > --
          > Tim Jenness
          > JAC software
          > http://www.jach.hawaii.edu/~timj
          >
          >
          > On Tue, 28 Oct 2003, jpeyser wrote:
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          > http://docs.yahoo.com/info/terms/
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          > 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
          I stand corrected; everything has been incorporated into SOAP::Lite (almost). So I tried to run the old examples from the SOAP-MIME package without using
          Message 4 of 12 , Oct 29, 2003
          • 0 Attachment
            I stand corrected; everything has been incorporated into SOAP::Lite
            (almost). So I tried to run the old examples from the SOAP-MIME
            package without using SOAP::MIME. The client side works fine. But the
            server side has a couple of problems.

            Here are the examples.

            #!/usr/local/bin/perl

            use SOAP::Lite +trace => qw(debug);
            use MIME::Entity;

            my $ent = build MIME::Entity
            Type => "image/gif",
            Encoding => "base64",
            Path => "m.gif",
            Filename => "m.gif",
            Disposition => "attachment";

            my @parts = ($ent);
            $SOME_HOST = 'http://localhost:8765';
            $SOME_NAMESPACE = 'SOAP_MIME_Test';


            my $som = SOAP::Lite
            ->readable(1)
            ->uri($SOME_NAMESPACE)
            ->proxy($SOME_HOST)
            ->parts(@parts)
            # ->parts([ $ent ])
            ->echo(SOAP::Data->name("whatToEcho" => "GREAT"));


            The old example has a couple of problems (maybe it is obsolete).
            First, the subroutine SOAP::SOM::parts that was introduced in the
            SOAP-MIME package was not added to SOAP::Lite. Second, after adding
            the parts routine, the result is different (there is an extra empty
            array).

            0 ARRAY(0x6a60e4)
            0 ARRAY(0xe250b8)
            empty array
            1 REF(0xe1d91c)
            -> MIME::Entity=HASH(0xe1da3c)
            'ME_Bodyhandle' => MIME::Body::InCore=HASH(0xe1daa8)
            'MBC_Data' => ARRAY(0xe12d94)



            Anyway, here is the modified code that works.

            #!/usr/local/bin/perl

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

            my $port = shift || 8765;

            my $daemon = SOAP::Transport::HTTP::Daemon
            -> new ('LocalPort' => $port, 'Reuse' => 1)
            -> dispatch_to('SOAP_MIME_Test')
            -> handle();

            BEGIN {

            sub SOAP::SOM::parts {
            my $self = shift;
            @_ ? ($self->{_parts} = shift, return $self) : return $self->
            {_parts};
            }


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

            sub echo {
            my $self = shift;
            my $envelope = pop;

            my $part = $envelope->parts->[1];
            # foreach my $part (@{$envelope->parts}) {
            print STDERR "Attachments.cgi: attachment found! (".ref
            ($$part).")\n";
            # }
            print STDERR "envelope is of type: " . ref($envelope) . "\n";
            print $envelope->body;
            my $STRING = $envelope->dataof("//echo/whatToEcho")
            or die SOAP::Fault->faultcode("Client")
            ->faultstring("You must specify a string to echo")
            ->faultactor('urn:SOAP_MIME_Test#echo');

            my $ent = build MIME::Entity
            'Id' => "<1234>",
            'Type' => "text/xml",
            'Path' => "hello.xml",
            'Filename' => "hello.xml",
            'Disposition' => "attachment";

            return SOAP::Data->name("whatToEcho" => $STRING);
            }
            }



            --- In soaplite@yahoogroups.com, "Byrne Reese" <byrne@m...> wrote:
            > Let me continue - you are correct, the functionality has been
            merged.
            > SOAP::Lite 0.60 should be more than sufficient for your needs.
            >
            > Would you mind sending some of your code samples and server
            config's? It
            > may help me track down your problem. Also - if you could put a
            trace on
            > the message payload (all I need to see is the MIME and SOAP
            stuff... by
            > all means, hide the attachment content if it is sensitive data.
            >
            > > I was under the impression that SOAP::Lite 0.60 (which is *still*
            not on
            > > CPAN!!!!!) did not require SOAP::MIME since that functionality
            had been
            > > integrated into the core.
            > >
            > > Tim
            > >
            > > --
            > > Tim Jenness
            > > JAC software
            > > http://www.jach.hawaii.edu/~timj
            > >
            > >

            >
            >
            > ^byrne :/
          • jigsaw9876
            Thanks for this fix. I have attachments working now. -JS
            Message 5 of 12 , Oct 30, 2003
            • 0 Attachment
              Thanks for this fix. I have attachments working now.

              -JS
            • 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 6 of 12 , Oct 31, 2003
              • 0 Attachment
                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 7 of 12 , Oct 31, 2003
                • 0 Attachment
                  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 8 of 12 , Oct 31, 2003
                  • 0 Attachment
                    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 9 of 12 , Nov 4, 2003
                    • 0 Attachment
                      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 10 of 12 , Nov 12, 2003
                      • 0 Attachment
                        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.