Hi Kavita, We need to understand why you're getting Null ResponseContext.. Adding new header to the Header List in the Message as described will not affect the response SOAP header. You need to obtain the ResponseContext map and set the Header.List in the map in order to change the response header.
What your route looks like? Thanks, William On Tue, Sep 8, 2009 at 8:54 AM, kav m<[email protected]> wrote: > > Hi William, > I do not see any errors etc. in the log. > > As I mentioned, due to the null response context, I am using a slightly > different way to obtain the List of headers from the CxfMessage. Once I get > the list, I'm using the same code as you have posted on the wiki to add a > new header to that list. But still, I am not being able to see headers in > the response. > > CxfMessage cxfMessage = exchange.getIn().getBody(CxfMessage.class) > Message message = cxfMessage.getMessage(); > List<SoapHeader> soapHeaders = (List<SoapHeader>) > message.get(Header.HEADER_LIST); > > // Insert a new header > String xml = "<?xml version=\"1.0\" > encoding=\"utf-8\"?><outofbandHeader " > + "xmlns=\"http://cxf.apache.org/outofband/Header\" > hdrAttribute=\"testHdrAttribute\" " > + "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" > soap:mustUnderstand=\"1\">" > + > "<name>New_testOobHeader</name><value>New_testOobHeaderValue</value></outofbandHeader>"; > > SoapHeader newHeader = new SoapHeader(soapHeaders.get(0).getName(), > DOMUtils.readXml(new > StringReader(xml)).getDocumentElement()); > > // make sure direction is OUT since it is a response message. > newHeader.setDirection(Direction.DIRECTION_OUT); > > //newHeader.setMustUnderstand(false); > > soapHeaders.add(newHeader); > > When I do a debug, I can see the new header's value in the soapHeaders list. > But no headers are being displayed in the SoapUI response message. > > What "extra" I need to do to be able to view the Soap Headers in the SoapUI > response ? > > Thanks, > Kavita > > > > > > > William Tam wrote: >> >> Hi Kavita, >> >> ResponseContext map is a CXF implementation detail. CXF client puts >> information related to a response in that map. The map is eventually >> copied to the CXF response message. >> >> I took another peek at camel-cxf code, I don't expect the response >> context to be null in normal code path. It sounds like some exception >> might have happened or the Camel message is not the right message >> (i.e. it may not be the response message). Do you see any error >> messages in the log or anything suspicious? If the message is not a >> response message, getting the Header.HEADER_LIST from it won't give >> you to right headers obviously. >> >> It is a bid hard for me to see what's going on. If you could provide >> a little test case, I'll be glad to take a look. >> >> Thanks, >> William >> >> >> On Mon, Sep 7, 2009 at 7:21 AM, kav m<[email protected]> wrote: >>> >>> Hi William, >>> >>> Thanks a lot for putting up the test case and also updating the CXF Wiki. >>> I am having a POJO based camel-cxf service endpoint [details same as >>> trivedi >>> has put in this thread] and trying to set soap headers so that those can >>> be >>> displayed in the soapUI client.I was using camel-cxf 1.6.0 but after >>> reading your post, I am using camel-cxf 1.6.2 >>> >>> >>> I followed the code you have written in the wiki but on line no. 2 below >>> , I >>> get a null responseContext: >>> >>> CxfMessage message = exchange.getIn().getBody(CxfMessage.class); //1 >>> Map responseContext = >>> (Map)message.getMessage().get(Client.RESPONSE_CONTEXT); //2 >>> List<SoapHeader> soapHeaders = >>> (List)responseContext.get(Header.HEADER_LIST); //3 >>> >>> Can you tell me what this responseContext Map is and why am I getting it >>> as >>> null ? >>> >>> Since a null responseContext did not allow me to proceed further with the >>> solution, I used the following code to ultimately obtain a List of >>> soapHeaders- >>> >>> CxfMessage cxfMessage = exchange.getIn().getBody(CxfMessage.class) >>> Message message = cxfMessage.getMessage(); >>> List<SoapHeader> soapHeaders = (List<SoapHeader>) >>> message.get(Header.HEADER_LIST); >>> >>> The rest of the code I used is exactly what you have in the wiki. Still I >>> do >>> not see any headers at all in the SoapUI client. [WS-Addressing is set to >>> true in SoapUI] >>> Besides the header I also need to set a POJO in the SoapBody which should >>> be >>> displayed in SoapUI. I am doing that using the following code and it is >>> displaying perfectly fine. >>> >>> exchange.getOut().setBody(subscribeResponse); >>> >>> Please help me to also set the SoapHeaders in the response, so that they >>> are >>> visible in SoapUI along with the body. >>> >>> Thanks for your help. >>> >>> Regards, >>> Kavita >>> >>> >>> >>> >>> >>> >>> >>> William Tam wrote: >>>> >>>> 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> >>>>> >>>>> >>>>> 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 >>>>> >>>>>>>>>> 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 >>>>>>>>> >>>> >>>> >>> >>> -- >>> View this message in context: >>> http://www.nabble.com/setting-soap-headers-in-camel-cxf-router-tp25068148p25328913.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-tp25068148p25345654.html > Sent from the Camel - Users mailing list archive at Nabble.com. > >
