You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by juliocest <ju...@gmail.com> on 2008/11/03 16:20:34 UTC

GZIP Response not work on Axis2

Hi everybody!

I made an application that send attachments on soap message using SWA and
MTOM. The client and server works properly. Now, I am trying to use GZIP in
order to compress/decompress SOAP messages.

My Service code:

	public OMElement downloadFileSWA(OMElement element) throws Exception {
		FileDataSource binaryDataSource;
		DataHandler binaryDataHandler;
		String vectorFileType[] =
{"file10KB","file100KB","file1MB","file10MB","file100MB"};
				
		// Checking if the resources folder is available
		File file =  new File(filePath);
		if (!file.isDirectory() || !file.exists()){
		    throw new AxisFault("File not available in the service provider...");
		}
		
		// Obtain the request (incoming) from the MessageContext as follows
		MessageContext inMessageContext =
MessageContext.getCurrentMessageContext();
		
		// Obtain the operation context from the request message context
		OperationContext operationContext =
inMessageContext.getOperationContext();
		
		// Obtain the response (outgoing) message context from the operation
context
		MessageContext outMessageContext =
operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
		
		outMessageContext.setProperty(HTTPConstants.MC_GZIP_RESPONSE, true);
		outMessageContext.setProperty(HTTPConstants.MC_ACCEPT_GZIP, true);
		
		// Get the first element from the received message
		String firstElem = element.getFirstElement().getText();
		OMElement result = null;
		
		for (int i = 0; i < vectorFileType.length; i++) {
			if (vectorFileType[i].equalsIgnoreCase(firstElem)) {
				binaryDataSource = new FileDataSource(filePath +File.separator+
vectorFileType[i]);
				binaryDataHandler = new DataHandler(binaryDataSource);
				// Add the created data handler as an attachment to the outgoing
message.
				String binaryID = outMessageContext.addAttachment(binaryDataHandler);
				result = buildDownloadFileSWAEnvelope(vectorFileType[i],binaryID);
				break;
			}
		} 		
		return result;		
	}


My Client code:

	public void donwloadBinarySWA(String binaryName) throws Exception {

		System.out.println("Download Binary with SWA");
		Options options = new Options(); 
                options.setProperty(HTTPConstants.MC_GZIP_REQUEST,
Boolean.TRUE);
		options.setProperty(HTTPConstants.MC_GZIP_RESPONSE, Boolean.TRUE);	
                 
		ServiceClient sender = new ServiceClient();
		sender.setOptions(options);
		OperationClient mepClient =
sender.createClient(ServiceClient.ANON_OUT_IN_OP);

		MessageContext mc = new MessageContext();
		SOAPEnvelope env = buildEnvelopeDownloadBinarySWA(binaryName);
		mc.setEnvelope(env);

		mepClient.addMessageContext(mc);
		mepClient.execute(true);

		// Get the message context for the response
		MessageContext response =
mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
		SOAPBody body = response.getEnvelope().getBody();
		OMElement element = body.getFirstChildWithName(new
QName("http://service.sample/xsd", "donwloadResponse"));
		
		if (element != null) {
			processDownloadBinarySWA(response, element);
		} else {
			throw new Exception("Malformed response.");
		}
	}

I am also using TCPMon to monitor all soap messages that are sent to my
service. What I can see is that all requests are compressed with GZIP but
responses are not. My tests are being made using both Axis2 1.3 (as a
server) and Tomcat 6.0.18 with this options in server.xml:

               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"
               compression="on"
               compressionMinSize="2048"
               noCompressionUserAgents="gozilla, traviata"
               compressableMimeType="text/html,text/xml"

Both in Axis2 and Tomcat the responses are not compressed.

Is it a bug on Axis2?

Someone had the same problem?

I hope some help.

Thanks.

Julio Cezar Estrella (São Carlos - SP - Brazil)

-- 
View this message in context: http://www.nabble.com/GZIP-Response-not-work-on-Axis2-tp20304607p20304607.html
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: GZIP Response not work on Axis2

Posted by juliocest <ju...@gmail.com>.
Hi,

Yes. I edited server.xml in order to enable compression. Don't work yet.

I need discover the problem.

Thanks.

Julio


