Base64 encoding of all MIME parts with attachments.
| From: | Nathan de Vries | Date: | Thu, 28 Apr 2005 06:28:14 +0000 |
| Subject: | Base64 encoding of all MIME parts with attachments. | ||
| Groups: | php.soap | ||
| Request: | Send a blank email to php-soap+get-1897@lists.php.net to get a copy of this message | ||
Hi there,
I'm trying to use SOAP to interface with an antivirus package my client is using, but I'm having no luck. I noticed that someone has had previous problems [1], but the fix they used doesn't seem to be working for me.
Basically, I have to put the file in the SOAP request. This gets base64 encoded, but then so does the body.
I'm doing:
$client = new SOAP_Client("http://example.com");
$client->setOpt('attachment', 'Mime');
$attachment = new SOAP_Attachment('file', 'text/plain', 'blar.txt');
$result = $client->call('scanFile', $parameters = array($attachment), 'urn:MYAV');
If I decode the first part of the request, it looks perfectly formatted according to what the server expects (SOAP::Lite), but I don't understand why it's encoding it. I've tried going into Base.php and adding double quotes around "text/xml", as well as changing the encoding to 8bit. No such luck.
I have been given a PERL script that works:
#!/usr/bin/perl
use strict;
use SOAP::Lite +trace => 'debug';
use MIME::Entity;
my $HOST = "http://example.com";
my $NS = "urn:MYAV";my $FILE = shift; my $ent = MIME::Entity->build(
Type => 'image/gif', Encoding => 'base64', Path => $FILE, Filename => $FILE, Disposition => 'attachment', 'Content-Location' => $FILE,);
my $soap = SOAP::Lite
->readable(1)
->uri($NS)
->parts($ent)
->proxy($HOST);
my $som = $soap->scanFile(
SOAP::Data->name("file")->attr({'href' => $FILE})
);
1;
Any ideas? I'd really appreciate your help.
Regards,
Nathan de Vries.
[1] http://www.codecomments.com/archive220-2004-4-165156.html