Quantcast

CXF - problem when receiving web service response

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

CXF - problem when receiving web service response

kafe
This post was updated on .
Hi,

I'm trying to use Camel as a web service proxy.
I've then configured 2 CXF endpoints :

 <cxf:cxfEndpoint id="helloServiceEndpoint" address="/helloservice"
      serviceClass="com.test.HelloService" />
     
<cxf:cxfEndpoint id="helloServiceDistantEndpoint"
        address="http://localhost:8088/mockHelloService"
        serviceClass="com.test.HelloService" />

and a simple route :

<route id="traiterDemandeSoap">
        <from uri="cxf:bean:helloServiceEndpoint" />
        <to uri="log:input"/>
        <to uri="cxf:bean:helloServiceDistantEndpoint" />
</route>

Everything is packaged as a war and deployed in JBoss 5.1.0.

To call my route as a webservice, i use SoapUI.
I also use SoapUI on port 8088 as a mock for the distant webservice.

If i directly call the SoapUI mock from SoapUI, everything is ok but when i use my route, it seems that CXF has a problem to deal with the response :

17:15:06,340 ERROR [DefaultErrorHandler] Failed delivery for exchangeId: pc-dev-49-54952-1321373519881-0-1. Exhausted after delivery attempt: 1 caught:
java.lang.RuntimeException: Couldn't parse stream.
        at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1181)
        at org.apache.cxf.interceptor.StaxInInterceptor.handleMessage(StaxInInterceptor.java:104)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
        at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:783)
        at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1627)
        at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:1499)
        at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:371)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
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:536)
        at com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:585)
        at com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:610)
        at com.ctc.wstx.stax.WstxInputFactory.createXMLStreamReader(WstxInputFactory.java:316)
        at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1179)
        ... 9 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)
        at com.ctc.wstx.io.UTF8Reader.read(UTF8Reader.java:189)
        at com.ctc.wstx.io.ReaderBootstrapper.initialLoad(ReaderBootstrapper.java:250)
        at com.ctc.wstx.io.ReaderBootstrapper.bootstrapInput(ReaderBootstrapper.java:133)
        at com.ctc.wstx.stax.WstxInputFactory.doCreateSR(WstxInputFactory.java:531)
        ... 13 more

When i analyse the network traffic with wireshark, there are four http requests :
- a POST that is sent by SoapUI to call the route
- a second POST request sent by Camel to call the distant web service (SoapUI mock)
- the response to the previous POST with a http status 200
- a HTTP 500 (internal servlet error) due to the previous stack trace

What i see is that the POST response is in gzip format (Content-Encoding: gzip\r\n) and maybe this is the problem ??


I really need help.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CFX - problem when receiving web service response

kafe
I found something interesting, if i modify my route to use the CXF MESSAGE format :

<route id="traiterDemandeSoap">
        <from uri="cxf:bean:helloServiceEndpoint?dataFormat=MESSAGE" />
        <to uri="log:input"/>
        <to uri="cxf:bean:helloServiceDistantEndpoint?dataFormat=MESSAGE" />
</route>

it works... i get my response on my SOAP UI client.

But i'd really like to know why it does not work with the POJO format for example (same problem with PAYLOAD one).
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CFX - problem when receiving web service response

kafe
Guys, i'm back to keep you informed.

I've solved my problem and i can now use POJO format, but i had to disable the gzip compression in the SoapUI mock configuration (so that the http response of the web service call is not compressed and can then be correctly managed by CXF/http connector ?).

That is a good step for me but it seems strange that gzip compression is not correctly managed in POJO format.

I'm going to have a look at the GZIPFeature with CXF.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CFX - problem when receiving web service response

Willem.Jiang
You many need to install the gzip feature of CXF to consumer request
which is gziped.

On Wed Nov 16 18:43:53 2011, kafe wrote:

