camel-cxf content-type response header

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

camel-cxf content-type response header

Marc Giger
Hi all,

I'm missing the content-type http response header in camel-cxf 1.6
(cxf:bean:localEndpoint?dataFormat=MESSAGE)

HTTP/1.1 200 OK
Content-Length: 4648
Server: Jetty(6.1.10)

or

HTTP/1.1 500 Internal Server Error
Content-Length: 253
Server: Jetty(6.1.10)

What do I have to do to get it back?:-)
I've lost the overview...

Thanks a lot!

Marc

Reply | Threaded
Open this post in threaded view
|

Re: camel-cxf content-type response header

Willem.Jiang
Administrator
Hi,

You can get the content-type and response code with below code example
in Camel 1.x .

 Map context = (Map)exchange.getIn().getHeaders().get("ResponseContext");
        assertNotNull("Expect to get the protocal header ",
context.get("org.apache.cxf.message.Message.PROTOCOL_HEADERS"));
Map protocalHeaders = (Map)
context.context.get("org.apache.cxf.message.Message.PROTOCOL_HEADERS");
String contentType = protocalHeaders.get("content-type");
int responseCode =
context.get("org.apache.cxf.message.Message.RESPONSE_CODE");

In Camel 2.0, you can get the context-type directly from the message header.

Willem

Marc Giger wrote:

> Hi all,
>
> I'm missing the content-type http response header in camel-cxf 1.6
> (cxf:bean:localEndpoint?dataFormat=MESSAGE)
>
> HTTP/1.1 200 OK
> Content-Length: 4648
> Server: Jetty(6.1.10)
>
> or
>
> HTTP/1.1 500 Internal Server Error
> Content-Length: 253
> Server: Jetty(6.1.10)
>
> What do I have to do to get it back?:-)
> I've lost the overview...
>
> Thanks a lot!
>
> Marc
>
>

Reply | Threaded
Open this post in threaded view
|

Re: camel-cxf content-type response header

Marc Giger
Hi Willem,

How to get the headers in a route is not the problem but how
to send specific headers back to the client. I saw there is a
new mechanism in camel 1.6 to filter specific headers. E.g. CxfHeaderFilterStrategy.
How can I apply a customized filter strategy to the spring-declared endpoints?

Thanks

Marc


On Tue, 05 May 2009 11:03:32 +0800
Willem Jiang <[hidden email]> wrote:

> Hi,
>
> You can get the content-type and response code with below code example
> in Camel 1.x .
>
>  Map context = (Map)exchange.getIn().getHeaders().get("ResponseContext");
>         assertNotNull("Expect to get the protocal header ",
> context.get("org.apache.cxf.message.Message.PROTOCOL_HEADERS"));
> Map protocalHeaders = (Map)
> context.context.get("org.apache.cxf.message.Message.PROTOCOL_HEADERS");
> String contentType = protocalHeaders.get("content-type");
> int responseCode =
> context.get("org.apache.cxf.message.Message.RESPONSE_CODE");
>
> In Camel 2.0, you can get the context-type directly from the message header.
>
> Willem
>
> Marc Giger wrote:
> > Hi all,
> >
> > I'm missing the content-type http response header in camel-cxf 1.6
> > (cxf:bean:localEndpoint?dataFormat=MESSAGE)
> >
> > HTTP/1.1 200 OK
> > Content-Length: 4648
> > Server: Jetty(6.1.10)
> >
> > or
> >
> > HTTP/1.1 500 Internal Server Error
> > Content-Length: 253
> > Server: Jetty(6.1.10)
> >
> > What do I have to do to get it back?:-)
> > I've lost the overview...
> >
> > Thanks a lot!
> >
> > Marc
> >
> >


--

itServe AG
Marc Giger
Länggassstrasse 26
3000 Bern 9
Tel.: +41 31 305 16 16
Fax:  +41 31 305 16 17

Direkt +41 31 305 43 27
Email [hidden email]

http://www.itserve.ch
Reply | Threaded
Open this post in threaded view
|

Re: camel-cxf content-type response header

Willem.Jiang
Administrator
Hi Marc,

I'm sorry that I misunderstand your question.

