Published on WSO2 Oxygen Tank (http://wso2.org)

Out of Memory Exception when downloading a large file from a web service using MTOM.

By suzy
Created 2008-05-14 11:19

Hi,



I am trying to download a potentially large file (> 100 MB) from a web service using MTOM.  The web service is written in asp .net (c#), and the client uses wso2 wsf/php to consume the web service.  The php client can successfully download and save small files.  But, when I try to download a large file, I recieve the following error:  "Allowed memory size of 134217728 bytes exhausted (tried to allocate 256116343 bytes)".



Is there a way using wso2 wsf/php to download large files from a web service without the whole file being loaded into memory?  Can the response from the web service be streamed and read/written to file using php?  What is the best way of accomplishing this?



The current php code I am using to consume the web service and download the file is below:



=====================================================

$reqPayloadString = <<<XML

<ns1:GetSomeFile xmlns:ns1="http://test/WebServices/">

    <ns1:fileName>C:\\output\\CK-0000115\\test.txt</ns1:fileName>

</ns1:GetSomeFile>

XML;



try {

    $reqMessage = new WSMessage($reqPayloadString, array("to"=>"http://test/ATest/TestWebService.asmx", "action"=>"http://test/WebServices/GetSomeFile", "attachments"=>array()));



    $client = new WSClient(array("useMTOM" => TRUE, "useWSA"=> TRUE, "useSoap"=>1.2, "responseXOP" => TRUE, "trace"=>1));

   

    $resMessage = $client->request($reqMessage);


======================================================



Any help would be appreciated. Thanks.


Source URL:
http://wso2.org/forum/thread/3595