Hi Trivedi,
After chatting with Willem a bit, I realized that the
InsertResponseOutHeaderProcessor should have been getting the "in"
message as opposed to the "out" message from the exchange since the
processor is in the pipeline.
That is,
CxfMessage message = exchange.getIn().getBody(CxfMessage.class);
I will update the test and just want to be aware of it.
Thanks,
William
On Thu, Sep 3, 2009 at 12:27 AM, William Tam<[email protected]> wrote:
> Hi Trivedi,
>
> You can now find some samples in this test module:
> https://svn.apache.org/repos/asf/camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest.java.
> Its Camel context definition is here :
> https://svn.apache.org/repos/asf/camel/branches/camel-1.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/message_headers_relay.xml
>
> The test of interest is
> testInoutOutOfBandHeaderCXFClientRelayWithHeaderInsertion and the
> route that the test references is:
> <route>
> <from uri="cxf:bean:routerRelayEndpointWithInsertion"/>
> <process ref="InsertRequestOutHeaderProcessor" />
> <to uri="cxf:bean:serviceRelayEndpointWithInsertion"/>
> <process ref="InsertResponseOutHeaderProcessor" />
> </route>
>
> Basically, the test involves a SOAP client invoking the
> routerRelayEndpointWithInsertion (camel-cxf) endpoint. The
> InsertRequestOutHeaderProcessor adds a new SOAP header to the request
> message. The message gets send to a CXF service endpoint
> serviceRelayEndpointWithInsertion. A response is sent back to Camel.
> Finally, the InsertResponseOutHeaderProcessors add a new header to the
> response which the client can verify.
>
> Please note that the InsertResponseOutHeaderProcessor requires bug fix
> for (https://issues.apache.org/activemq/browse/CAMEL-1983). I have
> submitted a fix the 1.x branch. InsertRequestOutHeaderProcessor does
> not require any fixes.
>
> Cheers,
> William
>
>
> On Wed, Sep 2, 2009 at 9:10 AM, William Tam<[email protected]> wrote:
>> Sorry, i've been quite busy. I'll get to it today.
>>
>> On Wed, Sep 2, 2009 at 3:12 AM, trivedi kumar b<[email protected]>
>> wrote:
>>>
>>> Hi,
>>>
>>> Did you get a chance to look into this?
>>>
>>> Thanks,
>>> Trivedi
>>>
>>>
>>> William Tam wrote:
>>>>
>>>> Hi Trivedi, I'll try to get that today.
>>>>
>>>> On Fri, Aug 28, 2009 at 3:26 PM, trivedi kumar
>>>> b<[email protected]> wrote:
>>>>>
>>>>> Hi William,
>>>>>
>>>>> I am using Camel 1.x, can you provide me a sample how to set headers in
>>>>> Exchange for POJO based CXF webservices?
>>>>>
>>>>> Thanks,
>>>>> Trivedi
>>>>>
>>>>> William Tam wrote:
>>>>>>
>>>>>> Try it with 2.0 if it is possible. Just set the Header.list in the
>>>>>> Camel out headers. If the headers that you are trying to set are
>>>>>> defined in WSDL, you may not be able to set them with as the
>>>>>> Header.list header since (I think) out parameters (Java objects) could
>>>>>> be marshaled into SOAP headers. If you are dealing with SOAP headers,
>>>>>> another option is PAYLOAD mode. It is a bit easier to work with SOAP
>>>>>> headers.
>>>>>> (see the section "How to deal with the message for a camel-cxf
>>>>>> endpoint in PAYLOAD data format" in
>>>>>> http://cwiki.apache.org/confluence/display/CAMEL/CXF). In 2.0, the
>>>>>> body of camel message is a CxfPayload<SoapHeader> object. You can
>>>>>> call CxfPayload.getHeaders() to get a List<Element> of SOAP headers.
>>>>>> To set you response, you just set your CxfPayload object in out body
>>>>>> of the exchange.
>>>>>>
>>>>>> On Thu, Aug 27, 2009 at 12:06 AM, William Tam<[email protected]>
>>>>>> wrote:
>>>>>>> What version of Camel are you running? I remember that we had some
>>>>>>> issue with SOAP headers getting dropped in older release.
>>>>>>> https://issues.apache.org/activemq/browse/CAMEL-1474. Also, are the
>>>>>>> headers that you are setting defined in your WSDL?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Wed, Aug 26, 2009 at 5:02 PM, trivedi kumar
>>>>>>> b<[email protected]> wrote:
>>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> Sorry for the late response on this from my side, we could able to get
>>>>>>>> the
>>>>>>>> headers from the exchange but the problem that we are facing was how
>>>>>>>> to
>>>>>>>> set
>>>>>>>> the headers on out message? Any sample code?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Trivedi
>>>>>>>>
>>>>>>>>
>>>>>>>> William Tam wrote:
>>>>>>>>>
>>>>>>>>> Just took a peek at the doc. The PAYLOAD mode doc in that area
>>>>>>>>> needs
>>>>>>>>> improvement, too. I will look into it.
>>>>>>>>>
>>>>>>>>> On Tue, Aug 25, 2009 at 11:01 AM, William Tam<[email protected]>
>>>>>>>>> wrote:
>>>>>>>>>> Will do, Claus. :-) Getting SOAP headers and body have been
>>>>>>>>>> documented for PAYLOAD mode (both 1.x and 2.x). For MESSAGE mode,
>>>>>>>>>> it
>>>>>>>>>> is not applicable as there is no SOAP processing (but we will
>>>>>>>>>> mention
>>>>>>>>>> it). We just have to add doc for POJO mode.
>>>>>>>>>>
>>>>>>>>>> On Tue, Aug 25, 2009 at 10:49 AM, Claus Ibsen<[email protected]>
>>>>>>>>>> wrote:
>>>>>>>>>>> On Tue, Aug 25, 2009 at 4:38 PM, William Tam<[email protected]>
>>>>>>>>>>> wrote:
>>>>>>>>>>>> In 1.x, we don't copy the Headers.list to Camel headers. You can
>>>>>>>>>>>> get
>>>>>>>>>>>> the Headers.list by first getting the CXF Message from Camel
>>>>>>>>>>>> Message.
>>>>>>>>>>>> And then, you can get the header list from CXF message.
>>>>>>>>>>>>
>>>>>>>>>>>> org.apache.camel.Message in = exchange.getIn();
>>>>>>>>>>>> org.apache.camel.component.cxf.CxfMessage body =
>>>>>>>>>>>> (org.apache.camel.component.cxf.CxfMessage)in.getBody();
>>>>>>>>>>>> org.apache.cxf.message.Message cxfMessage = body.getMessage();
>>>>>>>>>>>> List<org.apache.cxf.headers.Header.Header> soapHeaders =
>>>>>>>>>>>> cxfMessage.get(org.apache.cxf.headers.Header.Header.HEADER_LIST);
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> No wonder CXF is hard, when you need all the "ugly" code above.
>>>>>>>>>>>
>>>>>>>>>>> As a lot of people are asking how to get SOAP headers from the 3
>>>>>>>>>>> dataFormats.
>>>>>>>>>>> And as well how to get the body as type X. Or what the default type
>>>>>>>>>>> the body is returned as etc.
>>>>>>>>>>>
>>>>>>>>>>> It would be cool and nice if we added such description and sample
>>>>>>>>>>> on
>>>>>>>>>>> the CXF wiki page.
>>>>>>>>>>>
>>>>>>>>>>> Start with Camel 2.0 and then later if time we can do it for 1.x as
>>>>>>>>>>> well.
>>>>>>>>>>>
>>>>>>>>>>> Camel 2.0
>>>>>>>>>>> ========
>>>>>>>>>>> About body and headers using dataFormat=POJO
>>>>>>>>>>> bla bla
>>>>>>>>>>>
>>>>>>>>>>> About body and headers using dataFormat=MESSAGE
>>>>>>>>>>> bla bla
>>>>>>>>>>>
>>>>>>>>>>> About body and headers using dataFormat=RAW
>>>>>>>>>>> bla bla
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Tue, Aug 25, 2009 at 10:18 AM, William
>>>>>>>>>>>> Tam<[email protected]>
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>> Are you using 2.x? (My reply was assuming you were using 2.x).
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Tue, Aug 25, 2009 at 10:16 AM, William
>>>>>>>>>>>>> Tam<[email protected]>
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>> In POJO mode, the SOAP headers are copied to Camel IN headers as
>>>>>>>>>>>>>> "org.apache.cxf.headers.Headers.list." The header value is a
>>>>>>>>>>>>>> List
>>>>>>>>>>>>>> of
>>>>>>>>>>>>>> CXF Header objects
>>>>>>>>>>>>>> (http://svn.apache.org/repos/asf/cxf/trunk/api/src/main/java/org/apache/cxf/headers/Header.java).
>>>>>>>>>>>>>> That's how you can read request SOAP headers. You can add/edit
>>>>>>>>>>>>>> the
>>>>>>>>>>>>>> Headers.list header of Camel OUT headers to modify the response
>>>>>>>>>>>>>> SOAP
>>>>>>>>>>>>>> headers.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Hope this help.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> - William
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Tue, Aug 25, 2009 at 1:42 AM, Claus
>>>>>>>>>>>>>> Ibsen<[email protected]>
>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>> On Thu, Aug 20, 2009 at 9:14 PM, trivedi kumar
>>>>>>>>>>>>>>> b<[email protected]> wrote:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> I have exposed webservice using cxf and dataformat is "POJO".
>>>>>>>>>>>>>>>> With
>>>>>>>>>>>>>>>> in the
>>>>>>>>>>>>>>>> router, I want to get and set the soap headers in message
>>>>>>>>>>>>>>>> exchange,
>>>>>>>>>>>>>>>> can
>>>>>>>>>>>>>>>> someone help me on this?
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Get the attention of Willem Jiang as he works on CXF.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Thanks,
>>>>>>>>>>>>>>>> Trivedi
>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>>>> http://www.nabble.com/setting-soap-headers-in-camel-cxf-router-tp25068148p25068148.html
>>>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>> Claus Ibsen
>>>>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Open Source Integration: http://fusesource.com
>>>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>>>> Twitter: http://twitter.com/davsclaus
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Claus Ibsen
>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>
>>>>>>>>>>> Open Source Integration: http://fusesource.com
>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>> Twitter: http://twitter.com/davsclaus
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> View this message in context:
>>>>>>>> http://www.nabble.com/setting-soap-headers-in-camel-cxf-router-tp25068148p25157965.html
>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/setting-soap-headers-in-camel-cxf-router-tp25068148p25195593.html
>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/setting-soap-headers-in-camel-cxf-router-tp25068148p25252694.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>