I'm creating a client on a soap webservice using Spring and CXF.
I was told the webservice (a .NET wsdl service) supports "HTTP compression".

How do I properly make use of that compression? I tried the following, which
did not work:


/@Autowired
private SpringBus bus;

//instantiate
SoapService service = new SoapService(bus);
port = service.getBasicISoapService();

//add compression headers
Map<String, Object> context = ((BindingProvider) port).getRequestContext();
Map<String, List&lt;String>> head = new HashMap<>();
head.put(HttpHeaderHelper.ACCEPT_ENCODING, Arrays.asList("gzip",
"deflate"));
context.put(MessageContext.HTTP_REQUEST_HEADERS, head);/


This will send an xml request with /Accept-Encoding=[gzip, defalte]/, and I
get back:
/
Headers: {content-encoding=[gzip], content-type=[text/xml;charset=utf-8],
transfer-encoding=[chunked], Vary=[Accept-Encoding]}
Error: java.lang.RuntimeException: Couldn't parse stream./
(+full stacktrace, see below).

I then tried adding GZIP Interceptors to the Bus in addition to the header
configuration.
/bus.getOutInterceptors().add(new GZIPInInterceptor());
bus.getOutInterceptors().add(new GZIPOutInterceptor());/

Same error result. What can I do here?? Note that all request work without
problems when removing the compression code.

Full stacktrace:
/2014-11-10 22:13:31,480 WARN org.apache.cxf.phase.PhaseInterceptorChain:
Interceptor for {http://schemas.***}Logon has thrown exception, unwinding
now
java.lang.RuntimeException: Couldn't parse stream.
        at
org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1447)
~[cxf-core-3.0.1.jar:3.0.1]
        at
org.apache.cxf.interceptor.StaxInInterceptor.handleMessage(StaxInInterceptor.java:123)
~[cxf-core-3.0.1.jar:3.0.1]
        at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
[cxf-core-3.0.1.jar:3.0.1]
        at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:798)
[cxf-core-3.0.1.jar:3.0.1]
        at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1636)
[cxf-rt-transports-http-3.0.1.jar:3.0.1]
        at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1525)
[cxf-rt-transports-http-3.0.1.jar:3.0.1]
        at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1330)
[cxf-rt-transports-http-3.0.1.jar:3.0.1]
        at
org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:56)
[cxf-core-3.0.1.jar:3.0.1]
        at 
org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:215)
[cxf-core-3.0.1.jar:3.0.1]
        at 
org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
[cxf-core-3.0.1.jar:3.0.1]
        at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:638)
[cxf-rt-transports-http-3.0.1.jar:3.0.1]
        at
org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
[cxf-core-3.0.1.jar:3.0.1]
        at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
[cxf-core-3.0.1.jar:3.0.1]
        at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:514)
[cxf-core-3.0.1.jar:3.0.1]
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:423)
[cxf-core-3.0.1.jar:3.0.1]
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:326)
[cxf-core-3.0.1.jar:3.0.1]
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:279)
[cxf-core-3.0.1.jar:3.0.1]
        at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
[cxf-rt-frontend-simple-3.0.1.jar:3.0.1]
        at 
org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:137)
[cxf-rt-frontend-jaxws-3.0.1.jar:3.0.1]
        at com.sun.proxy.$Proxy145.logon(Unknown Source) [?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
~[?:1.7.0_51]
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
~[?:1.7.0_51]
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[?:1.7.0_51]
        at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_51]
        at
org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:63)
[spring-expression-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at
org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:122)
[spring-expression-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at
org.springframework.expression.spel.ast.MethodReference.access$000(MethodReference.java:44)
[spring-expression-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at
org.springframework.expression.spel.ast.MethodReference$MethodValueRef.getValue(MethodReference.java:258)
[spring-expression-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at
org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:84)
[spring-expression-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at
org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:114)
[spring-expression-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at
org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:111)
[spring-expression-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at
org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:159)
[spring-integration-core-4.0.4.RELEASE.jar:?]
        at
org.springframework.integration.util.MessagingMethodInvokerHelper.processInternal(MessagingMethodInvokerHelper.java:273)
[spring-integration-core-4.0.4.RELEASE.jar:?]
        at
org.springframework.integration.util.MessagingMethodInvokerHelper.process(MessagingMethodInvokerHelper.java:142)
[spring-integration-core-4.0.4.RELEASE.jar:?]
        at
org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:75)
[spring-integration-core-4.0.4.RELEASE.jar:?]
        at
org.springframework.integration.handler.ServiceActivatingHandler.handleRequestMessage(ServiceActivatingHandler.java:71)
[spring-integration-core-4.0.4.RELEASE.jar:?]
        at
org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:170)
[spring-integration-core-4.0.4.RELEASE.jar:?]
        at
org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
[spring-integration-core-4.0.4.RELEASE.jar:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
~[?:1.7.0_51]
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
~[?:1.7.0_51]
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[?:1.7.0_51]
        at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_51]
        at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
