Buscar este blog

martes, 31 de marzo de 2015

CXF - Invalid UTF-8 start byte 0x8b (at char #2, byte #-1)

Problem/Cause

You get this error when you are working with a CXF client which receives a response with content encoding GZIP.

In my case I was working with Apache Camel, using a cxfEndPoint and simulating the server with SoapUI.


Content-Encoding: gzip
Server: Jetty(6.1.26)
Transfer-Encoding: chunked
Content-Type: text/xml; charset=utf-8

Solution

Just add org.apache.cxf.transport.common.gzip.GZIPInInterceptor as interceptor for incoming messages. This class will parse the response and decompressit.


<bean id="loggingOutInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
<bean id="loggingInInterceptor" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
<bean id="gziptInterceptor" class="org.apache.cxf.transport.common.gzip.GZIPInInterceptor"/>

<cxf:cxfEndpoint id="dllCrytpoWSEndpoint"
 address="https://localhost:9443/mockDllCryptoServiceSoap"
 serviceClass="XXXXX.DllCryptoServiceSoap" serviceName="ssp:DllCryptoService"
 endpointName="{http://XXXXX}DllCryptoServiceSoap"
 wsdlURL="src/main/resources/wsdl/DllCryptoServiceSoap.wsdl" xmlns:ssp="http://XXXXX"
 loggingFeatureEnabled="true">

 <cxf:outInterceptors>
  <ref bean="loggingOutInterceptor" />
 </cxf:outInterceptors>

 <cxf:inInterceptors>
  <ref bean="gziptInterceptor" />
  <ref bean="loggingInInterceptor" />
 </cxf:inInterceptors>

</cxf:cxfEndpoint>

No hay comentarios:

Publicar un comentario