Attachments with SOAP::Lite

M

markdibley

Hello

I am having trouble understanding the few examples of attaching files
to SOAP server responses in the context of how my own service is set
up. I was under the impression that returning large files (>20MB) as
attachments would resolve the timeout problem I have.

My server consists of a CGI script that calls a library function.
-------------------------------------------
#!/usr/bin/perl -w
use SOAP::Transport::HTTP;
use SOAP::Lite +trace =>[qw(debug)];

my $server = SOAP::Transport::HTTP::CGI ->
dispatch_to('/mylib','Library');
$server -> serializer -> autotype(0);
$server -> handle;
-------------------------------------------

My library function does it stuff and returns data like so
-------------------------------------------
sub getFile{
my $fhData = new FileHandle("myfile", "r");
my @lines = $fhData->getlines();
$fhData->close();

my $SoapResult = [];
push @$SoapResult, SOAP::Data->name("YourFile" => join("",
@lines))->type('base64');
return $SoapResult;
}
-------------------------------------------

As far as I can tell there are 2 ways to add attachments. Either make a
SOAP::SOM object and put it into "parts" or make a MIME::Entity and
return this with the $SoapResult.

-------------------------------------------
sub getFile{
my $ent = MIME::Entity->build(
Type => "image/gif",
Path => "myfile",
Encoding => "base64");

my $SoapResult = [];
push @$SoapResult, SOAP::Data->name("YourFile" =>"Is
attached")->type('string');
return $SoapResult, $ent;
}
-------------------------------------------

However, the first method requires me to assign ALL the values to SOM
such a proxy etc which I would much prefer to be done automatically and
the second method simply doesn't seem to assign the file to parts and
instead puts the MIME::Entity into the envelope and has no data in it.

If anyone can suggest where I am going wrong or show me an example of
how to do this I would be extremely grateful.

Mark Dibley
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top