Search in sources :

Example 46 with Handler

use of javax.xml.ws.handler.Handler in project cxf by apache.

the class SecondClient method newInstance.

public static SecondServiceAT newInstance() throws Exception {
    URL wsdlLocation = new URL("http://localhost:8082/Service/SecondServiceAT?wsdl");
    QName serviceName = new QName("http://service.ws.sample", "SecondServiceATService");
    QName portName = new QName("http://service.ws.sample", "SecondServiceAT");
    Service service = Service.create(wsdlLocation, serviceName);
    SecondServiceAT client = service.getPort(portName, SecondServiceAT.class);
    List<Handler> handlerChain = new ArrayList<>();
    JaxWSTxOutboundBridgeHandler txOutboundBridgeHandler = new JaxWSTxOutboundBridgeHandler();
    EnabledWSTXHandler wstxHandler = new EnabledWSTXHandler();
    handlerChain.add(txOutboundBridgeHandler);
    handlerChain.add(wstxHandler);
    ((BindingProvider) client).getBinding().setHandlerChain(handlerChain);
    return client;
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Service(javax.xml.ws.Service) Handler(javax.xml.ws.handler.Handler) EnabledWSTXHandler(com.arjuna.mw.wst11.client.EnabledWSTXHandler) JaxWSTxOutboundBridgeHandler(org.jboss.jbossts.txbridge.outbound.JaxWSTxOutboundBridgeHandler) JaxWSTxOutboundBridgeHandler(org.jboss.jbossts.txbridge.outbound.JaxWSTxOutboundBridgeHandler) EnabledWSTXHandler(com.arjuna.mw.wst11.client.EnabledWSTXHandler) URL(java.net.URL)

Example 47 with Handler

use of javax.xml.ws.handler.Handler in project cxf by apache.

the class HandlerInvocationUsingAddNumbersTest method testHandlerPostConstruct.

@Test
public void testHandlerPostConstruct() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
    AddNumbersServiceWithAnnotation service = new AddNumbersServiceWithAnnotation(wsdl, serviceName);
    AddNumbers port = service.getPort(portName, AddNumbers.class);
    setAddress(port, addNumbersAddress);
    @SuppressWarnings("rawtypes") List<Handler> handlerChain = ((BindingProvider) port).getBinding().getHandlerChain();
    SmallNumberHandler h = (SmallNumberHandler) handlerChain.get(0);
    assertTrue(h.isPostConstructInvoked());
}
Also used : AddNumbers(org.apache.handlers.AddNumbers) Handler(javax.xml.ws.handler.Handler) URL(java.net.URL) Test(org.junit.Test)

Example 48 with Handler

use of javax.xml.ws.handler.Handler in project cxf by apache.

the class HandlerInvocationTest method testAddingUnusedHandlersThroughConfigFile.

@Test
public void testAddingUnusedHandlersThroughConfigFile() {
    HandlerTestServiceWithAnnotation service1 = new HandlerTestServiceWithAnnotation(wsdl, serviceName);
    HandlerTest handlerTest1 = service1.getPort(portName, HandlerTest.class);
    BindingProvider bp1 = (BindingProvider) handlerTest1;
    Binding binding1 = bp1.getBinding();
    @SuppressWarnings("rawtypes") List<Handler> port1HandlerChain = binding1.getHandlerChain();
    assertEquals(1, port1HandlerChain.size());
}
Also used : HandlerTest(org.apache.handler_test.HandlerTest) Binding(javax.xml.ws.Binding) Handler(javax.xml.ws.handler.Handler) BindingProvider(javax.xml.ws.BindingProvider) HandlerTest(org.apache.handler_test.HandlerTest) Test(org.junit.Test)

Example 49 with Handler

use of javax.xml.ws.handler.Handler in project cxf by apache.

the class WSSecurityClientTest method testTimestampSignEncrypt.

@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());
}
Also used : Binding(javax.xml.ws.Binding) SOAPBinding(javax.xml.ws.soap.SOAPBinding) HTTPBinding(javax.xml.ws.http.HTTPBinding) Bus(org.apache.cxf.Bus) ArrayList(java.util.ArrayList) Handler(javax.xml.ws.handler.Handler) Service(javax.xml.ws.Service) BindingProvider(javax.xml.ws.BindingProvider) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Greeter(org.apache.hello_world_soap_http.Greeter) Test(org.junit.Test)

Example 50 with Handler

use of javax.xml.ws.handler.Handler in project uavstack by uavorg.

the class JaxWSHookIT method createDispatch.

@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;
}
Also used : Binding(javax.xml.ws.Binding) SOAPHandler(javax.xml.ws.handler.soap.SOAPHandler) Handler(javax.xml.ws.handler.Handler) JDKProxyInvokeHandler(com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler) Dispatch(javax.xml.ws.Dispatch) BindingProvider(javax.xml.ws.BindingProvider)

Aggregations

Handler (javax.xml.ws.handler.Handler)100 QName (javax.xml.namespace.QName)47 ArrayList (java.util.ArrayList)46 BindingProvider (javax.xml.ws.BindingProvider)36 URL (java.net.URL)32 Service (javax.xml.ws.Service)29 Test (org.junit.Test)29 LogicalHandler (javax.xml.ws.handler.LogicalHandler)24 Binding (javax.xml.ws.Binding)11 WebServiceException (javax.xml.ws.WebServiceException)11 MessageContext (javax.xml.ws.handler.MessageContext)9 SOAPHandler (javax.xml.ws.handler.soap.SOAPHandler)9 Exchange (org.apache.cxf.message.Exchange)9 IOException (java.io.IOException)8 SOAPMessageContext (javax.xml.ws.handler.soap.SOAPMessageContext)7 HandlerChainInvoker (org.apache.cxf.jaxws.handler.HandlerChainInvoker)7 DataHandler (javax.activation.DataHandler)6 InitialContext (javax.naming.InitialContext)6 Source (javax.xml.transform.Source)6 DOMSource (javax.xml.transform.dom.DOMSource)6