You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by cantalou <ca...@gmail.com> on 2011/07/12 16:55:49 UTC

How to use GZIP

Dear All, 
i want to configure GZIPFeature to compress message in my
CXFserver(tomcat6.0),
follow is the configuration:
<bean id="GZIPFeature"
class="org.apache.cxf.transport.common.gzip.GZIPFeature">
		<property name="threshold">
			<value>1</value> 
		</property>
</bean>	
<cxf:bus>
    <cxf:features>
       <ref bean="loggingFeature"/>
		<ref bean="GZIPFeature"></ref>
       </cxf:features>
</cxf:bus>


then i get  ###################*the server logs :*####################


Address: http://localhost:8080/cxf/HelloWorld
Encoding: UTF-8
Http-Method: POST
Content-Type: text/xml; charset=UTF-8
Headers: {Accept=[*/*], accept-encoding=[gzip;q=1.0, identity; q=0.5,
*;q=0], cache-control=[no-cache], connection=[keep-alive],
Content-Length=[177], content-type=[text/xml; charset=UTF-8],
host=[localhost:8080], pragma=[no-cache], SOAPAction=[""],
user-agent=[Apache CXF 2.4.1]}
Payload: <soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:say
xmlns:ns2="http://service.cxf.com/"><msg>ss</msg></ns2:say></soap:Body></soap:Envelope>
--------------------------------------
2011-7-12 22:30:10 org.apache.cxf.interceptor.AbstractLoggingInterceptor log
信息: Outbound Message
---------------------------
ID: 3
Encoding: UTF-8
Content-Type: text/xml
Headers: {Content-Encoding=[gzip], Vary=[Accept-Encoding]}
Payload: <soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:sayResponse
xmlns:ns2="http://service.cxf.com/"><return>ss Tue Jul 12 22:30:10 CST
2011</return></ns2:sayResponse></soap:Body></soap:Envelope>
-----------------------------



######################*the client logs:*###################


Address: http://localhost:8080/cxf/HelloWorld
Encoding: UTF-8
Content-Type: text/xml
Headers: {Accept=[*/*], Accept-Encoding=[gzip;q=1.0, identity; q=0.5,
*;q=0], SOAPAction=[""]}
Payload: <soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:say
xmlns:ns2="http://service.cxf.com/"><msg>ss</msg></ns2:say></soap:Body></soap:Envelope>
--------------------------------------
2011-7-12 22:30:10 org.apache.cxf.interceptor.AbstractLoggingInterceptor log
信息: Inbound Message
----------------------------
ID: 1
Response-Code: 200
Encoding: UTF-8
Content-Type: text/xml;charset=UTF-8
Headers: {Content-Length=[168], content-type=[text/xml;charset=UTF-8],
Date=[Tue, 12 Jul 2011 14:30:10 GMT], Server=[Apache-Coyote/1.1],
Vary=[Accept-Encoding]}
Payload: <soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:sayResponse
xmlns:ns2="http://service.cxf.com/"><return>ss Tue Jul 12 22:30:10 CST
2011</return></ns2:sayResponse></soap:Body></soap:Envelope>
--------------------------

does the response has been compressed with gzip?


another question is that :if i don't put the 
"   factory.setFeatures(Arrays.asList(new AbstractFeature[]{new
LoggingFeature(),newGZIPFeature()}));" in the client code ,i can't see the
"Headers: {Content-Encoding=[gzip], Vary=[Accept-Encoding]}" in the server
logs ?

Thank you so much. 



--
View this message in context: http://cxf.547215.n5.nabble.com/How-to-use-GZIP-tp4579145p4579145.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: How to use GZIP

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

I think Logging feature reports the content before it has been
gzipped, so you can confirm it using a tcpmon utility
Cheers, Sergey

On Tue, Jul 12, 2011 at 3:55 PM, cantalou <ca...@gmail.com> wrote:
> Dear All,
> i want to configure GZIPFeature to compress message in my
> CXFserver(tomcat6.0),
> follow is the configuration:
> <bean id="GZIPFeature"
> class="org.apache.cxf.transport.common.gzip.GZIPFeature">
>                <property name="threshold">
>                        <value>1</value>
>                </property>
> </bean>
> <cxf:bus>
>    <cxf:features>
>       <ref bean="loggingFeature"/>
>                <ref bean="GZIPFeature"></ref>
>       </cxf:features>
> </cxf:bus>
>


>
> then i get  ###################*the server logs :*####################
>
>
> Address: http://localhost:8080/cxf/HelloWorld
> Encoding: UTF-8
> Http-Method: POST
> Content-Type: text/xml; charset=UTF-8
> Headers: {Accept=[*/*], accept-encoding=[gzip;q=1.0, identity; q=0.5,
> *;q=0], cache-control=[no-cache], connection=[keep-alive],
> Content-Length=[177], content-type=[text/xml; charset=UTF-8],
> host=[localhost:8080], pragma=[no-cache], SOAPAction=[""],
> user-agent=[Apache CXF 2.4.1]}
> Payload: <soap:Envelope
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:say
> xmlns:ns2="http://service.cxf.com/"><msg>ss</msg></ns2:say></soap:Body></soap:Envelope>
> --------------------------------------
> 2011-7-12 22:30:10 org.apache.cxf.interceptor.AbstractLoggingInterceptor log
> 信息: Outbound Message
> ---------------------------
> ID: 3
> Encoding: UTF-8
> Content-Type: text/xml
> Headers: {Content-Encoding=[gzip], Vary=[Accept-Encoding]}
> Payload: <soap:Envelope
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:sayResponse
> xmlns:ns2="http://service.cxf.com/"><return>ss Tue Jul 12 22:30:10 CST
> 2011</return></ns2:sayResponse></soap:Body></soap:Envelope>
> -----------------------------
>
>
>
> ######################*the client logs:*###################
>
>
> Address: http://localhost:8080/cxf/HelloWorld
> Encoding: UTF-8
> Content-Type: text/xml
> Headers: {Accept=[*/*], Accept-Encoding=[gzip;q=1.0, identity; q=0.5,
> *;q=0], SOAPAction=[""]}
> Payload: <soap:Envelope
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:say
> xmlns:ns2="http://service.cxf.com/"><msg>ss</msg></ns2:say></soap:Body></soap:Envelope>
> --------------------------------------
> 2011-7-12 22:30:10 org.apache.cxf.interceptor.AbstractLoggingInterceptor log
> 信息: Inbound Message
> ----------------------------
> ID: 1
> Response-Code: 200
> Encoding: UTF-8
> Content-Type: text/xml;charset=UTF-8
> Headers: {Content-Length=[168], content-type=[text/xml;charset=UTF-8],
> Date=[Tue, 12 Jul 2011 14:30:10 GMT], Server=[Apache-Coyote/1.1],
> Vary=[Accept-Encoding]}
> Payload: <soap:Envelope
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:sayResponse
> xmlns:ns2="http://service.cxf.com/"><return>ss Tue Jul 12 22:30:10 CST
> 2011</return></ns2:sayResponse></soap:Body></soap:Envelope>
> --------------------------
>
> does the response has been compressed with gzip?
>
>
> another question is that :if i don't put the
> "   factory.setFeatures(Arrays.asList(new AbstractFeature[]{new
> LoggingFeature(),newGZIPFeature()}));" in the client code ,i can't see the
> "Headers: {Content-Encoding=[gzip], Vary=[Accept-Encoding]}" in the server
> logs ?
>
> Thank you so much.
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/How-to-use-GZIP-tp4579145p4579145.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>