Java Code Examples for javax.xml.ws.Binding#setHandlerChain()

The following examples show how to use javax.xml.ws.Binding#setHandlerChain() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JaxWSCxfHookIT.java    From uavstack with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
public <T> T create(T t,ClientFactoryBean clientFactoryBean) { 
    
    Binding binding = ((BindingProvider) t).getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();
    handlerChain.add(this.handler);
    binding.setHandlerChain(handlerChain);
    
    String wsdlLocation = clientFactoryBean.getAddress();
    
    T tProxy = JDKProxyInvokeUtil.newProxyInstance(clientFactoryBean.getServiceClass().getClassLoader(),
            new Class[] { clientFactoryBean.getServiceClass() },
            new JDKProxyInvokeHandler<T>(t, new ClientStubProcessor(wsdlLocation.toString(), this.handler)));
    return tProxy;
}
 
Example 2
Source File: JaxWSHookIT.java    From uavstack with Apache License 2.0 5 votes vote down vote up
/**
 * this is for Client Stub Programming
 * 
 * @param t
 * @param s
 * @param args
 * @return
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public <T> T getPort(T t, Service s, Object[] args) {
    
    if (JDKProxyInvokeUtil.isJDKProxy(t)) {
        return t;
    }

    Class<T> clz = null;
    if (Class.class.isAssignableFrom(args[0].getClass())) {
        clz = (Class<T>) args[0];
    }
    else if (Class.class.isAssignableFrom(args[1].getClass())) {
        clz = (Class<T>) args[1];
    }

    if (clz == null) {
        return t;
    }

    Binding binding = ((BindingProvider) t).getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();
    handlerChain.add(this.handler);
    binding.setHandlerChain(handlerChain);

    final String wsdlLocation = getServiceURL(s);

    T tProxy = JDKProxyInvokeUtil.newProxyInstance(clz.getClassLoader(), new Class[] { clz },
            new JDKProxyInvokeHandler<T>(t, new ClientStubProcessor(wsdlLocation.toString(), this.handler)));
    return tProxy;
}
 
Example 3
Source File: JaxWSHookIT.java    From uavstack with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
public Dispatch createDispatch(Dispatch d, Service s, Object[] args) {

    Binding binding = ((BindingProvider) d).getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();
    handlerChain.add(this.handler);
    binding.setHandlerChain(handlerChain);

    final String wsdlLocation = getServiceURL(s);

    Dispatch tProxy = JDKProxyInvokeUtil.newProxyInstance(this.getClass().getClassLoader(),
            new Class[] { Dispatch.class },
            new JDKProxyInvokeHandler<Dispatch>(d, new DispatchProcessor(wsdlLocation.toString(), this.handler)));
    return tProxy;
}
 
Example 4
Source File: AbstractUDDIClientTestCase.java    From juddi with Apache License 2.0 5 votes vote down vote up
protected void registerService(BindingProvider bindingProvider)
{
    Binding binding = bindingProvider.getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();

    handlerChain.add(new LoggingHandler());

    // set the handler chain again for the changes to take effect
    binding.setHandlerChain(handlerChain);
}
 
Example 5
Source File: JUDDIServiceProvider.java    From juddi with Apache License 2.0 5 votes vote down vote up
private void registerService(BindingProvider bindingProvider) {
	Binding binding = bindingProvider.getBinding();
	List<Handler> handlerChain = binding.getHandlerChain();

	handlerChain.add(new LoggingHandler());

	// set the handler chain again for the changes to take effect
	binding.setHandlerChain(handlerChain);
}
 
Example 6
Source File: WSSecurityClientTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testTimestampSignEncrypt() throws Exception {
    Bus b = new SpringBusFactory()
        .createBus("org/apache/cxf/systest/ws/security/client.xml");
    BusFactory.setDefaultBus(b);
    final javax.xml.ws.Service svc = javax.xml.ws.Service.create(
        WSDL_LOC,
        GREETER_SERVICE_QNAME
    );
    final Greeter greeter = svc.getPort(
        TIMESTAMP_SIGN_ENCRYPT_PORT_QNAME,
        Greeter.class
    );
    updateAddressPort(greeter, test.getPort());

    // Add a No-Op JAX-WS SoapHandler to the dispatch chain to
    // verify that the SoapHandlerInterceptor can peacefully co-exist
    // with the explicitly configured SAAJOutInterceptor
    //
    @SuppressWarnings("rawtypes")
    List<Handler> handlerChain = new ArrayList<>();
    Binding binding = ((BindingProvider)greeter).getBinding();
    TestOutHandler handler = new TestOutHandler();
    handlerChain.add(handler);
    binding.setHandlerChain(handlerChain);

    greeter.sayHi();

    assertTrue("expected Handler.handleMessage() to be called",
               handler.handleMessageCalledOutbound);
    assertFalse("expected Handler.handleFault() not to be called",
                handler.handleFaultCalledOutbound);
    ((java.io.Closeable)greeter).close();
    b.shutdown(true);
    BusFactory.setDefaultBus(getStaticBus());
}