Since we don't use CXFMessage to store CXF message for better support
routing the message between cxf and other endpoints, the original CXF
message context maybe lost between the CXF endpoints.

If you just want to Camel route work as proxy, you can use camel-jetty
component to do that, and you can control the http header and the
content-type by apply your HttpBinding or HeaderFilterStrategy.
The route rule could like this

from("jetty://http://localhost:9001/router").to("http://localhost:9002/helloworld");

You can setup the HttpBinding or HeaderFilterStrategy by adding a
customized JettyComponent in your Spring configuration file.

<bean id="jetty" class="org.apache.camel.component.jetty.JettyComponent">
  <property name="Httpbinding">
  <bean class="YourHTTPBinding"/>  
  </property>
        <property name="HeaderFilterStrategy">
  <bean class="YourHeaderFilterStrategy"/>  
  </property>
  </bean>

Willem


Marc Giger wrote:

> Hi Willem,
>
> How to get the headers in a route is not the problem but how
> to send specific headers back to the client. I saw there is a
> new mechanism in camel 1.6 to filter specific headers. E.g. CxfHeaderFilterStrategy.
> How can I apply a customized filter strategy to the spring-declared endpoints?
>
> Thanks
>
> Marc
>
>
> On Tue, 05 May 2009 11:03:32 +0800
> Willem Jiang <[hidden email]> wrote:
>
>> Hi,
>>
>> You can get the content-type and response code with below code example
>> in Camel 1.x .
>>
>>  Map context = (Map)exchange.getIn().getHeaders().get("ResponseContext");
>>         assertNotNull("Expect to get the protocal header ",
>> context.get("org.apache.cxf.message.Message.PROTOCOL_HEADERS"));
>> Map protocalHeaders = (Map)
>> context.context.get("org.apache.cxf.message.Message.PROTOCOL_HEADERS");
>> String contentType = protocalHeaders.get("content-type");
>> int responseCode =
>> context.get("org.apache.cxf.message.Message.RESPONSE_CODE");
>>
>> In Camel 2.0, you can get the context-type directly from the message header.
>>
>> Willem
>>
>> Marc Giger wrote:
>>> Hi all,
>>>
>>> I'm missing the content-type http response header in camel-cxf 1.6
>>> (cxf:bean:localEndpoint?dataFormat=MESSAGE)
>>>
>>> HTTP/1.1 200 OK
>>> Content-Length: 4648
>>> Server: Jetty(6.1.10)
>>>
>>> or
>>>
>>> HTTP/1.1 500 Internal Server Error
>>> Content-Length: 253
>>> Server: Jetty(6.1.10)
>>>
>>> What do I have to do to get it back?:-)
>>> I've lost the overview...
>>>
>>> Thanks a lot!
>>>
>>> Marc
>>>
>>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: camel-cxf content-type response header

Marc Giger
Hi Willem,

In my case the entry point is a cxfEndpoint. My route looks
like the following:

from("cxf:bean:routerEndpoint?dataFormat=MESSAGE").
                processRef("uniqueIDProcessor").
                processRef("decryptProcessor").
                processRef("idProcessor").
                processRef("messageStoreProcessor").
                processRef("logProcessor").
                choice().
                    when().
                        method("endpointSelector", "matches").
                        to("bean:invokeProcessor").
                    otherwise().
                        to("cxf:bean:localEndpoint?dataFormat=MESSAGE");

I have to return the contentType/contentEncoding from the localEndpoint through
the routerEndpoint back to the client. This worked until camel 1.6

In the method CxfHeaderHelper.propagateCxfToCamel() there is a try to copy
the CONTENT_TYPE but it can't be found because it doesn't exist in the Message-Object
but in the WrappedMessageContext.

I think a solution to my problem would be to write an interceptor for
the routerEndpoint bean and copy the needed headers...
Is there a easier/better solution?

Thanks

Marc



On Tue, 05 May 2009 16:53:06 +0800
Willem Jiang <[hidden email]> wrote:

