On Thursday 24 April 2008, olanga henry wrote:
> I found that the Interceptor was not even being called after I put
> some debugging statements inside the Interceptor I wrote. Then I
> found that The org.apache.cxf.endpoint.Client interface has a
> superInterface org.apache.cxf.interceptor.InterceptorProvider which
> has a method getOutInterceptors() so I applied the interceptor to
> client not to JaxWsProxyFactoryBean (which also implements
> InterceptorProvider), then it just worked normally. I think I saw the
> interceptors being applied to the JaxWsProxyFactoryBean instead of the
> client in an example such as in
> http://cwiki.apache.org/CXF20DOC/a-simple-jax-ws-service.html at the
> bottom of the page for the client code. Is this a mistake on the
> documentation or something I am not uderstanding? Dan, would you help
> me out? Thanks
Probably a bug. I'll need to dig into that some more. The interceptors
on the factory should be copied into the Client when it creates the
Client object. Not sure why that wouldn't work.
Obviously adding interceptors to the Factory after the client is created
would have no affect on the Client, but doing so before hand definitely
should.
Can you please log a bug and maybe provide a testcase? Or at least dump
your "non-working" client code into the description.
Thanks!
Dan
>
> ----------------------------------------
>
> > From: [EMAIL PROTECTED]
> > To: [EMAIL PROTECTED]
> > Subject: RE: client interceptor to send parameters with headers
> > Date: Wed, 23 Apr 2008 18:15:05 +0000
> >
> > 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:
> > test--------------------------------------
> >
> >> 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 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:>>>>>>>>> >>> >> implementor="#hello"
> >> address="/services/HelloWorld">>>> >> bean="myInterceptor" />>>>
> >> 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.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>>>> > 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_T
> >AGHM_MSN_Make_IM_Yours
>
> _________________________________________________________________
> Express yourself wherever you are. Mobilize!
> http://www.gowindowslive.com/Mobile/Landing/Messenger/Default.aspx?Loc
>ale=en-US?ocid=TAG_APRIL
--
J. Daniel Kulp
Principal Engineer, IONA
[EMAIL PROTECTED]
http://www.dankulp.com/blog