Expand my Community achievements bar.

Filetransfer via Webservice

Avatar

Level 1
Hello, everyone.



I am trying to write a client with Flex/AIR that can download
files using a webservice (wsdl).



The webservice method returns me a byteArray.



The whole thing is working and the datatransfer is pretty
fast, but the decoding of the byteArray seems to be so slow, that
it freezes the whole application during that procedure.



With smaller files, the short freeze does not bother at all.
But with files bigget than, let's say, 5mb the period of waiting
becomes very very long.



Does anyone know a solution for that problem?



Here is the actionscript code I use on the client side
(Unlike the code is saying, I am not using MTOM here (Since FLEX
doesn't support MTOM at all, as far as I know). It was intended to
use it, but since there is no implementation, we simply turned it
off on the server):









public function init():void{

var service:Service = new Service();

service.addgetTestMTOMEventListener(testfunc);

// App starts freezing HERE

service.getTestMTOM();

}



public function testfunc(evt:GetTestMTOMResultEvent):void{

var arr:ByteArray = evt.result.testDataHandler;



var dir:File = File.desktopDirectory.resolvePath("files");

dir.createDirectory();



var file:File =
File.desktopDirectory.resolvePath("files/testfile.zip");



var fileStream:FileStream = new FileStream();

fileStream.open(file, FileMode.WRITE);

fileStream.writeBytes(arr);



fileStream.close();

}
2 Replies

Avatar

Level 2
this is really a Flex/AIR performance problem, not related to
data services.



considering AS3 does not support multi-threading, and not
likely to support it in the next version, I suggest you transfer
the files using multipart post instead of ws.

Avatar

Level 1
Thanks for you reply.



Would MTOM be of any help here, if Flex supported it?

If yes, would it be possible to develop an own implementation
of MTOM for Flex?