SOAP_Attachement
| From: | Laurent Jourdren | Date: | Thu, 06 Oct 2005 18:52:01 +0000 |
| Subject: | SOAP_Attachement | ||
| Groups: | php.soap | ||
| Request: | Send a blank email to php-soap+get-2022@lists.php.net to get a copy of this message | ||
Hi,
I want to download from my website large files (500KB-10 MB) using web
services. I'm using PHP PEAR SOAP 0.9.1 under PHP 4.3 (Debian stable).
To do it, it is possible to encode files in base64 in a string field (see
the next code) but i would like to replace it by a MIME attachement.
SOAP_Attachement is supposed to do that but all that i have tested doesn't
work !
Thank you in advance for any assistance you can offer.
Laurent.
<?
require_once('SOAP/Server.php');
require_once('SOAP/Disco.php');
class ServerTest
{
var $__dispatch_map = array();
function ServerTest() {
$this->__dispatch_map['DownloadFile'] =
array('in' => array('file' => 'string'),
'out' => array('return' => 'base64Binary'));
}
function DownloadFile($file) {
if (file_exists($file))
return base64_encode(file_get_contents($file));
return null;
}
}
// Create the server
$server = new SOAP_Server();
$webservice = new ServerTest();
$server->addObjectMap($webservice, 'urn:ServerTest');
if (isset($_SERVER['REQUEST_METHOD']) &&
$_SERVER['REQUEST_METHOD']=='POST') {
$server->service($HTTP_RAW_POST_DATA);
} else {
// Create the DISCO server
$disco = new SOAP_DISCO_Server($server,'Lims');
header("Content-type: text/xml");
if (isset($_SERVER['QUERY_STRING']) &&
strcasecmp($_SERVER['QUERY_STRING'],'wsdl') == 0) {
echo $disco->getWSDL();
} else {
echo $disco->getDISCO();
}
}
exit;
?>