You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by olanga henry <ol...@hotmail.com> on 2008/04/23 16:56:16 UTC

client interceptor to send parameters with headers

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

Re: client interceptor to send parameters with headers

Posted by Daniel Kulp <dk...@apache.org>.
Can you add the Logging interceptors to the server side to see if the 
headers are even making it there..

The client side interceptor is probably running too late and thus the 
headers aren't being written.   I think super(Phase.WRITE) is too late.  
Try moving that to Phase.USER_LOGICAL.   

Dan


On Wednesday 23 April 2008, 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: dkulp@apache.org> To: cxf-user@incubator.apache.org> Subject:
> > Re: client interceptor to send parameters with headers> Date: Wed,
> > 23 Apr 2008 13:00:24 -0400> CC: sudipx@gmail.com> > 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/heade
> >rs> >/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 <ul...@iona.com> > 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> dkulp@apache.org>
> > 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_ap
>ril08



-- 
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog

Re: client interceptor to send parameters with headers

Posted by Daniel Kulp <dk...@apache.org>.
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: olonga@hotmail.com
> > To: cxf-user@incubator.apache.org
> > 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: ulhas.bhole@iona.com>
> >> To: cxf-user@incubator.apache.org> 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: dkulp@apache.org> To:
> >> cxf-user@incubator.apache.org> Subject:>>>> Re: client interceptor
> >> to send parameters with headers> Date: Wed,>>>> 23 Apr 2008
> >> 13:00:24 -0400> CC: sudipx@gmail.com>> 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>
> >> dkulp@apache.org>>>>> 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
dkulp@apache.org
http://www.dankulp.com/blog

RE: client interceptor to send parameters with headers

Posted by olanga henry <ol...@hotmail.com>.
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

----------------------------------------
> From: olonga@hotmail.com
> To: cxf-user@incubator.apache.org
> 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: ulhas.bhole@iona.com> To: cxf-user@incubator.apache.org> 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: dkulp@apache.org> To: cxf-user@incubator.apache.org> Subject:>>>> Re: client interceptor to send parameters with headers> Date: Wed,>>>> 23 Apr 2008 13:00:24 -0400> CC: sudipx@gmail.com>> 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> dkulp@apache.org>>>>> 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

_________________________________________________________________
Express yourself wherever you are. Mobilize!
http://www.gowindowslive.com/Mobile/Landing/Messenger/Default.aspx?Locale=en-US?ocid=TAG_APRIL

RE: client interceptor to send parameters with headers

Posted by olanga henry <ol...@hotmail.com>.
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: ulhas.bhole@iona.com> To: cxf-user@incubator.apache.org> 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: dkulp@apache.org> To: cxf-user@incubator.apache.org> Subject: > >>> Re: client interceptor to send parameters with headers> Date: Wed, > >>> 23 Apr 2008 13:00:24 -0400> CC: sudipx@gmail.com> > 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 > >>> <ul...@iona.com> > 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> dkulp@apache.org> > >>> 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

Re: client interceptor to send parameters with headers

Posted by Ulhas Bhole <ul...@iona.com>.
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: dkulp@apache.org> To: cxf-user@incubator.apache.org> Subject: 
>>> Re: client interceptor to send parameters with headers> Date: Wed, 
>>> 23 Apr 2008 13:00:24 -0400> CC: sudipx@gmail.com> > 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 
>>> <ul...@iona.com> > 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> dkulp@apache.org> 
>>> 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

Re: client interceptor to send parameters with headers

Posted by Ulhas Bhole <ul...@iona.com>.
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: dkulp@apache.org> To: cxf-user@incubator.apache.org> Subject: Re: client interceptor to send parameters with headers> Date: Wed, 23 Apr 2008 13:00:24 -0400> CC: sudipx@gmail.com> > 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 <ul...@iona.com> > 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> dkulp@apache.org> 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

RE: client interceptor to send parameters with headers

Posted by olanga henry <ol...@hotmail.com>.
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: dkulp@apache.org> To: cxf-user@incubator.apache.org> Subject: Re: client interceptor to send parameters with headers> Date: Wed, 23 Apr 2008 13:00:24 -0400> CC: sudipx@gmail.com> > 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 <ul...@iona.com> > 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> dkulp@apache.org> 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

Re: client interceptor to send parameters with headers

Posted by Daniel Kulp <dk...@apache.org>.
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 <ul...@iona.com> 
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
dkulp@apache.org
http://www.dankulp.com/blog

RE: client interceptor to send parameters with headers

Posted by olanga henry <ol...@hotmail.com>.
Thanks guys.  This is actually what I got after I tried suggestion from Ulhas.  Please advise me further.

> Date: Wed, 23 Apr 2008 11:42:01 -0500> From: sudipx@gmail.com> To: cxf-user@incubator.apache.org> Subject: Re: client interceptor to send parameters with headers> > 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.> > Thanks> *> > > > On Wed, Apr 23, 2008 at 10:53 AM, Ulhas Bhole <ul...@iona.com> 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> >
_________________________________________________________________
In a rush? Get real-time answers with Windows Live Messenger.
http://www.windowslive.com/messenger/overview.html?ocid=TXT_TAGLM_WL_Refresh_realtime_042008

Re: client interceptor to send parameters with headers

Posted by sudip shrestha <su...@gmail.com>.
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.

Thanks
*



On Wed, Apr 23, 2008 at 10:53 AM, Ulhas Bhole <ul...@iona.com> 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
>

Re: client interceptor to send parameters with headers

Posted by Ulhas Bhole <ul...@iona.com>.
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