> Hi Marc,
>
> I'm sorry that I misunderstand your question.
>
> Since we don't use CXFMessage to store CXF message for better support
> routing the message between cxf and other endpoints, the original CXF
> message context maybe lost between the CXF endpoints.
>
> If you just want to Camel route work as proxy, you can use camel-jetty
> component to do that, and you can control the http header and the
> content-type by apply your HttpBinding or HeaderFilterStrategy.
> The route rule could like this
>
> from("jetty://http://localhost:9001/router").to("http://localhost:9002/helloworld");
>
> You can setup the HttpBinding or HeaderFilterStrategy by adding a
> customized JettyComponent in your Spring configuration file.
>
> <bean id="jetty" class="org.apache.camel.component.jetty.JettyComponent">
>   <property name="Httpbinding">
>   <bean class="YourHTTPBinding"/>  
>   </property>
>         <property name="HeaderFilterStrategy">
>   <bean class="YourHeaderFilterStrategy"/>  
>   </property>
>   </bean>
>
> Willem
>
>
> Marc Giger wrote:
> > Hi Willem,
> >
> > How to get the headers in a route is not the problem but how
> > to send specific headers back to the client. I saw there is a
> > new mechanism in camel 1.6 to filter specific headers. E.g. CxfHeaderFilterStrategy.
> > How can I apply a customized filter strategy to the spring-declared endpoints?
> >
> > Thanks
> >
> > Marc
> >
> >
> > On Tue, 05 May 2009 11:03:32 +0800
> > Willem Jiang <[hidden email]> wrote:
> >
> >> Hi,
> >>
> >> You can get the content-type and response code with below code example
> >> in Camel 1.x .
> >>
> >>  Map context = (Map)exchange.getIn().getHeaders().get("ResponseContext");
> >>         assertNotNull("Expect to get the protocal header ",
> >> context.get("org.apache.cxf.message.Message.PROTOCOL_HEADERS"));
> >> Map protocalHeaders = (Map)
> >> context.context.get("org.apache.cxf.message.Message.PROTOCOL_HEADERS");
> >> String contentType = protocalHeaders.get("content-type");
> >> int responseCode =
> >> context.get("org.apache.cxf.message.Message.RESPONSE_CODE");
> >>
> >> In Camel 2.0, you can get the context-type directly from the message header.
> >>
> >> Willem
> >>
> >> Marc Giger wrote:
> >>> Hi all,
> >>>
> >>> I'm missing the content-type http response header in camel-cxf 1.6
> >>> (cxf:bean:localEndpoint?dataFormat=MESSAGE)
> >>>
> >>> HTTP/1.1 200 OK
> >>> Content-Length: 4648
> >>> Server: Jetty(6.1.10)
> >>>
> >>> or
> >>>
> >>> HTTP/1.1 500 Internal Server Error
> >>> Content-Length: 253
> >>> Server: Jetty(6.1.10)
> >>>
> >>> What do I have to do to get it back?:-)
> >>> I've lost the overview...
> >>>
> >>> Thanks a lot!
> >>>
> >>> Marc
> >>>
> >>>
> >
> >


--

itServe AG
Marc Giger
Länggassstrasse 26
3000 Bern 9
Tel.: +41 31 305 16 16
Fax:  +41 31 305 16 17

Direkt +41 31 305 43 27
Email [hidden email]

http://www.itserve.ch
Reply | Threaded
Open this post in threaded view
|

Re: camel-cxf content-type response header

Willem.Jiang
Administrator
Hi Marc,

It maybe a bug of camel-cxf component, I will look it tommorrow.
Please feel free to fill a JIRA[1] for it.

[1] https://issues.apache.org/activemq/browse/CAMEL

Willem

Marc Giger wrote:

