Search in sources :

Example 1 with JaxWsClientFactoryBean

use of org.apache.cxf.jaxws.JaxWsClientFactoryBean 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 2 with JaxWsClientFactoryBean

use of org.apache.cxf.jaxws.JaxWsClientFactoryBean in project cxf by apache.

the class BeanPostProcessorTest method verifyServices.

@Test
public void verifyServices() throws Exception {
    JaxWsClientFactoryBean cf = new JaxWsClientFactoryBean();
    cf.setAddress("local://services/Alger");
    cf.setServiceClass(IWebServiceRUs.class);
    Client client = cf.create();
    String response = (String) client.invoke("consultTheOracle")[0];
    assertEquals("All your bases belong to us.", response);
    Service service = WebServiceRUs.getService();
    assertEquals(JAXBDataBinding.class, service.getDataBinding().getClass());
}
Also used : JaxWsClientFactoryBean(org.apache.cxf.jaxws.JaxWsClientFactoryBean) Service(org.apache.cxf.service.Service) Client(org.apache.cxf.endpoint.Client) AbstractCXFSpringTest(org.apache.cxf.test.AbstractCXFSpringTest) Test(org.junit.Test)

Example 3 with JaxWsClientFactoryBean

use of org.apache.cxf.jaxws.JaxWsClientFactoryBean in project teiid by teiid.

the class WSManagedConnectionFactory method createConnectionFactory.

@SuppressWarnings("serial")
@Override
public BasicConnectionFactory<WSConnectionImpl> createConnectionFactory() throws ResourceException {
    if (this.endPointName == null) {
        this.endPointName = WSManagedConnectionFactory.DEFAULT_LOCAL_NAME;
    }
    if (this.serviceName == null) {
        this.serviceName = WSManagedConnectionFactory.DEFAULT_LOCAL_NAME;
    }
    if (this.namespaceUri == null) {
        this.namespaceUri = WSManagedConnectionFactory.DEFAULT_NAMESPACE_URI;
    }
    this.portQName = new QName(this.namespaceUri, this.endPointName);
    this.serviceQName = new QName(this.namespaceUri, this.serviceName);
    if (this.wsdl != null) {
        try {
            this.wsdlUrl = new URL(this.wsdl);
        } catch (MalformedURLException e) {
            File f = new File(this.wsdl);
            try {
                this.wsdlUrl = f.toURI().toURL();
            } catch (MalformedURLException e1) {
                throw new InvalidPropertyException(e1);
            }
        }
    }
    if (this.configFile != null) {
        this.bus = new SpringBusFactory().createBus(this.configFile);
        JaxWsClientFactoryBean instance = new JaxWsClientFactoryBean();
        if (this.wsdl == null) {
            Configurer configurer = this.bus.getExtension(Configurer.class);
            if (null != configurer) {
                // $NON-NLS-1$
                configurer.configureBean(this.portQName.toString() + ".jaxws-client.proxyFactory", instance);
            }
            this.outInterceptors = instance.getOutInterceptors();
        }
    }
    return new BasicConnectionFactory<WSConnectionImpl>() {

        @Override
        public WSConnectionImpl getConnection() throws ResourceException {
            return new WSConnectionImpl(WSManagedConnectionFactory.this);
        }
    };
}
Also used : JaxWsClientFactoryBean(org.apache.cxf.jaxws.JaxWsClientFactoryBean) MalformedURLException(java.net.MalformedURLException) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) BasicConnectionFactory(org.teiid.resource.spi.BasicConnectionFactory) QName(javax.xml.namespace.QName) InvalidPropertyException(javax.resource.spi.InvalidPropertyException) Configurer(org.apache.cxf.configuration.Configurer) File(java.io.File) URL(java.net.URL)

Aggregations

JaxWsClientFactoryBean (org.apache.cxf.jaxws.JaxWsClientFactoryBean)3 File (java.io.File)1 Method (java.lang.reflect.Method)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 InvalidPropertyException (javax.resource.spi.InvalidPropertyException)1 QName (javax.xml.namespace.QName)1 Handler (javax.xml.ws.handler.Handler)1 CookieHandler (org.apache.camel.http.common.cookie.CookieHandler)1 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)1 ResourceInjector (org.apache.cxf.common.injection.ResourceInjector)1 ModCountCopyOnWriteArrayList (org.apache.cxf.common.util.ModCountCopyOnWriteArrayList)1 Configurer (org.apache.cxf.configuration.Configurer)1 Client (org.apache.cxf.endpoint.Client)1 WebServiceContextResourceResolver (org.apache.cxf.jaxws.context.WebServiceContextResourceResolver)1 AnnotationHandlerChainBuilder (org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder)1 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)1 DefaultResourceManager (org.apache.cxf.resource.DefaultResourceManager)1 ResourceManager (org.apache.cxf.resource.ResourceManager)1