Hello

I'm retrieving a JPEG from the server side to display it in an mx:Image. The
image raw bytes are served by a plain Java Servlet. The content type is
correct. If I call the servlet from a common browser it all works fine. The
image is 400KB big.

PROBLEM: when I call the servlet from Flex 3, it looks like the lastResult
contains only the first bytes of the image, not all.

Briefly:

HTTPService declaration:

<mx:HTTPService id="arkServlet" url="/DocServlet" 
                            useProxy="false" fault="fault(event)" 
result="showImage()">
        <mx:request>
            <idDoc>101</idDoc>
        </mx:request>
    </mx:HTTPService>

The AS method that fires the http call:

public function downloadImage():void {
    arkServlet.send() ;
}

The result callback:

private function showImage():void {
                var imgBytes:ByteArray = new ByteArray() ;
                imgBytes.writeObject(arkServlet.lastResult) ;
                
                var imgLoader:FlexLoader = new FlexLoader() ;
        
imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeEventHandler);
 
                imgLoader.loadBytes(imgBytes) ;
        }

I am not posting the completeEventHandler() callback because it never gets
to execute it: it fails at imgLoader.loadBytes(imgBytes) giving the
following error (italian localized message):

Error #2044: IOErrorEvent non gestito:. text=Error #2124: Il file caricato รจ
di un tipo sconosciuto.

which translates more or less as

Error #2044: IOErrorEvent not managed: . text=Error #2124: loaded file is of
unknown type

Inspecting via debugger, it looks like the lastResult contains just a small
part of the 400KB.

Do I have to read the bytes explicitly in a loop in AS code ? Or is it just
my code that's wrong ?
Any help will be valuable, even debugging hints.

Thanks
Pier
-- 
View this message in context: 
http://www.nabble.com/Partial-result-from-HTTPService-call-tp16447449p16447449.html
Sent from the FlexCoders mailing list archive at Nabble.com.

Reply via email to