Personalize

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

Forums :

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.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

hi, Try increasing the

hi,

Try increasing the "memory_limit" value in php.ini. That might fix your problem. We are working on the MTOM caching feature ( writing to a file ) and we will add it in a future release.

Nandika

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.