[spring-aop-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
[spring-aop-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
[spring-aop-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at
org.springframework.integration.monitor.SimpleMessageHandlerMetrics.handleMessage(SimpleMessageHandlerMetrics.java:107)
[spring-integration-jmx-4.0.4.RELEASE.jar:?]
        at
org.springframework.integration.monitor.SimpleMessageHandlerMetrics.invoke(SimpleMessageHandlerMetrics.java:87)
[spring-integration-jmx-4.0.4.RELEASE.jar:?]
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
[spring-aop-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
[spring-aop-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at com.sun.proxy.$Proxy155.handleMessage(Unknown Source) [?:?]
        at
org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116)
[spring-integration-core-4.0.4.RELEASE.jar:?]
        at
org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:101)
[spring-integration-core-4.0.4.RELEASE.jar:?]
        at
org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:97)
[spring-integration-core-4.0.4.RELEASE.jar:?]
        at
org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
[spring-integration-core-4.0.4.RELEASE.jar:?]
        at
org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:255)
[spring-integration-core-4.0.4.RELEASE.jar:?]
        at
org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:109)
[spring-messaging-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at
org.springframework.messaging.core.GenericMessagingTemplate.doSendAndReceive(GenericMessagingTemplate.java:144)
[spring-messaging-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at
org.springframework.messaging.core.GenericMessagingTemplate.doSendAndReceive(GenericMessagingTemplate.java:44)
[spring-messaging-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at
org.springframework.messaging.core.AbstractMessagingTemplate.sendAndReceive(AbstractMessagingTemplate.java:75)
[spring-messaging-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at
org.springframework.integration.gateway.MessagingGatewaySupport.doSendAndReceive(MessagingGatewaySupport.java:250)
[spring-integration-core-4.0.4.RELEASE.jar:?]
        at
org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceiveMessage(MessagingGatewaySupport.java:224)
[spring-integration-core-4.0.4.RELEASE.jar:?]
        at
org.springframework.integration.ip.tcp.TcpInboundGateway.doOnMessage(TcpInboundGateway.java:99)
[spring-integration-ip-4.0.4.RELEASE.jar:?]
        at
org.springframework.integration.ip.tcp.TcpInboundGateway.onMessage(TcpInboundGateway.java:89)
[spring-integration-ip-4.0.4.RELEASE.jar:?]
        at
org.springframework.integration.ip.tcp.connection.TcpNioConnection.sendToChannel(TcpNioConnection.java:349)
[spring-integration-ip-4.0.4.RELEASE.jar:?]
        at
org.springframework.integration.ip.tcp.connection.TcpNioConnection.run(TcpNioConnection.java:222)
[spring-integration-ip-4.0.4.RELEASE.jar:?]
        at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[?:1.7.0_51]
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[?:1.7.0_51]
        at java.lang.Thread.run(Thread.java:744) [?:1.7.0_51]
Caused by: com.ctc.wstx.exc.WstxIOException: Invalid UTF-8 start byte 0x8b
(at char #2, byte #-1)
        at 
com.ctc.wstx.stax.WstxInputFactory.doCreateSR(WstxInputFactory.java:550)
~[woodstox-core-asl-4.4.0.jar:4.4.0]
        at 
com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:605)
~[woodstox-core-asl-4.4.0.jar:4.4.0]
        at 
com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:628)
~[woodstox-core-asl-4.4.0.jar:4.4.0]
        at
com.ctc.wstx.stax.WstxInputFactory.createXMLStreamReader(WstxInputFactory.java:331)
~[woodstox-core-asl-4.4.0.jar:4.4.0]
        at
org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1445)
~[cxf-core-3.0.1.jar:3.0.1]
        ... 75 more
Caused by: java.io.CharConversionException: Invalid UTF-8 start byte 0x8b
(at char #2, byte #-1)
        at com.ctc.wstx.io.UTF8Reader.reportInvalidInitial(UTF8Reader.java:303)
~[woodstox-core-asl-4.4.0.jar:4.4.0]
        at com.ctc.wstx.io.UTF8Reader.read(UTF8Reader.java:189)
~[woodstox-core-asl-4.4.0.jar:4.4.0]
        at
com.ctc.wstx.io.ReaderBootstrapper.initialLoad(ReaderBootstrapper.java:250)
~[woodstox-core-asl-4.4.0.jar:4.4.0]
        at
com.ctc.wstx.io.ReaderBootstrapper.bootstrapInput(ReaderBootstrapper.java:133)
~[woodstox-core-asl-4.4.0.jar:4.4.0]
        at 
com.ctc.wstx.stax.WstxInputFactory.doCreateSR(WstxInputFactory.java:545)
~[woodstox-core-asl-4.4.0.jar:4.4.0]
        at 
com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:605)
~[woodstox-core-asl-4.4.0.jar:4.4.0]
        at 
com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:628)
~[woodstox-core-asl-4.4.0.jar:4.4.0]
        at
com.ctc.wstx.stax.WstxInputFactory.createXMLStreamReader(WstxInputFactory.java:331)
~[woodstox-core-asl-4.4.0.jar:4.4.0]
        at org.apache.cxf.staxutils.StaxUt/



--
View this message in context: 
http://cxf.547215.n5.nabble.com/How-to-properly-use-HTTP-compression-with-CXF-3-tp5750949.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to