> Guys, i'm back to keep you informed.
>
> I've solved my problem and i can now use POJO format, but i had to disable
> the gzip compression in the SoapUI mock configuration (so that the http
> response of the web service call is not compressed and can then be correctly
> managed by CXF/http connector ?).
>
> That is a good step for me but it seems strange that gzip compression is not
> correctly managed in POJO format.
>
> I'm going to have a look at the GZIPFeature with CXF.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CXF-problem-when-receiving-web-service-response-tp4994825p4997346.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CFX - problem when receiving web service response

kafe
That's what i'm trying to do but without success right now.

Here is my camel-cxf.xml spring configuration file :

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:cxf="http://camel.apache.org/schema/cxf"
        xmlns:cxf-core="http://cxf.apache.org/core"
        xsi:schemaLocation="
       http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/cxf
       http://camel.apache.org/schema/cxf/camel-cxf.xsd
       http://cxf.apache.org/core
       http://cxf.apache.org/schemas/core.xsd">

        <import resource="classpath:META-INF/cxf/cxf.xml" />
        <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
        <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

        <cxf:cxfEndpoint id="helloServiceEndpoint" address="/helloservice"
      serviceClass="com.test.HelloService" bus="myBus" />
     
<cxf:cxfEndpoint id="helloServiceDistantEndpoint"
        address="http://localhost:8088/mockHelloService"
        serviceClass="com.test.HelloService" bus="myBus" />

        <bean id="gzipFeature" class="org.apache.cxf.transport.common.gzip.GZIPFeature">
                <property name="threshold">
                        <value>1</value>
                </property>
        </bean>

        <cxf-core:bus name="myBus">
                <cxf-core:features>
                        <ref bean="gzipFeature"></ref>
                </cxf-core:features>
        </cxf-core:bus>

</beans>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CFX - problem when receiving web service response

Willem.Jiang
You are using Servlet transport.
You need to configure the WebContainor the support gzip.

On Wed Nov 16 21:34:33 2011, kafe wrote:

> That's what i'm trying to do but without success right now.
>
> Here is my camel-cxf.xml spring configuration file :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:cxf="http://camel.apache.org/schema/cxf"
> xmlns:cxf-core="http://cxf.apache.org/core"
> xsi:schemaLocation="
>         http://www.springframework.org/schema/beans
>         http://www.springframework.org/schema/beans/spring-beans.xsd
>         http://camel.apache.org/schema/cxf
>         http://camel.apache.org/schema/cxf/camel-cxf.xsd
>         http://cxf.apache.org/core
>         http://cxf.apache.org/schemas/core.xsd">
>
> <import resource="classpath:META-INF/cxf/cxf.xml" />
> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>
> <cxf:cxfEndpoint id="helloServiceEndpoint" address="/helloservice"
>        serviceClass="com.test.HelloService" bus="myBus" />
>
> <cxf:cxfEndpoint id="helloServiceDistantEndpoint"
>          address="http://localhost:8088/mockHelloService"
>          serviceClass="com.test.HelloService" bus="myBus" />
>
> <bean id="gzipFeature"
> class="org.apache.cxf.transport.common.gzip.GZIPFeature">
> <property name="threshold">
> <value>1</value>
> </property>
> </bean>
>
> <cxf-core:bus name="myBus">
> <cxf-core:features>
> <ref bean="gzipFeature"></ref>
> </cxf-core:features>
> </cxf-core:bus>
>
> </beans>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CXF-problem-when-receiving-web-service-response-tp4994825p4997712.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CFX - problem when receiving web service response

kafe
Hum... can you be more precise please ? How can i do that ?

Thanks for your help.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CFX - problem when receiving web service response

kafe
I modified JBoss "server/default/deploy/jbossweb.sar/server.xml" http connector and set compression="1" but same result :-(
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CFX - problem when receiving web service response

kafe
Actually, i solved my problem by adding a GZIPInInterceptor to my CXF endpoints.

Thx for help.
Loading...