Thanks Alexey!

I just voted for that issue and posted a workaround there.

c/p to this mailinglist:
from("cxfrs:bean:rsServer?bindingStyle=SimpleConsumer&resourceClasses=my.own.ResourceClass)

.removeHeader("Content-Length") // <!-- workaround.. just remove the
incoming header so it cannot do any harm

.bean(myBean, "myMethod")


On Fri, Jun 6, 2014 at 9:19 AM, Alexey Markevich <[email protected]>
wrote:

> Hi Jan,
>
> https://issues.apache.org/jira/browse/CAMEL-7246
>
>
> On Fri, 06 Jun 2014 09:27:12 +0300, Jan Hoeve <[email protected]> wrote:
>
>  Hi all,
>>
>> I encountered some strange behavior when using CXF with camel (using the
>> cxfrs component).
>> I have a route builder like:
>>
>> from("cxfrs:bean:rsServer?bindingStyle=SimpleConsumer&
>> resourceClasses=my.own.ResourceClass)
>>         .bean(myBean, "myMethod")
>> Jetty is used as a transport mechanism.
>>
>> When I use GET for my REST requestst, everything is fine.
>> However, when using POST, and supplying a (xml) body in the request, the
>> client does not get the expected response back, but a truncated version.
>> (okay, not exactly true.. the client does get all contents, but only SHOWS
>> a part of that content)
>>
>> Say: my request looks like:
>> <helloWorld />
>> Then the response shown in the client (all clients: soapui, postman
>> (chrome), poster (firefox)) are like:
>> <?xml version=
>>
>> Please note this should be a complete xml document, with some
>> <helloWorldResponse/> in it, but not shown at the moment.
>>
>> Further investigations showed that the Content-Length header in the
>> response was 14, which is _exactly_ the length of the request body! The
>> client truncates the response to this content-length header value.
>> I thought that was just strange, so did some debugging.
>>
>> Findings:
>> In org.apache.cxf.transport.http.Headers.copyFromRequest(
>> HttpServletRequest)
>> all request headers (including the reqest Content-Length) are copied into
>> some field called 'headers'.
>> When creating the http servlet response
>> via org.apache.cxf.transport.http.Headers.copyToResponse(
>> HttpServletResponse),
>> all headers present in the field 'headers' are copied onto the
>> HttpServletResponse.
>> --> there is my problem! The Content-Length header just getting copied
>> from
>> request to response, forcing clients to truncate the response!
>>
>> By the way: Jetty sees this, and emits a DEBUG msg saying:
>> org.eclipse.jetty.http.AbstractGenerator - ContentLength written==80 !=
>> contentLength==14
>>
>> In a nutshell: I think the Content-Length headers should not be just
>> copied
>> from request to response.
>> What do you think, is this a bug or some misunderstanding on my side?
>>
>> Some info about the used jars:
>> camel:2.12.3
>> cxf:2.7.10
>> cxf-rt-transports-http-jetty:2.7.10
>>
>> Thanks for your comments,
>> Jan Hoeve
>>
>
>
> --
> Regards, Alexey.
>

Reply via email to