> Hi Willem,
>
> In my case the entry point is a cxfEndpoint. My route looks
> like the following:
>
> from("cxf:bean:routerEndpoint?dataFormat=MESSAGE").
>                 processRef("uniqueIDProcessor").
>                 processRef("decryptProcessor").
>                 processRef("idProcessor").
>                 processRef("messageStoreProcessor").
>                 processRef("logProcessor").
>                 choice().
>                     when().
>                         method("endpointSelector", "matches").
>                         to("bean:invokeProcessor").
>                     otherwise().
>                         to("cxf:bean:localEndpoint?dataFormat=MESSAGE");
>
> I have to return the contentType/contentEncoding from the localEndpoint through
> the routerEndpoint back to the client. This worked until camel 1.6
>
> In the method CxfHeaderHelper.propagateCxfToCamel() there is a try to copy
> the CONTENT_TYPE but it can't be found because it doesn't exist in the Message-Object
> but in the WrappedMessageContext.
>
> I think a solution to my problem would be to write an interceptor for
> the routerEndpoint bean and copy the needed headers...
> Is there a easier/better solution?
>
> Thanks
>
> Marc
>
>
>
> On Tue, 05 May 2009 16:53:06 +0800
> Willem Jiang <[hidden email]> wrote:
>
>> Hi Marc,
>>
>> I'm sorry that I misunderstand your question.
>>
>> Since we don't use CXFMessage to store CXF message for better support
>> routing the message between cxf and other endpoints, the original CXF
>> message context maybe lost between the CXF endpoints.
>>
>> If you just want to Camel route work as proxy, you can use camel-jetty
>> component to do that, and you can control the http header and the
>> content-type by apply your HttpBinding or HeaderFilterStrategy.
>> The route rule could like this
>>
>> from("jetty://http://localhost:9001/router").to("http://localhost:9002/helloworld");
>>
>> You can setup the HttpBinding or HeaderFilterStrategy by adding a
>> customized JettyComponent in your Spring configuration file.
>>
>> <bean id="jetty" class="org.apache.camel.component.jetty.JettyComponent">
>>   <property name="Httpbinding">
>>   <bean class="YourHTTPBinding"/>  
>>   </property>
>>         <property name="HeaderFilterStrategy">
>>   <bean class="YourHeaderFilterStrategy"/>  
>>   </property>
>>   </bean>
>>
>> Willem
>>
>>
>> Marc Giger wrote:
>>> Hi Willem,
>>>
>>> How to get the headers in a route is not the problem but how
>>> to send specific headers back to the client. I saw there is a
>>> new mechanism in camel 1.6 to filter specific headers. E.g. CxfHeaderFilterStrategy.
>>> How can I apply a customized filter strategy to the spring-declared endpoints?
>>>
>>> Thanks
>>>
>>> Marc
>>>
>>>
>>> On Tue, 05 May 2009 11:03:32 +0800
>>> Willem Jiang <[hidden email]> wrote:
>>>
>>>> Hi,
>>>>
>>>> You can get the content-type and response code with below code example
>>>> in Camel 1.x .
>>>>
>>>>  Map context = (Map)exchange.getIn().getHeaders().get("ResponseContext");
>>>>         assertNotNull("Expect to get the protocal header ",
>>>> context.get("org.apache.cxf.message.Message.PROTOCOL_HEADERS"));
>>>> Map protocalHeaders = (Map)
>>>> context.context.get("org.apache.cxf.message.Message.PROTOCOL_HEADERS");
>>>> String contentType = protocalHeaders.get("content-type");
>>>> int responseCode =
>>>> context.get("org.apache.cxf.message.Message.RESPONSE_CODE");
>>>>
>>>> In Camel 2.0, you can get the context-type directly from the message header.
>>>>
>>>> Willem
>>>>
>>>> Marc Giger wrote:
>>>>> Hi all,
>>>>>
>>>>> I'm missing the content-type http response header in camel-cxf 1.6
>>>>> (cxf:bean:localEndpoint?dataFormat=MESSAGE)
>>>>>
>>>>> HTTP/1.1 200 OK
>>>>> Content-Length: 4648
>>>>> Server: Jetty(6.1.10)
>>>>>
>>>>> or
>>>>>
>>>>> HTTP/1.1 500 Internal Server Error
>>>>> Content-Length: 253
>>>>> Server: Jetty(6.1.10)
>>>>>
>>>>> What do I have to do to get it back?:-)
>>>>> I've lost the overview...
>>>>>
>>>>> Thanks a lot!
>>>>>
>>>>> Marc
>>>>>
>>>>>
>>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: camel-cxf content-type response header

Willem.Jiang
Administrator
Hi Marc,

After digging the code for a while , I find the camel-cxf of the
camel-1.x branch doesn't copy the protocol headers into the camel
message header, so you can't get the content-type from the camel-cxf
consumer.
Here is the JIRA[1] which traces for this issue.

