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

3093Re: SOAP::Lite and attachments...

Expand Messages
  • jpeyser
    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 :/
    • Show all 12 messages in this topic