OK then, I rewrote it with URLLoader, avoiding the HTTPService.send() call, using an URLRequest instead: now all of the image bytes get to the client.
Thanks to all who helped. P. Dmitri Girski wrote: > > Hi Pier, > > I said that I am not sure about getting binary data via HTTPService as > I never heard or read about it. There is no direct answer in the > documentation as well, I just think that HTTPService is too much > oriented on the high-level stuff as XML encoding/decoding etc. > > First thing - check that you use POST method. > > Then, try to use URLLoader - this one definitely works with binary data. > > > Also I would recommend to install Wireshark sniffer - this is really > great tool which helps you understand what is going on in your network. > > To use Wireshark you have to setup second machine acting as a server > as it does not understand loopback interface. And don't use SSL for > debugging as all your packets will be scrambled. > > Cheers, > Dmitri. > > > > > --- In [email protected], p_repetti <[EMAIL PROTECTED]> > wrote: >> >> >> Thanks for your note, Dmitri. >> >> I have thought about saving the jpg on the server then exposing it > through >> an URL, but that results in a potential security breach in my > system. If I >> generate the image on the fly and stream it to the client, I can control >> that the client has right credentials to obtain it. Moreover, no > trace is >> left on the server. I strongly prefer this way. >> >> Could you please add some detail about why you're not sure I can > retrieve >> binary data through an HTTPService call ? >> >> My idea, as of now, is implementing it like I would in a Java client. I >> mean: open an input stream from the servlet URL, then read data > until it's >> available, building the byte array chunk by chunk. By the way, > that's how >> the underlying FLex/AS code should do, in the backgrounds of the >> HTTPService/send()/result callback implementation. At least I think so, >> though I have no time to browse the Flex source code to find out. >> >> Do you have any more suggestions ? >> >> Pier >> >> >> >> Dmitri Girski wrote: >> > >> > Hmmm, I just re-read your post and realised that you are getting the >> > binary data via the HTTPService. >> > I am not sure if you can do this. >> > >> > If I were you I would save the generated image as .jpg file on server >> > in some temp location and then return the path+name of it to the >> > client. And then just set the source property of Image object. >> > >> > Cheers, >> > Dmitri. >> > >> > >> > >> > --- In [email protected], p_repetti <pierangelo.repetti@> >> > wrote: >> >> >> >> >> >> Thanks to everyone who replied, but nothing changed. >> >> >> >> It looks like the problem is in the result byte array, that is >> > _before_ the >> >> loader actually gets in. >> >> Is my way of creating the ByteArray correct ? >> >> How can I inspect the length and contents of lastResult via the >> > debugger ? >> >> >> >> Thanks >> >> >> >> >> >> Dave Cragg wrote: >> >> > >> >> > Isn't using URLLoader a better way to download binary data such > as >> >> > jpeg files? It has a dataFormat property that can be set to > binary, >> >> > which delivers the data as a byteArray. >> >> > >> >> > My understanding of httpService is that it will try to parse the >> >> > result depending on the setting of the resultFormat property. >> > There is >> >> > no binary option for this. >> >> > >> >> > I don't know if that's the cause of your problem, but it may be >> > worth >> >> > trying. >> >> > >> >> > Dave >> >> > >> >> > On 2 Apr 2008, at 18:04, p_repetti wrote: >> >> > >> >> >> >> >> >> 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. >> >> > >> >> > >> >> >> >> -- >> >> View this message in context: >> > > http://www.nabble.com/Partial-result-from-HTTPService-call-tp16447449p16467377.html >> >> Sent from the FlexCoders mailing list archive at Nabble.com. >> >> >> > >> > >> > >> > >> >> -- >> View this message in context: > http://www.nabble.com/Partial-result-from-HTTPService-call-tp16447449p16489127.html >> Sent from the FlexCoders mailing list archive at Nabble.com. >> > > > > -- View this message in context: http://www.nabble.com/Partial-result-from-HTTPService-call-tp16447449p16525935.html Sent from the FlexCoders mailing list archive at Nabble.com.

