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

Empty envelope problem for mime attachment in server response

Expand Messages
  • edsgarddaniel
    Hi, I would be very grateful for some help regarding adding an attachment to a server response. The problem is that the attachment is not present in the
    Message 1 of 1 , Apr 14 7:16 AM
    • 0 Attachment
      Hi,
      I would be very grateful for some help regarding adding an attachment
      to a server response.

      The problem is that the attachment is not present in the envelope
      recieved by the client. No errors is reported, neither by the
      interpreter nor in the servers error.log. Ordinary calls, such as
      calling a Hello-method which just passes strings, works.

      I have patched the soap-lite code with Jörg Prante's attachment-patch
      for soap-lite 0.69 found on the sourceforge developer mailing list.

      I'm using an apache/2.0.55 mod_perl/2.0.2 server on an Ubuntu dist.
      Could it be some error in my apache config even though the ordinary
      Hello-call works?

      I would be very glad if anyone might have some idea of what could be
      causing the problem. See below for my code.

      Thanks in advance,
      best regards,

      Daniel Edsgard


      ####################
      #CLIENT-SIDE
      ####################
      use SOAP::Lite +trace => qw(debug);

      my $soap = SOAP::Lite
      ->readable(1)
      ->uri('Attachment')
      ->proxy('http://localhost');


      #test attachment response => Empty envelope
      my $som = $soap->getattachment();

      foreach my $part (@{$som->parts}) {
      print $part->stringify;
      }


      #test string request and response => Works
      #my $som = $soap->Hello('Daniel');
      #print $som->result;

      1;


      #################
      #SERVER-SIDE:
      #################

      #####
      #/var/www/CLASS/Attachment.pm
      #####
      package Attachment;

      use SOAP::Lite;
      use MIME::Entity;
      use strict;

      sub getattachment {

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

      return $ent;
      }

      sub Hello{
      my ($self, $name) = @_;

      return 'Hello, ' . $name . "\n";
      }
      1;


      ########
      #/var/www/CLASS/WORLD.pm
      ########
      package CLASS::World;

      use SOAP::Transport::HTTP;
      use MIME::Entity;

      my $server = SOAP::Transport::HTTP::Apache
      ->packager(SOAP::Packager::MIME->new)
      ->dispatch_to('/var/www/CLASS', 'Attachment');

      $server -> serializer -> autotype(0);


      sub handler { $server->handler(@_); }

      1;


      #######
      #/etc/apache2/mods-enabled/perl.conf
      #######
      #Puts /var/www in @INC:
      PerlRequire /home/edsgard/startup.pl

      <Location />
      SetHandler perl-script
      PerlHandler CLASS::World
      </Location>


      ############################
      #DEBUG-OUTPUT
      ############################
      SOAP::Transport::HTTP::Client::send_receive: POST http://localhost
      HTTP/1.1
      Accept: text/xml
      Accept: multipart/*
      Accept: application/soap
      Content-Length: 418
      Content-Type: text/xml; charset=utf-8
      SOAPAction: "Attachment#getattachment"

      <?xml version="1.0" encoding="UTF-8"?>
      <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body><getattachment xmlns="Attachment" xsi:nil="true" />
      </soap:Body>
      </soap:Envelope>


      SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK
      Connection: close
      Date: Fri, 13 Apr 2007 10:46:50 GMT
      Server: Apache/2.0.55 (Ubuntu) mod_perl/2.0.2 Perl/v5.8.8
      Content-Length: 426
      Content-Type: text/xml; charset=utf-8
      Client-Date: Fri, 13 Apr 2007 10:46:50 GMT
      Client-Peer: 127.0.0.1:80
      Client-Response-Num: 1
      SOAPServer: SOAP::Lite/Perl/0.69

      <?xml version="1.0" encoding="UTF-8"?>
      <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
      <getattachmentResponse xmlns="Attachment" xsi:nil="true" />
      </soap:Body>
      </soap:Envelope>
    Your message has been successfully submitted and would be delivered to recipients shortly.