dims wrote:
> 
> did you edit tomcat server.xml?
> http://www.cubicleman.com/2007/04/06/enabling-gzip-compression-with-tomcat-and-flex/
> 
> thanks,
> dims
> 
> On Mon, Nov 3, 2008 at 10:20 AM, juliocest <ju...@gmail.com> wrote:
>>
>> Hi everybody!
>>
>> I made an application that send attachments on soap message using SWA and
>> MTOM. The client and server works properly. Now, I am trying to use GZIP
>> in
>> order to compress/decompress SOAP messages.
>>
>> My Service code:
>>
>>        public OMElement downloadFileSWA(OMElement element) throws
>> Exception {
>>                FileDataSource binaryDataSource;
>>                DataHandler binaryDataHandler;
>>                String vectorFileType[] =
>> {"file10KB","file100KB","file1MB","file10MB","file100MB"};
>>
>>                // Checking if the resources folder is available
>>                File file =  new File(filePath);
>>                if (!file.isDirectory() || !file.exists()){
>>                    throw new AxisFault("File not available in the service
>> provider...");
>>                }
>>
>>                // Obtain the request (incoming) from the MessageContext
>> as follows
>>                MessageContext inMessageContext =
>> MessageContext.getCurrentMessageContext();
>>
>>                // Obtain the operation context from the request message
>> context
>>                OperationContext operationContext =
>> inMessageContext.getOperationContext();
>>
>>                // Obtain the response (outgoing) message context from the
>> operation
>> context
>>                MessageContext outMessageContext =
>> operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
>>
>>               
>> outMessageContext.setProperty(HTTPConstants.MC_GZIP_RESPONSE, true);
>>               
>> outMessageContext.setProperty(HTTPConstants.MC_ACCEPT_GZIP, true);
>>
>>                // Get the first element from the received message
>>                String firstElem = element.getFirstElement().getText();
>>                OMElement result = null;
>>
>>                for (int i = 0; i < vectorFileType.length; i++) {
>>                        if (vectorFileType[i].equalsIgnoreCase(firstElem))
>> {
>>                                binaryDataSource = new
>> FileDataSource(filePath +File.separator+
>> vectorFileType[i]);
>>                                binaryDataHandler = new
>> DataHandler(binaryDataSource);
>>                                // Add the created data handler as an
>> attachment to the outgoing
>> message.
>>                                String binaryID =
>> outMessageContext.addAttachment(binaryDataHandler);
>>                                result =
>> buildDownloadFileSWAEnvelope(vectorFileType[i],binaryID);
>>                                break;
>>                        }
>>                }
>>                return result;
>>        }
>>
>>
>> My Client code:
>>
>>        public void donwloadBinarySWA(String binaryName) throws Exception
>> {
>>
>>                System.out.println("Download Binary with SWA");
>>                Options options = new Options();
>>                options.setProperty(HTTPConstants.MC_GZIP_REQUEST,
>> Boolean.TRUE);
>>                options.setProperty(HTTPConstants.MC_GZIP_RESPONSE,
>> Boolean.TRUE);
>>
>>                ServiceClient sender = new ServiceClient();
>>                sender.setOptions(options);
>>                OperationClient mepClient =
>> sender.createClient(ServiceClient.ANON_OUT_IN_OP);
>>
>>                MessageContext mc = new MessageContext();
>>                SOAPEnvelope env =
>> buildEnvelopeDownloadBinarySWA(binaryName);
>>                mc.setEnvelope(env);
>>
>>                mepClient.addMessageContext(mc);
>>                mepClient.execute(true);
>>
>>                // Get the message context for the response
>>                MessageContext response =
>> mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
>>                SOAPBody body = response.getEnvelope().getBody();
>>                OMElement element = body.getFirstChildWithName(new
>> QName("http://service.sample/xsd", "donwloadResponse"));
>>
>>                if (element != null) {
>>                        processDownloadBinarySWA(response, element);
>>                } else {
>>                        throw new Exception("Malformed response.");
>>                }
>>        }
>>
>> I am also using TCPMon to monitor all soap messages that are sent to my
>> service. What I can see is that all requests are compressed with GZIP but
>> responses are not. My tests are being made using both Axis2 1.3 (as a
>> server) and Tomcat 6.0.18 with this options in server.xml:
>>
>>               port="8080" protocol="HTTP/1.1"
>>               connectionTimeout="20000"
>>               redirectPort="8443"
>>               compression="on"
>>               compressionMinSize="2048"
>>               noCompressionUserAgents="gozilla, traviata"
>>               compressableMimeType="text/html,text/xml"
>>
>> Both in Axis2 and Tomcat the responses are not compressed.
>>
>> Is it a bug on Axis2?
>>
>> Someone had the same problem?
>>
>> I hope some help.
>>
>> Thanks.
>>
>> Julio Cezar Estrella (São Carlos - SP - Brazil)
>>
>> --
>> View this message in context:
>> http://www.nabble.com/GZIP-Response-not-work-on-Axis2-tp20304607p20304607.html
>> Sent from the Axis - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>
> 
> 
> 
> -- 
> Davanum Srinivas :: http://davanum.wordpress.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/GZIP-Response-not-work-on-Axis2-tp20304607p20304985.html
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: GZIP Response not work on Axis2

Posted by Davanum Srinivas <da...@gmail.com>.
did you edit tomcat server.xml?
http://www.cubicleman.com/2007/04/06/enabling-gzip-compression-with-tomcat-and-flex/

thanks,
dims

On Mon, Nov 3, 2008 at 10:20 AM, juliocest <ju...@gmail.com> wrote:
>
> Hi everybody!
>
> I made an application that send attachments on soap message using SWA and
> MTOM. The client and server works properly. Now, I am trying to use GZIP in
> order to compress/decompress SOAP messages.
>
> My Service code:
>
>        public OMElement downloadFileSWA(OMElement element) throws Exception {
>                FileDataSource binaryDataSource;
>                DataHandler binaryDataHandler;
>                String vectorFileType[] =
> {"file10KB","file100KB","file1MB","file10MB","file100MB"};
>
>                // Checking if the resources folder is available
>                File file =  new File(filePath);
>                if (!file.isDirectory() || !file.exists()){
>                    throw new AxisFault("File not available in the service provider...");
>                }
>
>                // Obtain the request (incoming) from the MessageContext as follows
>                MessageContext inMessageContext =
> MessageContext.getCurrentMessageContext();
>
>                // Obtain the operation context from the request message context
>                OperationContext operationContext =
> inMessageContext.getOperationContext();
>
>                // Obtain the response (outgoing) message context from the operation
> context
>                MessageContext outMessageContext =
> operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
>
>                outMessageContext.setProperty(HTTPConstants.MC_GZIP_RESPONSE, true);
>                outMessageContext.setProperty(HTTPConstants.MC_ACCEPT_GZIP, true);
>
>                // Get the first element from the received message
>                String firstElem = element.getFirstElement().getText();
>                OMElement result = null;
>
>                for (int i = 0; i < vectorFileType.length; i++) {
>                        if (vectorFileType[i].equalsIgnoreCase(firstElem)) {
>                                binaryDataSource = new FileDataSource(filePath +File.separator+
> vectorFileType[i]);
>                                binaryDataHandler = new DataHandler(binaryDataSource);
>                                // Add the created data handler as an attachment to the outgoing
> message.
>                                String binaryID = outMessageContext.addAttachment(binaryDataHandler);
>                                result = buildDownloadFileSWAEnvelope(vectorFileType[i],binaryID);
>                                break;
>                        }
>                }
>                return result;
>        }
>
>
> My Client code:
>
>        public void donwloadBinarySWA(String binaryName) throws Exception {
>
>                System.out.println("Download Binary with SWA");
>                Options options = new Options();
>                options.setProperty(HTTPConstants.MC_GZIP_REQUEST,
> Boolean.TRUE);
>                options.setProperty(HTTPConstants.MC_GZIP_RESPONSE, Boolean.TRUE);
>
>                ServiceClient sender = new ServiceClient();
>                sender.setOptions(options);
>                OperationClient mepClient =
> sender.createClient(ServiceClient.ANON_OUT_IN_OP);
>
>                MessageContext mc = new MessageContext();
>                SOAPEnvelope env = buildEnvelopeDownloadBinarySWA(binaryName);
>                mc.setEnvelope(env);
>
>                mepClient.addMessageContext(mc);
>                mepClient.execute(true);
>
>                // Get the message context for the response
>                MessageContext response =
> mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
>                SOAPBody body = response.getEnvelope().getBody();
>                OMElement element = body.getFirstChildWithName(new
> QName("http://service.sample/xsd", "donwloadResponse"));
>
>                if (element != null) {
>                        processDownloadBinarySWA(response, element);
>                } else {
>                        throw new Exception("Malformed response.");
>                }
>        }
>
> I am also using TCPMon to monitor all soap messages that are sent to my
> service. What I can see is that all requests are compressed with GZIP but
> responses are not. My tests are being made using both Axis2 1.3 (as a
> server) and Tomcat 6.0.18 with this options in server.xml:
>
>               port="8080" protocol="HTTP/1.1"
>               connectionTimeout="20000"
>               redirectPort="8443"
>               compression="on"
>               compressionMinSize="2048"
>               noCompressionUserAgents="gozilla, traviata"
>               compressableMimeType="text/html,text/xml"
>
> Both in Axis2 and Tomcat the responses are not compressed.
>
> Is it a bug on Axis2?
>
> Someone had the same problem?
>
> I hope some help.
>
> Thanks.
>
> Julio Cezar Estrella (São Carlos - SP - Brazil)
>
> --
> View this message in context: http://www.nabble.com/GZIP-Response-not-work-on-Axis2-tp20304607p20304607.html
> Sent from the Axis - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>



-- 
Davanum Srinivas :: http://davanum.wordpress.com

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org