Search in sources :

Example 6 with Binding

use of javax.xml.ws.Binding 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 7 with Binding

use of javax.xml.ws.Binding in project cxf by apache.

the class JMSTestMtom method startServers.

@BeforeClass
public static void startServers() throws Exception {
    broker = new EmbeddedJMSBrokerLauncher();
    broker.startInProcess();
    bus = BusFactory.getDefaultBus();
    broker.updateWsdl(bus, "testutils/jms_test_mtom.wsdl");
    Object mtom = new JMSMTOMImpl();
    EndpointImpl ep = (EndpointImpl) Endpoint.publish("jms:jndi:dynamicQueues/test.cxf.jmstransport.queue&amp;receiveTimeout=10000", mtom);
    Binding binding = ep.getBinding();
    ((SOAPBinding) binding).setMTOMEnabled(true);
}
Also used : Binding(javax.xml.ws.Binding) SOAPBinding(javax.xml.ws.soap.SOAPBinding) EmbeddedJMSBrokerLauncher(org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher) EndpointImpl(org.apache.cxf.jaxws.EndpointImpl) SOAPBinding(javax.xml.ws.soap.SOAPBinding) BeforeClass(org.junit.BeforeClass)

Example 8 with Binding

use of javax.xml.ws.Binding in project uavstack by uavorg.

the class JaxWSHookIT method getPort.

/**
 * 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;
}
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) BindingProvider(javax.xml.ws.BindingProvider)

Example 9 with Binding

use of javax.xml.ws.Binding in project uavstack by uavorg.

the class JaxWSCxfHookIT method create.

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

Example 10 with Binding

use of javax.xml.ws.Binding in project tomee by apache.

the class EjbInterceptor method intercept.

@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {
    Endpoint endpoint = this.exchange.get(Endpoint.class);
    Service service = endpoint.getService();
    Binding binding = ((JaxWsEndpointImpl) endpoint).getJaxwsBinding();
    this.exchange.put(InvocationContext.class, context);
    if (binding.getHandlerChain() == null || binding.getHandlerChain().isEmpty()) {
        // no handlers so let's just directly invoke the bean
        log.debug("No handlers found.");
        EjbMethodInvoker invoker = (EjbMethodInvoker) service.getInvoker();
        return invoker.directEjbInvoke(this.exchange, this.method, this.params);
    } else {
        // have handlers so have to run handlers now and redo data binding
        // as handlers can change the soap message
        log.debug("Handlers found.");
        Message inMessage = exchange.getInMessage();
        PhaseInterceptorChain chain = new PhaseInterceptorChain(bus.getExtension(PhaseManager.class).getInPhases());
        chain.setFaultObserver(endpoint.getOutFaultObserver());
        /*
             * Since we have to re-do data binding and the XMLStreamReader
             * contents are already consumed by prior data binding step
             * we have to reinitialize the XMLStreamReader from the SOAPMessage
             * created by SAAJInInterceptor.
             */
        if (inMessage instanceof SoapMessage) {
            try {
                reserialize((SoapMessage) inMessage);
            } catch (Exception e) {
                throw new ServerRuntimeException("Failed to reserialize soap message", e);
            }
        } else {
        // TODO: how to handle XML/HTTP binding?
        }
        this.exchange.setOutMessage(null);
        // install default interceptors
        chain.add(new ServiceInvokerInterceptor());
        // chain.add(new OutgoingChainInterceptor()); // it is already in the enclosing chain, if we add it there we are in the tx so we write the message in the tx!
        // See http://cwiki.apache.org/CXF20DOC/interceptors.html
        // install Holder and Wrapper interceptors
        chain.add(new WrapperClassInInterceptor());
        chain.add(new HolderInInterceptor());
        // install interceptors for handler processing
        chain.add(new MustUnderstandInterceptor());
        chain.add(new LogicalHandlerInInterceptor(binding));
        chain.add(new SOAPHandlerInterceptor(binding));
        // install data binding interceptors - todo: check we need it
        copyDataBindingInterceptors(chain, inMessage.getInterceptorChain());
        InterceptorChain oldChain = inMessage.getInterceptorChain();
        inMessage.setInterceptorChain(chain);
        try {
            chain.doIntercept(inMessage);
        } finally {
            inMessage.setInterceptorChain(oldChain);
        }
        // TODO: the result should be deserialized from SOAPMessage
        Object result = getResult();
        return result;
    }
}
Also used : Binding(javax.xml.ws.Binding) PhaseInterceptorChain(org.apache.cxf.phase.PhaseInterceptorChain) Message(org.apache.cxf.message.Message) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) SOAPMessage(javax.xml.soap.SOAPMessage) HolderInInterceptor(org.apache.cxf.jaxws.interceptors.HolderInInterceptor) SOAPHandlerInterceptor(org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor) MustUnderstandInterceptor(org.apache.cxf.binding.soap.interceptor.MustUnderstandInterceptor) Service(org.apache.cxf.service.Service) ServerRuntimeException(org.apache.openejb.server.ServerRuntimeException) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) InterceptorChain(org.apache.cxf.interceptor.InterceptorChain) PhaseInterceptorChain(org.apache.cxf.phase.PhaseInterceptorChain) Endpoint(org.apache.cxf.endpoint.Endpoint) JaxWsEndpointImpl(org.apache.cxf.jaxws.support.JaxWsEndpointImpl) LogicalHandlerInInterceptor(org.apache.cxf.jaxws.handler.logical.LogicalHandlerInInterceptor) ServiceInvokerInterceptor(org.apache.cxf.interceptor.ServiceInvokerInterceptor) ServerRuntimeException(org.apache.openejb.server.ServerRuntimeException) WrapperClassInInterceptor(org.apache.cxf.jaxws.interceptors.WrapperClassInInterceptor) AroundInvoke(javax.interceptor.AroundInvoke)

Aggregations

Binding (javax.xml.ws.Binding)19 Handler (javax.xml.ws.handler.Handler)12 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)8 BindingProvider (javax.xml.ws.BindingProvider)8 QName (javax.xml.namespace.QName)7 SOAPHandler (javax.xml.ws.handler.soap.SOAPHandler)7 Set (java.util.Set)6 MessageContext (javax.xml.ws.handler.MessageContext)6 SOAPBinding (javax.xml.ws.soap.SOAPBinding)6 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)6 Exchange (org.apache.cxf.message.Exchange)6 HashSet (java.util.HashSet)5 SOAPMessage (javax.xml.soap.SOAPMessage)5 SOAPMessageContext (javax.xml.ws.handler.soap.SOAPMessageContext)5 HandlerChainInvoker (org.apache.cxf.jaxws.handler.HandlerChainInvoker)5 MessageImpl (org.apache.cxf.message.MessageImpl)5 IMocksControl (org.easymock.IMocksControl)5 IOException (java.io.IOException)4 SOAPBodyElement (javax.xml.soap.SOAPBodyElement)4