use of org.apache.cxf.databinding.source.mime.MimeSerializer 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);
}
}
}
}
Aggregations