PDA

View Full Version : Compress XML request before seding with HTTPService


kokot-san
02-28-2008, 04:52 PM
Hi,

I was wondering how I can compress an XML-request before sending it to
the server and let Apache2 decompress it before passing it on to the
target application. For this, in Apache2 I enabled the module
"deflate" with the following configuration:

<IfModule mod_deflate. c>
AddOutputFilterByTy pe DEFLATE text/xml application/ xml
SetInputFilter DEFLATE
</IfModule>

Note that the output filter works fine, but I also want to compress
XML in Flex 3/AS before sending it to the server. What I did so far -
without success - is:

var service:HTTPService = new HTTPService( );
service.method = "POST";
service.url = ...;
service.contentType = "application/ xml";
service.headers[ "Content- Encoding" ] = "gzip";
var xmlRequest:String = ...;
var bytes:ByteArray = new ByteArray();
bytes.writeUTFBytes (xmlRequest) ;
bytes.compress( );
service.request = bytes.readUTF8( );
service.send( );

Then Apache2 gives the following error:
(20014)Internal error: Error reading request entity data, referer:
file:///C:/Document s and Settings/Andrej/ My Documents/Flex Builder
3/gui/bin/MBraceGUI .swf

Does anybody know how to make this work? What am I doing wrong?

Cheers,
Andrej