use of org.apache.cxf.service.factory.ServiceConstructionException in project cxf by apache.
the class AbstractWSDLBasedEndpointFactory method createBindingInfo.
protected BindingInfo createBindingInfo() {
BindingFactoryManager mgr = bus.getExtension(BindingFactoryManager.class);
String binding = bindingId;
if (binding == null && bindingConfig != null) {
binding = bindingConfig.getBindingId();
}
if (binding == null) {
// default to soap binding
binding = "http://schemas.xmlsoap.org/soap/";
}
try {
if (binding.contains("/soap")) {
if (bindingConfig == null) {
bindingConfig = createSoapBindingConfig();
}
if (bindingConfig instanceof SoapBindingConfiguration && !((SoapBindingConfiguration) bindingConfig).isSetStyle()) {
((SoapBindingConfiguration) bindingConfig).setStyle(serviceFactory.getStyle());
}
}
bindingFactory = mgr.getBindingFactory(binding);
BindingInfo inf = bindingFactory.createBindingInfo(serviceFactory.getService(), binding, bindingConfig);
for (BindingOperationInfo boi : inf.getOperations()) {
serviceFactory.updateBindingOperation(boi);
Method m = serviceFactory.getMethodDispatcher().getMethod(boi);
serviceFactory.sendEvent(FactoryBeanListener.Event.BINDING_OPERATION_CREATED, inf, boi, m);
}
serviceFactory.sendEvent(FactoryBeanListener.Event.BINDING_CREATED, inf);
return inf;
} catch (BusException ex) {
throw new ServiceConstructionException(new Message("COULD.NOT.RESOLVE.BINDING", LOG, bindingId), ex);
}
}
use of org.apache.cxf.service.factory.ServiceConstructionException in project cxf by apache.
the class JAXBDataBinding method initialize.
@SuppressWarnings("unchecked")
public synchronized void initialize(Service service) {
inInterceptors.addIfAbsent(JAXBAttachmentSchemaValidationHack.INSTANCE);
inFaultInterceptors.addIfAbsent(JAXBAttachmentSchemaValidationHack.INSTANCE);
// context is already set, don't redo it
if (context != null) {
return;
}
contextClasses = new LinkedHashSet<>();
for (ServiceInfo serviceInfo : service.getServiceInfos()) {
JAXBContextInitializer initializer = new JAXBContextInitializer(getBus(), serviceInfo, contextClasses, typeRefs, this.getUnmarshallerProperties());
initializer.walk();
if (serviceInfo.getProperty("extra.class") != null) {
Set<Class<?>> exClasses = serviceInfo.getProperty("extra.class", Set.class);
contextClasses.addAll(exClasses);
}
}
String tns = getNamespaceToUse(service);
final CachedContextAndSchemas cachedContextAndSchemas;
try {
cachedContextAndSchemas = createJAXBContextAndSchemas(contextClasses, tns);
} catch (JAXBException e1) {
throw new ServiceConstructionException(e1);
}
final JAXBContext ctx = cachedContextAndSchemas.getContext();
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "CREATED_JAXB_CONTEXT", new Object[] { ctx, contextClasses });
}
setContext(ctx);
for (ServiceInfo serviceInfo : service.getServiceInfos()) {
SchemaCollection col = serviceInfo.getXmlSchemaCollection();
if (col.getXmlSchemas().length > 1) {
// someone has already filled in the types
justCheckForJAXBAnnotations(serviceInfo);
continue;
}
boolean schemasFromCache = false;
Collection<DOMSource> schemas = getSchemas();
if (schemas == null || schemas.isEmpty()) {
schemas = cachedContextAndSchemas.getSchemas();
if (schemas != null) {
schemasFromCache = true;
}
} else {
schemasFromCache = true;
}
Set<DOMSource> bi = new LinkedHashSet<>();
if (schemas == null) {
schemas = new LinkedHashSet<>();
try {
for (DOMResult r : generateJaxbSchemas()) {
DOMSource src = new DOMSource(r.getNode(), r.getSystemId());
if (isInBuiltInSchemas(r)) {
bi.add(src);
} else {
schemas.add(src);
}
}
// put any builtins at the end. Anything that DOES import them
// will cause it to load automatically and we'll skip them later
schemas.addAll(bi);
} catch (IOException e) {
throw new ServiceConstructionException("SCHEMA_GEN_EXC", LOG, e);
}
}
for (DOMSource r : schemas) {
if (bi.contains(r)) {
String ns = ((Document) r.getNode()).getDocumentElement().getAttribute("targetNamespace");
if (serviceInfo.getSchema(ns) != null) {
continue;
}
}
// StaxUtils.print(r.getNode());
// System.out.println();
addSchemaDocument(serviceInfo, col, (Document) r.getNode(), r.getSystemId());
}
JAXBSchemaInitializer schemaInit = new JAXBSchemaInitializer(serviceInfo, col, context, this.qualifiedSchemas, tns);
schemaInit.walk();
if (cachedContextAndSchemas != null && !schemasFromCache) {
cachedContextAndSchemas.setSchemas(schemas);
}
}
}
use of org.apache.cxf.service.factory.ServiceConstructionException in project cxf by apache.
the class ServiceImpl method initialize.
final void initialize(Bus b, URL url, WebServiceFeature... f) {
if (b == null) {
b = BusFactory.getThreadDefaultBus(true);
}
serviceFeatures = f;
bus = b;
handlerResolver = new HandlerResolverImpl(bus, serviceName, clazz);
if (null == url && null != bus) {
ServiceContractResolverRegistry registry = bus.getExtension(ServiceContractResolverRegistry.class);
if (null != registry) {
URI uri = registry.getContractLocation(serviceName);
if (null != uri) {
try {
url = uri.toURL();
} catch (MalformedURLException e) {
LOG.log(Level.FINE, "resolve qname failed", serviceName);
throw new WebServiceException(e);
}
}
}
}
wsdlURL = url == null ? null : url.toString();
if (url != null) {
try {
initializePorts();
} catch (ServiceConstructionException e) {
throw new WebServiceException(e);
}
}
}
use of org.apache.cxf.service.factory.ServiceConstructionException in project cxf by apache.
the class AbstractJAXWSMethodInvoker method getProviderServiceObjectMethod.
private Method getProviderServiceObjectMethod(Method m, Class<?> serviceObjectClass) {
if (!Provider.class.isAssignableFrom(serviceObjectClass)) {
return m;
}
Class<?> currentSvcClass = serviceObjectClass;
Class<?> genericType = null;
while (currentSvcClass != null) {
genericType = getProviderGenericType(currentSvcClass);
if (genericType != null) {
break;
}
// Check superclass until top
currentSvcClass = currentSvcClass.getSuperclass();
}
// Should never happens
if (genericType == null) {
return m;
}
try {
return serviceObjectClass.getMethod("invoke", genericType);
} catch (Exception e) {
throw new ServiceConstructionException(e);
}
}
use of org.apache.cxf.service.factory.ServiceConstructionException in project cxf by apache.
the class JAXWSMethodDispatcher method bind.
public void bind(OperationInfo o, Method... methods) {
Method[] newMethods = new Method[methods.length];
int i = 0;
for (Method m : methods) {
try {
newMethods[i] = getImplementationMethod(m);
i++;
} catch (NoSuchMethodException e) {
if (m.getName().endsWith("Async") && (Future.class.equals(m.getReturnType()) || Response.class.equals(m.getReturnType()))) {
newMethods[i] = m;
i++;
continue;
}
Class<?> endpointClass = implInfo.getImplementorClass();
Message msg = new Message("SEI_METHOD_NOT_FOUND", LOG, m.getName(), endpointClass.getName());
throw new ServiceConstructionException(msg, e);
}
}
super.bind(o, newMethods);
}
Aggregations