You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Amit <ap...@att.com> on 2013/10/10 20:28:13 UTC
CFX-Bean:headers access Issue
I am sending request to below route with "Content-Type: audio/amr" but i am
unable to access Content-Type in myService.
<route xmlns="http://camel.apache.org/schema/spring" trace="true">
<from uri="servlet:///myServlet?matchOnUriPrefix=true" />
<to uri="cxfbean:myService" />
</route>
Service with method
@POST
@Path("/{package}/{service}")
public Response processRequest(@Context UriInfo uriInfo,
@Context HttpServletRequest request,
@Context HttpHeaders headers)
{
MediaType mimeType = headers.getMediaType();
}
--
View this message in context: http://camel.465427.n5.nabble.com/CFX-Bean-headers-access-Issue-tp5741312.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: CFX-Bean:headers access Issue
Posted by Sergey Beryozkin <sb...@gmail.com>.
On 22/10/13 15:06, Amit wrote:
> Would you please fixed this issue in 2.11.3 release.
I've attached a patch on your behalf,
https://issues.apache.org/jira/secure/attachment/12610872/camel6878.txt
and hope the team will have no problems with applying it.
thanks for spotting this minor issue;
Cheers, Sergey
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CFX-Bean-headers-access-Issue-tp5741312p5742030.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Re: CFX-Bean:headers access Issue
Posted by Amit <am...@gmail.com>.
Would you please fixed this issue in 2.11.3 release.
--
View this message in context: http://camel.465427.n5.nabble.com/CFX-Bean-headers-access-Issue-tp5741312p5742030.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: CFX-Bean:headers access Issue
Posted by Christian Mueller <ch...@gmail.com>.
Amit,
can you please subscribe to the discussion forum in Nabble as we describe
here [1].
Otherwise all your mails has to be moderate manually by the Camel team so
that your post is also send to our mailing list which most of the Camel team
member are using instead of Nabble. Therefore your post is may
missed/delayed and you don't get an answer in the normal time frame we
answer questions.
Last but not least, it cost time which we cannot spend developing Camel,
answering questions or improving the documentation...
[1] http://camel.apache.org/discussion-forums.html
Thanks in advance,
Christian
--
View this message in context: http://camel.465427.n5.nabble.com/CFX-Bean-headers-access-Issue-tp5741312p5741705.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: CFX-Bean:headers access Issue
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
that is good, thanks for getting to the bottom of it, must be an easy
fix, IMHO we will just need to remove 'else', in a regular CXF request,
CONTENT_TYPE is available on the message as a dedicated property & also
part of the headers map.
Would you like to attach a basic patch to that JIRA issue ? It is your
fix after all, I'll edit the JIRA description later (I thought the
headers were blocked which is where I was wrong)
Thanks, Sergey
On 16/10/13 18:51, Amit wrote:
> After removing conent-type from header filter. I found the issue in
> CxfHeaderHelper below method. It puts the content Type in message not in
> header and org.apache.cxf.jaxrs.impl.HttpHeadersImpl class get content Type
> from header. I did comment out "if
> (Exchange.CONTENT_TYPE.equals(entry.getKey()))" block and it works as
> expected.
>
>
>
> public static void propagateCamelToCxf(HeaderFilterStrategy strategy,
> Map<String, Object> headers, Message message, Exchange exchange)
> {
>
> Map<String, List<String>> cxfHeaders =
> CastUtils.cast((Map<?,
> ?>)message.get(Message.PROTOCOL_HEADERS));
>
> if (cxfHeaders == null) {
> // use a treemap to keep ordering and ignore key case
> cxfHeaders = new TreeMap<String,
> List<String>>(String.CASE_INSENSITIVE_ORDER);
> message.put(Message.PROTOCOL_HEADERS, cxfHeaders);
> }
>
> for (Map.Entry<String, Object> entry : headers.entrySet()) {
> if (strategy != null
> && !strategy.applyFilterToCamelHeaders(entry.getKey(),
> entry.getValue(), exchange)) {
>
> if (Exchange.CONTENT_TYPE.equals(entry.getKey())) {
> //commented out this block
> message.put(Message.CONTENT_TYPE, entry.getValue());
> } else
>
> if (Client.REQUEST_CONTEXT.equals(entry.getKey())
> ||
> Client.RESPONSE_CONTEXT.equals(entry.getKey())
> || Message.RESPONSE_CODE.equals(entry.getKey()))
> {
> message.put(entry.getKey(), entry.getValue());
> } else {
> Object values = entry.getValue();
> if (values instanceof List<?>) {
> cxfHeaders.put(entry.getKey(),
> CastUtils.cast((List<?>)values, String.class));
> } else {
> List<String> listValue = new ArrayList<String>();
> listValue.add(entry.getValue().toString());
> cxfHeaders.put(entry.getKey(), listValue);
> }
> }
> }
> }
> }
>
> Thanks,
> Amit
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CFX-Bean-headers-access-Issue-tp5741312p5741691.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com
Re: CFX-Bean:headers access Issue
Posted by Amit <ap...@att.com>.
After removing conent-type from header filter. I found the issue in
CxfHeaderHelper below method. It puts the content Type in message not in
header and org.apache.cxf.jaxrs.impl.HttpHeadersImpl class get content Type
from header. I did comment out "if
(Exchange.CONTENT_TYPE.equals(entry.getKey()))" block and it works as
expected.
public static void propagateCamelToCxf(HeaderFilterStrategy strategy,
Map<String, Object> headers, Message message, Exchange exchange)
{
Map<String, List<String>> cxfHeaders =
CastUtils.cast((Map<?,
?>)message.get(Message.PROTOCOL_HEADERS));
if (cxfHeaders == null) {
// use a treemap to keep ordering and ignore key case
cxfHeaders = new TreeMap<String,
List<String>>(String.CASE_INSENSITIVE_ORDER);
message.put(Message.PROTOCOL_HEADERS, cxfHeaders);
}
for (Map.Entry<String, Object> entry : headers.entrySet()) {
if (strategy != null
&& !strategy.applyFilterToCamelHeaders(entry.getKey(),
entry.getValue(), exchange)) {
if (Exchange.CONTENT_TYPE.equals(entry.getKey())) {
//commented out this block
message.put(Message.CONTENT_TYPE, entry.getValue());
} else
if (Client.REQUEST_CONTEXT.equals(entry.getKey())
||
Client.RESPONSE_CONTEXT.equals(entry.getKey())
|| Message.RESPONSE_CODE.equals(entry.getKey()))
{
message.put(entry.getKey(), entry.getValue());
} else {
Object values = entry.getValue();
if (values instanceof List<?>) {
cxfHeaders.put(entry.getKey(),
CastUtils.cast((List<?>)values, String.class));
} else {
List<String> listValue = new ArrayList<String>();
listValue.add(entry.getValue().toString());
cxfHeaders.put(entry.getKey(), listValue);
}
}
}
}
}
Thanks,
Amit
--
View this message in context: http://camel.465427.n5.nabble.com/CFX-Bean-headers-access-Issue-tp5741312p5741691.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: CFX-Bean:headers access Issue
Posted by Sergey Beryozkin <sb...@gmail.com>.
Can you give me a favor and attach a Maven based test project to
https://issues.apache.org/jira/browse/CAMEL-6865
that would make it easier for me to find the time to deal with this issue
Thanks, Sergey
On 16/10/13 10:29, Sergey Beryozkin wrote:
> Hi
> On 14/10/13 19:34, Amit wrote:
>> I think the issue is
>> org.apache.camel.component.cxf.common.header.CxfHeaderFilterStrategy
>> filters
>> the Content-Type.
>
> If so then IMHO this is a bug that the headers are lost before a CXF
> JAX-RS endpoint invocation is complete, hopefully you can sort the issue
> out by applying the header filter strategy somehow, but it is not that a
> user should be worried about given that it is a basic expectation of
> JAX-RS that the headers are visible
>
> FYI, you might want to bypass cxfrs altogether and link directly to CXF
> jaxrs:server endpoint; you'd need to have its address using a 'camel'
> transport scheme
>
> I'll open a minor level JIRA to keep the issue tracked, will try to do a
> patch
>
> Cheers, Sergey
>
>> so i did try to add custom filter on endpoint but i am
>> getting below error. Is the headerFilterStrategy on the cfxbean endpoint
>> working?
>>
>> Failed to create route myroute at: >>>
>> To[cxfbean:speechService?headerFilterStrategy=#nimbusCxfHeaderFilterStrategy]
>>
>> <<< in route: Route(myroute)[[From[servlet:///speech/2.0/sp... because of
>> Failed to resolve endpoint:
>> cxfbean://speechService?headerFilterStrategy=%23nimbusCxfHeaderFilterStrategy
>>
>> due to: Could not find a suitable setter for property:
>> headerFilterStrategy
>> as there isn't a setter method with same type: java.lang.String nor type
>> conversion possible: No type converter available to convert from type:
>> java.lang.String to the required type:
>> org.apache.camel.spi.HeaderFilterStrategy with value
>> nimbusCxfHeaderFilterStrategy
>> CAUSED BY: java.lang.IllegalArgumentException: Could not find a suitable
>> setter for property: headerFilterStrategy as there isn't a setter method
>> with same type: java.lang.String nor type conversion possible: No type
>> converter available to convert from type: java.lang.String to the
>> required
>> type: org.apache.camel.spi.HeaderFilterStrategy with value
>> nimbusCxfHeaderFilterStrategy
>> STACKTRACE: at org.apache.camel.model.RouteDefinition(addRoutes:883)
>>
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/CFX-Bean-headers-access-Issue-tp5741312p5741562.html
>>
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>
Re: CFX-Bean:headers access Issue
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 14/10/13 19:34, Amit wrote:
> I think the issue is
> org.apache.camel.component.cxf.common.header.CxfHeaderFilterStrategy filters
> the Content-Type.
If so then IMHO this is a bug that the headers are lost before a CXF
JAX-RS endpoint invocation is complete, hopefully you can sort the issue
out by applying the header filter strategy somehow, but it is not that a
user should be worried about given that it is a basic expectation of
JAX-RS that the headers are visible
FYI, you might want to bypass cxfrs altogether and link directly to CXF
jaxrs:server endpoint; you'd need to have its address using a 'camel'
transport scheme
I'll open a minor level JIRA to keep the issue tracked, will try to do a
patch
Cheers, Sergey
> so i did try to add custom filter on endpoint but i am
> getting below error. Is the headerFilterStrategy on the cfxbean endpoint
> working?
>
> Failed to create route myroute at: >>>
> To[cxfbean:speechService?headerFilterStrategy=#nimbusCxfHeaderFilterStrategy]
> <<< in route: Route(myroute)[[From[servlet:///speech/2.0/sp... because of
> Failed to resolve endpoint:
> cxfbean://speechService?headerFilterStrategy=%23nimbusCxfHeaderFilterStrategy
> due to: Could not find a suitable setter for property: headerFilterStrategy
> as there isn't a setter method with same type: java.lang.String nor type
> conversion possible: No type converter available to convert from type:
> java.lang.String to the required type:
> org.apache.camel.spi.HeaderFilterStrategy with value
> nimbusCxfHeaderFilterStrategy
> CAUSED BY: java.lang.IllegalArgumentException: Could not find a suitable
> setter for property: headerFilterStrategy as there isn't a setter method
> with same type: java.lang.String nor type conversion possible: No type
> converter available to convert from type: java.lang.String to the required
> type: org.apache.camel.spi.HeaderFilterStrategy with value
> nimbusCxfHeaderFilterStrategy
> STACKTRACE: at org.apache.camel.model.RouteDefinition(addRoutes:883)
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CFX-Bean-headers-access-Issue-tp5741312p5741562.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Re: CFX-Bean:headers access Issue
Posted by Amit <ap...@att.com>.
I think the issue is
org.apache.camel.component.cxf.common.header.CxfHeaderFilterStrategy filters
the Content-Type. so i did try to add custom filter on endpoint but i am
getting below error. Is the headerFilterStrategy on the cfxbean endpoint
working?
Failed to create route myroute at: >>>
To[cxfbean:speechService?headerFilterStrategy=#nimbusCxfHeaderFilterStrategy]
<<< in route: Route(myroute)[[From[servlet:///speech/2.0/sp... because of
Failed to resolve endpoint:
cxfbean://speechService?headerFilterStrategy=%23nimbusCxfHeaderFilterStrategy
due to: Could not find a suitable setter for property: headerFilterStrategy
as there isn't a setter method with same type: java.lang.String nor type
conversion possible: No type converter available to convert from type:
java.lang.String to the required type:
org.apache.camel.spi.HeaderFilterStrategy with value
nimbusCxfHeaderFilterStrategy
CAUSED BY: java.lang.IllegalArgumentException: Could not find a suitable
setter for property: headerFilterStrategy as there isn't a setter method
with same type: java.lang.String nor type conversion possible: No type
converter available to convert from type: java.lang.String to the required
type: org.apache.camel.spi.HeaderFilterStrategy with value
nimbusCxfHeaderFilterStrategy
STACKTRACE: at org.apache.camel.model.RouteDefinition(addRoutes:883)
--
View this message in context: http://camel.465427.n5.nabble.com/CFX-Bean-headers-access-Issue-tp5741312p5741562.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: CFX-Bean:headers access Issue
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi, as far as I recall, the requests coming via Camel Servlet did not
have HttpServletRequest objects set at some point of time, which might
explain why headers are empty,
is 'request' initialized in your case or is it null ?
May be you should try the latest Camel ?
Cheers, Sergey
On 10/10/13 19:28, Amit wrote:
> I am sending request to below route with "Content-Type: audio/amr" but i am
> unable to access Content-Type in myService.
>
>
>
> <route xmlns="http://camel.apache.org/schema/spring" trace="true">
> <from uri="servlet:///myServlet?matchOnUriPrefix=true" />
> <to uri="cxfbean:myService" />
> </route>
>
> Service with method
> @POST
> @Path("/{package}/{service}")
> public Response processRequest(@Context UriInfo uriInfo,
> @Context HttpServletRequest request,
> @Context HttpHeaders headers)
>
> {
> MediaType mimeType = headers.getMediaType();
>
>
>
>
>
>
> }
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CFX-Bean-headers-access-Issue-tp5741312.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>