I will commit the quick fix for it in a min, and hope it can catch on
the train of Camel 1.6.1.

[1]https://issues.apache.org/activemq/browse/CAMEL-1586

Willem


Willem Jiang wrote:
> Hi Marc,
>
> It maybe a bug of camel-cxf component, I will look it tommorrow.
> Please feel free to fill a JIRA[1] for it.
>
> [1] https://issues.apache.org/activemq/browse/CAMEL
>
> Willem
>
Reply | Threaded
Open this post in threaded view
|

Re: camel-cxf content-type response header

Willem.Jiang
Administrator
In reply to this post by Willem.Jiang
Hi Marc,

After digging the code for a while , I find the camel-cxf of the
camel-1.x branch doesn't copy the protocol headers into the camel
message header, so you can't get the content-type from the camel-cxf
consumer.
Here is the JIRA[1] which traces for this issue.

I will commit the quick fix for it in a min, and hope it can catch on
the train of Camel 1.6.1.

[1]https://issues.apache.org/activemq/browse/CAMEL-1586

Willem


Willem Jiang wrote:
> Hi Marc,
>
> It maybe a bug of camel-cxf component, I will look it tommorrow.
> Please feel free to fill a JIRA[1] for it.
>
> [1] https://issues.apache.org/activemq/browse/CAMEL
>
> Willem
>
Reply | Threaded
Open this post in threaded view
|

Re: camel-cxf content-type response header

Marc Giger
Hi Willem,

Thanks for looking into this!

Can I somehow provide my own HeaderFilterStrategy to my setup
(shown in a previous email)?

Thanks

Marc


On Wed, 06 May 2009 12:47:09 +0800
Willem Jiang <[hidden email]> wrote:

> Hi Marc,
>
> After digging the code for a while , I find the camel-cxf of the
> camel-1.x branch doesn't copy the protocol headers into the camel
> message header, so you can't get the content-type from the camel-cxf
> consumer.
> Here is the JIRA[1] which traces for this issue.
>
> I will commit the quick fix for it in a min, and hope it can catch on
> the train of Camel 1.6.1.
>
> [1]https://issues.apache.org/activemq/browse/CAMEL-1586
>
> Willem
>
>
> Willem Jiang wrote:
> > Hi Marc,
> >
> > It maybe a bug of camel-cxf component, I will look it tommorrow.
> > Please feel free to fill a JIRA[1] for it.
> >
> > [1] https://issues.apache.org/activemq/browse/CAMEL
> >
> > Willem
> >

Reply | Threaded
Open this post in threaded view
|

Re: camel-cxf content-type response header

Claus Ibsen-2
On Wed, May 6, 2009 at 9:17 AM, Marc Giger <[hidden email]> wrote:
> Hi Willem,
>
> Thanks for looking into this!
>
> Can I somehow provide my own HeaderFilterStrategy to my setup
> (shown in a previous email)?
Look for a setHeaderFilterStrategy on either the component or the
endpoint itself. This should allow you to use your own version.

>
> Thanks
>
> Marc
>
>
> On Wed, 06 May 2009 12:47:09 +0800
> Willem Jiang <[hidden email]> wrote:
>
>> Hi Marc,
>>
>> After digging the code for a while , I find the camel-cxf of the
>> camel-1.x branch doesn't copy the protocol headers into the camel
>> message header, so you can't get the content-type from the camel-cxf
>> consumer.
>> Here is the JIRA[1] which traces for this issue.
>>
>> I will commit the quick fix for it in a min, and hope it can catch on
>> the train of Camel 1.6.1.
>>
>> [1]https://issues.apache.org/activemq/browse/CAMEL-1586
>>
>> Willem
>>
>>
>> Willem Jiang wrote:
>> > Hi Marc,
>> >
>> > It maybe a bug of camel-cxf component, I will look it tommorrow.
>> > Please feel free to fill a JIRA[1] for it.
>> >
>> > [1] https://issues.apache.org/activemq/browse/CAMEL
>> >
>> > Willem
>> >
>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration
Interview with me:
http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress