use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class DocLiteralInInterceptor method getBindingOperationForEmptyBody.
private void getBindingOperationForEmptyBody(Collection<OperationInfo> operations, Endpoint ep, Exchange exchange) {
// TO DO : check duplicate operation with no input and also check if the action matches
for (OperationInfo op : operations) {
MessageInfo bmsg = op.getInput();
int bPartsNum = bmsg.getMessagePartsNumber();
if (bPartsNum == 0 || (bPartsNum == 1 && Constants.XSD_ANYTYPE.equals(bmsg.getFirstMessagePart().getTypeQName()))) {
BindingOperationInfo boi = ep.getEndpointInfo().getBinding().getOperation(op);
exchange.put(BindingOperationInfo.class, boi);
exchange.setOneWay(op.isOneWay());
}
}
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class ReflectionServiceFactoryBean method initializeClassInfo.
/**
* set the holder generic type info into message part info
*
* @param o
* @param method
*/
protected boolean initializeClassInfo(OperationInfo o, Method method, List<String> paramOrder) {
OperationInfo origOp = o;
if (isWrapped(method)) {
if (o.getUnwrappedOperation() == null) {
// the "normal" algorithm didn't allow for unwrapping,
// but the annotations say unwrap this. We'll need to
// make it.
WSDLServiceBuilder.checkForWrapped(o, true);
}
if (o.getUnwrappedOperation() != null) {
if (o.hasInput()) {
MessageInfo input = o.getInput();
MessagePartInfo part = input.getFirstMessagePart();
part.setTypeClass(getRequestWrapper(method));
part.setProperty("REQUEST.WRAPPER.CLASSNAME", getRequestWrapperClassName(method));
part.setIndex(0);
}
if (o.hasOutput()) {
MessageInfo input = o.getOutput();
MessagePartInfo part = input.getFirstMessagePart();
part.setTypeClass(getResponseWrapper(method));
part.setProperty("RESPONSE.WRAPPER.CLASSNAME", getResponseWrapperClassName(method));
part.setIndex(0);
}
setFaultClassInfo(o, method);
o = o.getUnwrappedOperation();
} else {
LOG.warning(new Message("COULD_NOT_UNWRAP", LOG, o.getName(), method).toString());
setFaultClassInfo(o, method);
}
} else if (o.isUnwrappedCapable()) {
// remove the unwrapped operation because it will break the
// the WrapperClassOutInterceptor, and in general makes
// life more confusing
o.setUnwrappedOperation(null);
setFaultClassInfo(o, method);
}
o.setProperty(METHOD_PARAM_ANNOTATIONS, method.getParameterAnnotations());
o.setProperty(METHOD_ANNOTATIONS, method.getAnnotations());
// Set all out of band indexes to MAX_VALUE, anything left at MAX_VALUE after this is unmapped
for (MessagePartInfo mpi : o.getInput().getOutOfBandParts()) {
mpi.setIndex(Integer.MAX_VALUE);
}
if (o.hasOutput()) {
for (MessagePartInfo mpi : o.getOutput().getOutOfBandParts()) {
mpi.setIndex(Integer.MAX_VALUE);
}
}
Class<?>[] paramTypes = method.getParameterTypes();
Type[] genericTypes = method.getGenericParameterTypes();
for (int i = 0; i < paramTypes.length; i++) {
if (Exchange.class.equals(paramTypes[i])) {
continue;
}
Class<?> paramType = paramTypes[i];
Type genericType = genericTypes[i];
if (!initializeParameter(o, method, i, paramType, genericType)) {
return false;
}
}
setIndexes(o.getInput());
sendEvent(Event.OPERATIONINFO_IN_MESSAGE_SET, origOp, method, origOp.getInput());
// Initialize return type
if (o.hasOutput() && !initializeParameter(o, method, -1, method.getReturnType(), method.getGenericReturnType())) {
return false;
}
if (o.hasOutput()) {
setIndexes(o.getOutput());
}
if (origOp.hasOutput()) {
sendEvent(Event.OPERATIONINFO_OUT_MESSAGE_SET, origOp, method, origOp.getOutput());
}
setFaultClassInfo(o, method);
return true;
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class ReflectionServiceFactoryBean method initializeWSDLOperations.
protected void initializeWSDLOperations() {
List<OperationInfo> removes = new ArrayList<>();
Method[] methods = serviceClass.getMethods();
Arrays.sort(methods, new MethodComparator());
InterfaceInfo intf = getInterfaceInfo();
Map<QName, Method> validMethods = new HashMap<>();
for (Method m : methods) {
if (isValidMethod(m)) {
QName opName = getOperationName(intf, m);
validMethods.put(opName, m);
}
}
for (OperationInfo o : intf.getOperations()) {
Method selected = null;
for (Map.Entry<QName, Method> m : validMethods.entrySet()) {
QName opName = m.getKey();
if (o.getName().getNamespaceURI().equals(opName.getNamespaceURI()) && isMatchOperation(o.getName().getLocalPart(), opName.getLocalPart())) {
selected = m.getValue();
break;
}
}
if (selected == null) {
LOG.log(Level.WARNING, "NO_METHOD_FOR_OP", o.getName());
removes.add(o);
} else {
initializeWSDLOperation(intf, o, selected);
}
}
for (OperationInfo op : removes) {
intf.removeOperation(op);
}
// Update the bindings.
for (ServiceInfo service : getService().getServiceInfos()) {
for (BindingInfo bi : service.getBindings()) {
List<BindingOperationInfo> biremoves = new ArrayList<>();
for (BindingOperationInfo binfo : bi.getOperations()) {
if (removes.contains(binfo.getOperationInfo())) {
biremoves.add(binfo);
} else {
binfo.updateUnwrappedOperation();
}
}
for (BindingOperationInfo binfo : biremoves) {
bi.removeOperation(binfo);
}
}
}
sendEvent(Event.INTERFACE_CREATED, intf, getServiceClass());
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class ReflectionServiceFactoryBean method initializeWrappedSchema.
protected void initializeWrappedSchema(ServiceInfo serviceInfo) {
for (OperationInfo op : serviceInfo.getInterface().getOperations()) {
if (op.getUnwrappedOperation() != null) {
if (op.hasInput()) {
MessagePartInfo fmpi = op.getInput().getFirstMessagePart();
if (fmpi.getTypeClass() == null) {
QName wrapperBeanName = fmpi.getElementQName();
XmlSchemaElement e = null;
for (SchemaInfo s : serviceInfo.getSchemas()) {
e = s.getElementByQName(wrapperBeanName);
if (e != null) {
fmpi.setXmlSchema(e);
break;
}
}
if (e == null) {
createWrappedSchema(serviceInfo, op.getInput(), op.getUnwrappedOperation().getInput(), wrapperBeanName);
}
}
for (MessagePartInfo mpi : op.getInput().getMessageParts()) {
if (Boolean.TRUE.equals(mpi.getProperty(HEADER))) {
QName qn = (QName) mpi.getProperty(ELEMENT_NAME);
mpi.setElement(true);
mpi.setElementQName(qn);
checkForElement(serviceInfo, mpi);
}
}
}
if (op.hasOutput()) {
MessagePartInfo fmpi = op.getOutput().getFirstMessagePart();
if (fmpi.getTypeClass() == null) {
QName wrapperBeanName = fmpi.getElementQName();
XmlSchemaElement e = null;
for (SchemaInfo s : serviceInfo.getSchemas()) {
e = s.getElementByQName(wrapperBeanName);
if (e != null) {
break;
}
}
if (e == null) {
createWrappedSchema(serviceInfo, op.getOutput(), op.getUnwrappedOperation().getOutput(), wrapperBeanName);
}
}
for (MessagePartInfo mpi : op.getOutput().getMessageParts()) {
if (Boolean.TRUE.equals(mpi.getProperty(HEADER))) {
QName qn = (QName) mpi.getProperty(ELEMENT_NAME);
mpi.setElement(true);
mpi.setElementQName(qn);
checkForElement(serviceInfo, mpi);
}
}
}
}
}
}
use of org.apache.cxf.service.model.OperationInfo 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