use of org.apache.cxf.service.factory.ServiceConstructionException in project cxf by apache.
the class ReflectionServiceFactoryBean method createEndpoints.
protected void createEndpoints() {
Service service = getService();
BindingFactoryManager bfm = getBus().getExtension(BindingFactoryManager.class);
for (ServiceInfo inf : service.getServiceInfos()) {
for (EndpointInfo ei : inf.getEndpoints()) {
for (BindingOperationInfo boi : ei.getBinding().getOperations()) {
updateBindingOperation(boi);
}
try {
bfm.getBindingFactory(ei.getBinding().getBindingId());
} catch (BusException e1) {
continue;
}
try {
Endpoint ep = createEndpoint(ei);
service.getEndpoints().put(ei.getName(), ep);
} catch (EndpointException e) {
throw new ServiceConstructionException(e);
}
}
}
}
use of org.apache.cxf.service.factory.ServiceConstructionException in project cxf by apache.
the class ReflectionServiceFactorBeanTest method testEmptyWsdlAndNoServiceClass.
@Test
public void testEmptyWsdlAndNoServiceClass() throws Exception {
final String dummyWsdl = "target/dummy.wsdl";
ReflectionServiceFactoryBean bean = new ReflectionServiceFactoryBean();
Bus bus = control.createMock(Bus.class);
WSDLManager wsdlmanager = control.createMock(WSDLManager.class);
EasyMock.expect(bus.getExtension(WSDLManager.class)).andReturn(wsdlmanager);
EasyMock.expect(wsdlmanager.getDefinition(dummyWsdl)).andThrow(new WSDLException("PARSER_ERROR", "Problem parsing '" + dummyWsdl + "'."));
EasyMock.expect(bus.getExtension(FactoryBeanListenerManager.class)).andReturn(null);
control.replay();
bean.setWsdlURL(dummyWsdl);
bean.setServiceName(new QName("http://cxf.apache.org/hello_world_soap_http", "GreeterService"));
bean.setBus(bus);
try {
bean.create();
fail("no valid wsdl nor service class specified");
} catch (ServiceConstructionException e) {
// ignore
}
}
use of org.apache.cxf.service.factory.ServiceConstructionException in project cxf by apache.
the class ServerFactoryBean method create.
public Server create() {
ClassLoaderHolder orig = null;
try {
Server server = null;
try {
if (bus != null) {
ClassLoader loader = bus.getExtension(ClassLoader.class);
if (loader != null) {
orig = ClassLoaderUtils.setThreadContextClassloader(loader);
}
}
if (getServiceFactory().getProperties() == null) {
getServiceFactory().setProperties(getProperties());
} else if (getProperties() != null) {
getServiceFactory().getProperties().putAll(getProperties());
}
if (serviceBean != null && getServiceClass() == null) {
setServiceClass(ClassHelper.getRealClass(bus, serviceBean));
}
if (invoker != null) {
getServiceFactory().setInvoker(invoker);
} else if (serviceBean != null) {
invoker = createInvoker();
getServiceFactory().setInvoker(invoker);
}
Endpoint ep = createEndpoint();
getServiceFactory().sendEvent(FactoryBeanListener.Event.PRE_SERVER_CREATE, server, serviceBean, serviceBean == null ? getServiceClass() == null ? getServiceFactory().getServiceClass() : getServiceClass() : getServiceClass() == null ? ClassHelper.getRealClass(getBus(), getServiceBean()) : getServiceClass());
server = new ServerImpl(getBus(), ep, getDestinationFactory(), getBindingFactory());
if (ep.getService().getInvoker() == null) {
if (invoker == null) {
ep.getService().setInvoker(createInvoker());
} else {
ep.getService().setInvoker(invoker);
}
}
} catch (EndpointException | BusException | IOException e) {
throw new ServiceConstructionException(e);
}
if (serviceBean != null) {
Class<?> cls = ClassHelper.getRealClass(getServiceBean());
if (getServiceClass() == null || cls.equals(getServiceClass())) {
initializeAnnotationInterceptors(server.getEndpoint(), cls);
} else {
initializeAnnotationInterceptors(server.getEndpoint(), cls, getServiceClass());
}
} else if (getServiceClass() != null) {
initializeAnnotationInterceptors(server.getEndpoint(), getServiceClass());
}
applyFeatures(server);
getServiceFactory().sendEvent(FactoryBeanListener.Event.SERVER_CREATED, server, serviceBean, serviceBean == null ? getServiceClass() == null ? getServiceFactory().getServiceClass() : getServiceClass() : getServiceClass() == null ? ClassHelper.getRealClass(getServiceBean()) : getServiceClass());
if (start) {
try {
server.start();
} catch (RuntimeException re) {
// prevent resource leak
server.destroy();
throw re;
}
}
getServiceFactory().reset();
return server;
} finally {
if (orig != null) {
orig.reset();
}
}
}
use of org.apache.cxf.service.factory.ServiceConstructionException in project cxf by apache.
the class ClientFactoryBean method create.
public Client create() {
getServiceFactory().reset();
if (getServiceFactory().getProperties() == null) {
getServiceFactory().setProperties(properties);
} else if (properties != null) {
getServiceFactory().getProperties().putAll(properties);
}
final Client client;
final Endpoint ep;
try {
ep = createEndpoint();
this.getServiceFactory().sendEvent(FactoryBeanListener.Event.PRE_CLIENT_CREATE, ep);
applyProperties(ep);
client = createClient(ep);
initializeAnnotationInterceptors(ep, getServiceClass());
} catch (EndpointException | BusException e) {
throw new ServiceConstructionException(e);
}
applyFeatures(client);
this.getServiceFactory().sendEvent(FactoryBeanListener.Event.CLIENT_CREATED, client, ep);
return client;
}
use of org.apache.cxf.service.factory.ServiceConstructionException in project ddf by codice.
the class SecureProxyServiceFactoryImpl method createSecureClientFactory.
private <ProxyServiceType> ProxyServiceType createSecureClientFactory(WebServiceProperties<ProxyServiceType> wsp, SecurityToken token) throws UnsupportedOperationException {
JaxWsProxyFactoryBean clientFactory = new JaxWsProxyFactoryBean();
boolean populateFromClass = unavailableWsdls.contains(wsp.endpointWsdlURL);
if (populateFromClass) {
LOGGER.debug("Using service class to create client rather than WSDL.");
}
clientFactory.getClientFactoryBean().getServiceFactory().setPopulateFromClass(populateFromClass);
LOGGER.debug("Configuring client proxy properties");
configureProxyFactoryProperties(clientFactory, token, wsp);
clientFactory.getOutInterceptors().add(new TokenPassThroughInterceptor());
ProxyServiceType proxyServiceType;
try {
proxyServiceType = clientFactory.create(wsp.serviceClass);
} catch (ServiceConstructionException e) {
LOGGER.debug("Unable to use WSDL to build client. Attempting to use service class.", e);
unavailableWsdls.add(wsp.endpointWsdlURL);
clientFactory.getClientFactoryBean().getServiceFactory().setPopulateFromClass(true);
proxyServiceType = clientFactory.create(wsp.serviceClass);
}
return proxyServiceType;
}
Aggregations