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

SOAP::Lite and attachments using SMTP/PP3

Expand Messages
  • victorio_bentivogli@yahoo.com.ar
    Hello, I am trying to use SOAP::Lite to send attachments over SMTP/POP3. I modified the example code provided: ... use SOAP::Lite +trace = all ; use
    Message 1 of 2 , Dec 17, 2003
    • 0 Attachment
      Hello,

      I am trying to use SOAP::Lite to send attachments over SMTP/POP3. I
      modified the example code provided:

      Server:
      -------

      use SOAP::Lite +trace => 'all';
      use SOAP::Transport::POP3;
      my $server = SOAP::Transport::POP3::Server
      -> new('pop://127.0.0.1')
      -> dispatch_to('SOAP_MIME_Test');
      $server->login('user'=>'passwordt') or die " -> could not
      authenticate\n";
      while (0==0) {
      print " -> checking...\n";
      print " -> " . $server->handle;
      print " mail(s) processed.\n";
      print " -> waiting 10 secs...\n";
      sleep 10;
      }

      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 {
      print " -> modulo echo cargado satisfactoriamente.\n";
      my $self = shift;
      my $envelope = pop;
      my $part = $envelope->parts->[1];
      # foreach my $part (@{$envelope->parts}) {
      print "Attachments.cgi: attachment found! (".ref
      ($$part).")\n";
      # }
      print "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);
      }
      }

      Client:
      -------

      my $NS = 'urn:SOAP_MIME_Test';
      use SOAP::Lite +trace => qw(debug);
      use MIME::Entity;
      my $ent1 = build MIME::Entity
      'Id' => "<abcd>",
      'Type' => "text/xml",
      'Path' => "attachments/some1.xml",
      'Filename' => "some1.xml",
      'Disposition' => "attachment";
      my $ent2 = build MIME::Entity
      'Id' => "<1234>",
      'Type' => "text/xml",
      'Path' => "attachments/some2.xml",
      'Filename' => "some2.xml",
      'Disposition' => "attachment";
      push @attachments, $ent1;
      push @attachments, $ent2;
      my $som = SOAP::Lite
      ->readable(1)
      ->uri($NS)
      ->parts(@attachments)
      ->proxy('mailto:soap@...', smtp => '127.0.0.1', From
      => 'Administrator@...', Subject => 'SOAP message with attachment')
      ->echo( SOAP::Data->name('whatToEcho' => 'foo bar baz') );

      If I comment "->parts(@attachments)", the programs seem to work fine
      and the corresponding subroutine is called. Although when I try to
      send the attachments (uncommenting that section), the corresponding
      subroutine is not called. A trace returns:

      SOAP::Serializer::new: ()
      SOAP::Deserializer::new: ()
      SOAP::Parser::new: ()
      SOAP::Server::new: ()
      -> checking...
      SOAP::Server::handle: ()
      SOAP::Deserializer::deserialize: ()
      SOAP::MIMEParser::new: ()
      SOAP::Parser::decode: ()
      -> 1 mail(s) processed.
      -> waiting 10 secs...

      Everything seems to work fine if I use another transport like HTTP. I
      am using SOAP::Lite 0.60 and ActiveState Perl 5.6 on Windows 2000.

      Any suggestion ?

      Thanks,

      Victorio
    • Byrne Reese
      Actually, MIME support was never enabled for anything but HTTP. SOAP::MIME was originally just a patch. Properly supporting MIME requires a large rewrite. But
      Message 2 of 2 , Dec 18, 2003
      • 0 Attachment
        Actually, MIME support was never enabled for anything but HTTP. SOAP::MIME
        was originally just a patch. Properly supporting MIME requires a large
        rewrite.

        But SMTP/POP support should be relatively simple. I will make sure that
        gets into the next release, or the one immediately after.


        > Hello,
        >
        > I am trying to use SOAP::Lite to send attachments over SMTP/POP3. I
        > modified the example code provided:
        >
        > Server:
        > -------
        >
        > use SOAP::Lite +trace =< 'all';
        > use SOAP::Transport::POP3;
        > my $server = SOAP::Transport::POP3::Server
        > -< new('pop://127.0.0.1')
        > -< dispatch_to('SOAP_MIME_Test');
        > $server-


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