Search in sources :

Example 1 with Handler

use of javax.xml.ws.handler.Handler in project nhin-d by DirectProject.

the class DirectSOAPHandlerResolverTest method testGetHandlerChain.

/**
     * Test the getHandlerChain method.
     */
public void testGetHandlerChain() {
    PortInfo portInfo = null;
    List<Handler> output = null;
    DirectSOAPHandlerResolver handler = new DirectSOAPHandlerResolver();
    output = handler.getHandlerChain(portInfo);
    assertNotNull("List is null", output);
    assertTrue("List contains 0 elements", !output.isEmpty());
    assertEquals("List contains more than expected elements", 1, output.size());
    assertTrue("List does not contain expected element", output.get(0) instanceof DirectSOAPHandler);
}
Also used : PortInfo(javax.xml.ws.handler.PortInfo) Handler(javax.xml.ws.handler.Handler)

Example 2 with Handler

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

the class CxfEndpoint method setupHandlers.

protected void setupHandlers(ClientFactoryBean factoryBean, Client client) throws Exception {
    if (factoryBean instanceof JaxWsClientFactoryBean && handlers != null) {
        AnnotationHandlerChainBuilder builder = new AnnotationHandlerChainBuilder();
        Method m = factoryBean.getClass().getMethod("getServiceFactory");
        JaxWsServiceFactoryBean sf = (JaxWsServiceFactoryBean) m.invoke(factoryBean);
        @SuppressWarnings("rawtypes") List<Handler> chain = new ArrayList<Handler>(handlers);
        chain.addAll(builder.buildHandlerChainFromClass(sf.getServiceClass(), sf.getEndpointInfo().getName(), sf.getServiceQName(), factoryBean.getBindingId()));
        if (!chain.isEmpty()) {
            ResourceManager resourceManager = getBus().getExtension(ResourceManager.class);
            List<ResourceResolver> resolvers = resourceManager.getResourceResolvers();
            resourceManager = new DefaultResourceManager(resolvers);
            resourceManager.addResourceResolver(new WebServiceContextResourceResolver());
            ResourceInjector injector = new ResourceInjector(resourceManager);
            for (Handler<?> h : chain) {
                if (Proxy.isProxyClass(h.getClass()) && getServiceClass() != null) {
                    injector.inject(h, getServiceClass());
                    injector.construct(h, getServiceClass());
                } else {
                    injector.inject(h);
                    injector.construct(h);
                }
            }
        }
        ((JaxWsEndpointImpl) client.getEndpoint()).getJaxwsBinding().setHandlerChain(chain);
    }
}
Also used : JaxWsClientFactoryBean(org.apache.cxf.jaxws.JaxWsClientFactoryBean) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) AnnotationHandlerChainBuilder(org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder) ModCountCopyOnWriteArrayList(org.apache.cxf.common.util.ModCountCopyOnWriteArrayList) ArrayList(java.util.ArrayList) CookieHandler(org.apache.camel.http.common.cookie.CookieHandler) Handler(javax.xml.ws.handler.Handler) Method(java.lang.reflect.Method) ResourceManager(org.apache.cxf.resource.ResourceManager) DefaultResourceManager(org.apache.cxf.resource.DefaultResourceManager) ResourceInjector(org.apache.cxf.common.injection.ResourceInjector) DefaultResourceManager(org.apache.cxf.resource.DefaultResourceManager) ResourceResolver(org.apache.cxf.resource.ResourceResolver) WebServiceContextResourceResolver(org.apache.cxf.jaxws.context.WebServiceContextResourceResolver) WebServiceContextResourceResolver(org.apache.cxf.jaxws.context.WebServiceContextResourceResolver)

Example 3 with Handler

use of javax.xml.ws.handler.Handler 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) {
    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 4 with Handler

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

the class AnnotationHandlerChainBuilderTest method testFindHandlerChainAnnotationPerPortServiceBindingNegative.

@Test
public void testFindHandlerChainAnnotationPerPortServiceBindingNegative() {
    HandlerTestImpl handlerTestImpl = new HandlerTestImpl();
    AnnotationHandlerChainBuilder chainBuilder = new AnnotationHandlerChainBuilder();
    QName portQName = new QName("namespacedoesntsupportyet", "SoapPortUnknown");
    QName serviceQName = new QName("namespacedoesntsupportyet", "SoapServiceUnknown");
    String bindingID = "BindingUnknow";
    @SuppressWarnings("rawtypes") List<Handler> handlers = chainBuilder.buildHandlerChainFromClass(handlerTestImpl.getClass(), portQName, serviceQName, bindingID);
    assertNotNull(handlers);
    assertEquals(3, handlers.size());
}
Also used : QName(javax.xml.namespace.QName) Handler(javax.xml.ws.handler.Handler) LogicalHandler(javax.xml.ws.handler.LogicalHandler) Test(org.junit.Test)

Example 5 with Handler

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

the class AnnotationHandlerChainBuilderTest method testFindHandlerChainAnnotationPerPortServiceBindingWildcard.

@Test
public void testFindHandlerChainAnnotationPerPortServiceBindingWildcard() {
    HandlerTestImpl handlerTestImpl = new HandlerTestImpl();
    AnnotationHandlerChainBuilder chainBuilder = new AnnotationHandlerChainBuilder();
    QName portQName = new QName("http://apache.org/handler_test", "SoapPortWildcard");
    QName serviceQName = new QName("http://apache.org/handler_test", "SoapServiceWildcard");
    String bindingID = "BindingUnknow";
    @SuppressWarnings("rawtypes") List<Handler> handlers = chainBuilder.buildHandlerChainFromClass(handlerTestImpl.getClass(), portQName, serviceQName, bindingID);
    assertNotNull(handlers);
    assertEquals(7, handlers.size());
}
Also used : QName(javax.xml.namespace.QName) Handler(javax.xml.ws.handler.Handler) LogicalHandler(javax.xml.ws.handler.LogicalHandler) Test(org.junit.Test)

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