factory.setTransportId(LocalTransportFactory.TRANSPORT_ID);
Server server = factory.create();
Service service = server.getEndpoint().getService();
service.getInInterceptors().add(new SAAJInInterceptor());
service.getOutInterceptors().add(new SAAJOutInterceptor());
wsIn = new WSS4JInInterceptor();
wsIn.setProperty(WSHandlerConstants.SIG_PROP_FILE, "META-INF/cxf/insecurity.properties");
wsIn.setProperty(WSHandlerConstants.DEC_PROP_FILE, "META-INF/cxf/insecurity.properties");
wsIn.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName());
service.getInInterceptors().add(wsIn);
wsOut = new WSS4JOutInterceptor();
wsOut.setProperty(WSHandlerConstants.SIG_PROP_FILE, "META-INF/cxf/outsecurity.properties");
wsOut.setProperty(WSHandlerConstants.ENC_PROP_FILE, "META-INF/cxf/outsecurity.properties");
wsOut.setProperty(WSHandlerConstants.USER, "myalias");
wsOut.setProperty("password", "myAliasPassword");
wsOut.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName());
service.getOutInterceptors().add(wsOut);
// Create the client
JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
proxyFac.setServiceClass(Echo.class);
proxyFac.setAddress("local://Echo");
proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID);
echo = (Echo)proxyFac.create();
client = ClientProxy.getClient(echo);
client.getInInterceptors().add(wsIn);
client.getInInterceptors().add(new SAAJInInterceptor());
client.getOutInterceptors().add(wsOut);
client.getOutInterceptors().add(new SAAJOutInterceptor());
}