The phase change does not seem to matter and yes, as Dan suggested
LoggingInInterceptor does show empty header:
Apr 23, 2008 1:14:42 PM org.apache.cxf.interceptor.LoggingInInterceptor
loggingINFO: Inbound Message----------------------------Encoding: UTF-8Headers:
{connection=[keep-alive], host=[dev1.aixtest.com], user-agent=[Java/1.5.0_10],
SOAPAction=[""], transfer-encoding=[chunked], pragma=[no-cache],
content-type=[text/xml; charset=UTF-8], accept=[*],
Cache-Control=[no-cache]}Messages: Message:
Payload: <soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:sayHi
xmlns:ns1="http://spring.demo/"><arg0>test</arg0></ns1:sayHi></soap:Body></soap:Envelope>--------------------------------------
> Date: Wed, 23 Apr 2008 18:58:13 +0100> From: [EMAIL PROTECTED]> To:
> [email protected]> Subject: Re: client interceptor to send
> parameters with headers> > Just saw Dan's mail and his suggestion to move the
> interceptor to > Phase.USER_LOGICAL is much cleaner than mine.> > Regards,> >
> Ulhas Bhole> > Ulhas Bhole wrote:> > Hello Henry,> >> > Sorry I forgot about
> the Header object creation. you are tying to add > > the interceptor in
> Phase.WRITE and for some reason it looks like it is > > getting called after
> the SoapOutInterceptor which does the header > > processing.> >> > Try adding
> the following line to the constructor after super() :> >
> addBefore(SoapOutInterceptor.class.getName());> >> > This will make sure that
> the interceptor is called before the headers > > are being processed.> >> >
> Regards,> >> > Ulhas Bhole> >> > olanga henry wrote:> >> Dan: I am afraid
> that I am still not seeing any headers on the server > >> side even after I
> tried sending the Header the way you suggested.> >> > >> I am using the
> following interceptor (as I found from the discussion > >> threads) in the
> server side applied to JAX-WS HelloWorld service:> >> > >> public class
> MySoapInterceptor extends AbstractSoapInterceptor {> >> > >> public
> MySoapInterceptor() { super(Phase.UNMARSHAL); }> >> > >> public void
> handleMessage(SoapMessage msg) throws SoapFault {> >>
> System.out.println("Interceptor " + this.getPhase());> >> List<Header> lista
> = msg.getHeaders(); for (Header h : lista) > >> { Element el = (Element)
> h.getObject(); > >> System.out.println("Header XML :"); > >>
> XMLUtils.printDOM(el); Node node = > >> DOMUtils.getChild(el, null);
> printNode(node);> >> while ( ((node = DOMUtils.getNext(node, null, > >>
> node.getNodeType()) ) != null) ) { printNode(node); } }> >> }> >> > >> public
> void printNode(Node node) { System.out.println("Node : > >> ");
> System.out.println(node.getNodeName()); > >> System.out.println("Node value :
> "); > >> System.out.println(DOMUtils.getContent(node)); }> >> }> >> > >> > >>
> and here is my service config:> >> > >> > >> <bean id="hello"
> class="demo.spring.HelloWorldImpl" /> > >> <jaxws:endpoint id="helloWorld" >
> >> implementor="#hello" address="/services/HelloWorld" > >> >
> <jaxws:inInterceptors> <ref > >> bean="myInterceptor" /> > >>
> </jaxws:inInterceptors> </jaxws:endpoint>Thank you.> >>> >>> >>> >> > >>>
> From: [EMAIL PROTECTED]> To: [email protected]> Subject: > >>>
> Re: client interceptor to send parameters with headers> Date: Wed, > >>> 23
> Apr 2008 13:00:24 -0400> CC: [EMAIL PROTECTED]> > On Wednesday 23 > >>> April
> 2008, sudip shrestha wrote:> > Ulhas:> >> > *In the method: > >>> public
> java.util.List<Header> > > >>>
> <http://incubator.apache.org/cxf/javadoc/latest/org/apache/cxf/headers> > >>>
> >/Header.html>> **getHeaders()> >> > **as the list has the type of > >>>
> Header, the add method does not accept> > org.w3c.dom.Element as the > >>>
> parameter.> > Just do "new Header(> new QName(el.getNamespaceURI(),> > >>>
> el.getLocalName()),> el)"> > That should be it.> > Dan> > > > > >> > > >>>
> Thanks> > *> >> > On Wed, Apr 23, 2008 at 10:53 AM, Ulhas Bhole > >>> <[EMAIL
> PROTECTED]> > wrote:> > > Hi Olanga,> > >> > > try > >>> skipping the
> SoapHeader creation and add the DOM element> > > > >>> directly into the
> Header list like msg.getHeaders().add(param1).> > > >>> >> > > -- Ulhas
> Bhole> > >> > > olanga henry wrote:> > > > Hi all, > >>> this was so easy in
> XFire with the handlers. I am a bit> > > > > >>> struggling due to lack of
> clear examples. I am trying to write a> > > >>> > > simple interceptor on the
> client side (am not clear on which> > > >>> > > abstractInterceptor to extend
> out of several available in cxf, > >>> so> > > > in this example I just
> extended AbstractSoapInterceptor) > >>> so that I> > > > can send some
> parameters in the soap headers. Here > >>> is what I> > > > did:public class
> AddHeaderInterceptor extends> > > > >>> > AbstractSoapInterceptor { public
> AddHeaderInterceptor() {> > > > > >>> super(Phase.WRITE); } public void
> handleMessage(SoapMessage msg)> > > >>> > > throws SoapFault { Document d =
> DOMUtils.createDocument(); > > > > >>> > Element param1 =
> d.createElement("my_param1"); > > > > > >>> param1.setTextContent("my
> param1"); SoapHeader sh_param1 = new> > > > >>> > SoapHeader(new
> QName("http://spring.demo", "HelloWorldImplPort"),> > >>> > > > param1);
> msg.getHeaders().add( sh_param1 ); }}Then I attached> > >>> > > > the
> interceptor to the factory in the actual client code:> > > > >>> >
> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();> > > > >>> >
> factory.setServiceClass( HelloWorld.class ); factory.setAddress(> > >>> > > >
> "http://wsdev.adestagroup.com/services/HelloWorld" ); > > > > > >>>
> factory.getOutInterceptors().add(new> > > > AddHeaderInterceptor()); > >>>
> //<<-------------------> > > > HelloWorld client = (HelloWorld) > >>>
> factory.create();> > > > System.out.println( client.sayHi("test") > >>> );But
> I can't seem> > > > to intercept the headers at the server > >>> side. What
> am I doing> > > > wrong here?Highly appreciate any help. > >>> Thanks> > > >
> > >>> _________________________________________________________________> > >
> >>> > > Make i'm yours. Create a custom banner to support your cause.> > >
> >>> > >> > > > > >>>
> http://im.live.com/Messenger/IM/Contribute/Default.aspx?source=TXT> > >>> > >
> >_TAGHM_MSN_Make_IM_Yours> > >> > > > >>> ----------------------------> > >
> IONA Technologies PLC (registered > >>> in Ireland)> > > Registered Number:
> 171387> > > Registered Address: > >>> The IONA Building, Shelbourne Road,
> Dublin 4,> > > Ireland> > > > -- > >>> > J. Daniel Kulp> Principal Engineer,
> IONA> [EMAIL PROTECTED]> > >>> http://www.dankulp.com/blog> >>> > >>
> _________________________________________________________________> >> Spell a
> grand slam in this game where word skill meets World Series. > >> Get in the
> game.> >>
> http://club.live.com/word_slugger.aspx?icid=word_slugger_wlhm_admod_april08 >
> >>> >> > >> >> > ----------------------------> > IONA Technologies PLC
> (registered in Ireland)> > Registered Number: 171387> > Registered Address:
> The IONA Building, Shelbourne Road, Dublin 4, Ireland> >> >
> ----------------------------> IONA Technologies PLC (registered in Ireland)>
> Registered Number: 171387> Registered Address: The IONA Building, Shelbourne
> Road, Dublin 4, Ireland
_________________________________________________________________
Make i'm yours. Create a custom banner to support your cause.
http://im.live.com/Messenger/IM/Contribute/Default.aspx?source=TXT_TAGHM_MSN_Make_IM_Yours