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);
}
}
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());
}
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);
}
};
}
Aggregations