use of org.apache.cxf.service.factory.ServiceConstructionException in project cxf by apache.
the class JaxWsServiceFactoryBean method bindOperation.
protected void bindOperation(OperationInfo op, Method method) {
try {
// Find the Async method which returns a Response
Method responseMethod = ReflectionUtil.getDeclaredMethod(method.getDeclaringClass(), method.getName() + "Async", method.getParameterTypes());
// Find the Async method whic has a Future & AsyncResultHandler
List<Class<?>> asyncHandlerParams = Arrays.asList(method.getParameterTypes());
// copy it to may it non-readonly
asyncHandlerParams = new ArrayList<>(asyncHandlerParams);
asyncHandlerParams.add(AsyncHandler.class);
Method futureMethod = ReflectionUtil.getDeclaredMethod(method.getDeclaringClass(), method.getName() + "Async", asyncHandlerParams.toArray(new Class<?>[0]));
getMethodDispatcher().bind(op, method, responseMethod, futureMethod);
} catch (SecurityException e) {
throw new ServiceConstructionException(e);
} catch (NoSuchMethodException e) {
getMethodDispatcher().bind(op, method);
}
}
use of org.apache.cxf.service.factory.ServiceConstructionException in project cxf by apache.
the class RMEndpoint method createService.
void createService(ProtocolVariation protocol) {
ServiceInfo si = new ServiceInfo();
si.setProperty(Schema.class.getName(), getSchema());
QName serviceQName = new QName(protocol.getWSRMNamespace(), SERVICE_NAME);
si.setName(serviceQName);
buildInterfaceInfo(si, protocol);
WrappedService service = new WrappedService(applicationEndpoint.getService(), serviceQName, si);
Class<?> create = protocol.getCodec().getCreateSequenceType();
try {
JAXBContext ctx = JAXBContext.newInstance(PackageUtils.getPackageName(create), create.getClassLoader());
service.setDataBinding(new JAXBDataBinding(ctx));
} catch (JAXBException e) {
throw new ServiceConstructionException(e);
}
service.setInvoker(servant);
services.put(protocol, service);
}
use of org.apache.cxf.service.factory.ServiceConstructionException in project cxf by apache.
the class ReflectionServiceFactoryBean method checkForElement.
protected void checkForElement(ServiceInfo serviceInfo, MessagePartInfo mpi) {
SchemaInfo si = getOrCreateSchema(serviceInfo, mpi.getElementQName().getNamespaceURI(), getQualifyWrapperSchema());
XmlSchemaElement e = si.getSchema().getElementByName(mpi.getElementQName().getLocalPart());
if (e != null) {
mpi.setXmlSchema(e);
return;
}
XmlSchema schema = si.getSchema();
// cached element is now invalid
si.setElement(null);
XmlSchemaElement el = new XmlSchemaElement(schema, true);
el.setName(mpi.getElementQName().getLocalPart());
el.setNillable(true);
XmlSchemaType tp = (XmlSchemaType) mpi.getXmlSchema();
if (tp == null) {
throw new ServiceConstructionException(new Message("INTRACTABLE_PART", LOG, mpi.getName(), mpi.getMessageInfo().getName()));
}
el.setSchemaTypeName(tp.getQName());
mpi.setXmlSchema(el);
}
use of org.apache.cxf.service.factory.ServiceConstructionException in project cxf by apache.
the class ReflectionServiceFactoryBean method buildServiceFromClass.
protected void buildServiceFromClass() {
Object o = getBus().getProperty("requireExplicitContractLocation");
if (o != null && ("true".equals(o) || Boolean.TRUE.equals(o))) {
throw new ServiceConstructionException(new Message("NO_WSDL_PROVIDED", LOG, getServiceClass().getName()));
}
if (LOG.isLoggable(Level.INFO)) {
LOG.info("Creating Service " + getServiceQName() + " from class " + getServiceClass().getName());
}
populateFromClass = true;
if (Proxy.isProxyClass(this.getServiceClass())) {
LOG.log(Level.WARNING, "USING_PROXY_FOR_SERVICE", getServiceClass());
}
sendEvent(Event.CREATE_FROM_CLASS, getServiceClass());
ServiceInfo serviceInfo = new ServiceInfo();
SchemaCollection col = serviceInfo.getXmlSchemaCollection();
col.getXmlSchemaCollection().setSchemaResolver(new CatalogXmlSchemaURIResolver(this.getBus()));
col.getExtReg().registerSerializer(MimeAttribute.class, new MimeSerializer());
ServiceImpl service = new ServiceImpl(serviceInfo);
setService(service);
setServiceProperties();
serviceInfo.setName(getServiceQName());
serviceInfo.setTargetNamespace(serviceInfo.getName().getNamespaceURI());
sendEvent(Event.SERVICE_SET, getService());
createInterface(serviceInfo);
Set<?> wrapperClasses = this.getExtraClass();
for (ServiceInfo si : getService().getServiceInfos()) {
if (wrapperClasses != null && !wrapperClasses.isEmpty()) {
si.setProperty(EXTRA_CLASS, wrapperClasses);
}
}
initializeDataBindings();
boolean isWrapped = isWrapped() || hasWrappedMethods(serviceInfo.getInterface());
if (isWrapped) {
initializeWrappedSchema(serviceInfo);
}
for (OperationInfo opInfo : serviceInfo.getInterface().getOperations()) {
Method m = (Method) opInfo.getProperty(METHOD);
if (!isWrapped(m) && !isRPC(m) && opInfo.getInput() != null) {
createBareMessage(serviceInfo, opInfo, false);
}
if (!isWrapped(m) && !isRPC(m) && opInfo.getOutput() != null) {
createBareMessage(serviceInfo, opInfo, true);
}
if (opInfo.hasFaults()) {
// check to make sure the faults are elements
for (FaultInfo fault : opInfo.getFaults()) {
QName qn = (QName) fault.getProperty("elementName");
MessagePartInfo part = fault.getFirstMessagePart();
if (!part.isElement()) {
part.setElement(true);
part.setElementQName(qn);
checkForElement(serviceInfo, part);
}
}
}
}
if (LOG.isLoggable(Level.FINE) || isValidate()) {
ServiceModelSchemaValidator validator = new ServiceModelSchemaValidator(serviceInfo);
validator.walk();
String validationComplaints = validator.getComplaints();
if (!"".equals(validationComplaints)) {
if (isValidate()) {
LOG.warning(validationComplaints);
} else {
LOG.fine(validationComplaints);
}
}
}
}
use of org.apache.cxf.service.factory.ServiceConstructionException in project cxf by apache.
the class ReflectionServiceFactoryBean method validateSchemas.
private void validateSchemas(SchemaCollection xmlSchemaCollection) {
final StringBuilder errorBuilder = new StringBuilder();
XercesXsdValidationImpl v = new XercesXsdValidationImpl();
v.validateSchemas(xmlSchemaCollection.getXmlSchemaCollection(), new DOMErrorHandler() {
public boolean handleError(DOMError error) {
errorBuilder.append(error.getMessage());
LOG.warning(error.getMessage());
return true;
}
});
if (errorBuilder.length() > 0) {
throw new ServiceConstructionException(new Message("XSD_VALIDATION_ERROR", LOG, errorBuilder.toString()));
}
}
Aggregations