cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From olanga henry <olo...@hotmail.com>
Subject client interceptor to send parameters with headers
Date Wed, 23 Apr 2008 14:56:16 GMT
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
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message