checkForWrapped(opInfo, allowRefs, relaxed, Level.FINE);
}
public static void checkForWrapped(OperationInfo opInfo, boolean allowRefs,
boolean relaxed, Level logLevel) {
MessageInfo inputMessage = opInfo.getInput();
MessageInfo outputMessage = opInfo.getOutput();
boolean passedRule = true;
// RULE No.1:
// The operation's input and output message (if present) each contain
// only a single part
// input message must exist
if (inputMessage == null || inputMessage.size() == 0
|| (inputMessage.size() > 1 && !relaxed)) {
passedRule = false;
}
if (outputMessage != null && outputMessage.size() > 1) {
passedRule = false;
}
if (!passedRule) {
org.apache.cxf.common.i18n.Message message
= new org.apache.cxf.common.i18n.Message("WRAPPED_RULE_1", LOG, opInfo.getName());
LOG.log(logLevel, message.toString());
return;
}
SchemaCollection schemas = opInfo.getInterface().getService().getXmlSchemaCollection();
XmlSchemaElement inputEl = null;
XmlSchemaElement outputEl = null;
// RULE No.2:
// The input message part refers to a global element declaration whose
// local name is equal to the operation name.
MessagePartInfo inputPart = inputMessage.getMessagePartByIndex(0);
if (!inputPart.isElement()) {
passedRule = false;
} else {
QName inputElementName = inputPart.getElementQName();
inputEl = schemas.getElementByQName(inputElementName);
if (inputEl == null) {
passedRule = false;
} else if (!opInfo.getName().getLocalPart().equals(inputElementName.getLocalPart())) {
passedRule = relaxed;
}
}
if (!passedRule) {
org.apache.cxf.common.i18n.Message message
= new org.apache.cxf.common.i18n.Message("WRAPPED_RULE_2", LOG, opInfo.getName());
LOG.log(logLevel, message.toString());
return;
}
// RULE No.3:
// The output message part refers to a global element declaration
MessagePartInfo outputPart = null;
if (outputMessage != null && outputMessage.size() == 1) {
outputPart = outputMessage.getMessagePartByIndex(0);
if (outputPart != null) {
if (!outputPart.isElement()
|| schemas.getElementByQName(outputPart.getElementQName()) == null) {
passedRule = false;
} else {
outputEl = schemas.getElementByQName(outputPart.getElementQName());
}
}
}
if (!passedRule) {
org.apache.cxf.common.i18n.Message message
= new org.apache.cxf.common.i18n.Message("WRAPPED_RULE_3", LOG, opInfo.getName());
LOG.log(logLevel, message.toString());
return;
}
// RULE No.4 and No5:
// wrapper element should be pure complex type
// Now lets see if we have any attributes...
// This should probably look at the restricted and substitute types too.
OperationInfo unwrapped = new UnwrappedOperationInfo(opInfo);
MessageInfo unwrappedInput = new MessageInfo(unwrapped, MessageInfo.Type.INPUT,
inputMessage.getName());
MessageInfo unwrappedOutput = null;
XmlSchemaComplexType xsct = null;
if (inputEl.getSchemaType() instanceof XmlSchemaComplexType) {
xsct = (XmlSchemaComplexType)inputEl.getSchemaType();
if (hasAttributes(xsct)
|| (inputEl.isNillable() && !relaxed)
|| !isWrappableSequence(xsct, inputEl.getQName().getNamespaceURI(),
unwrappedInput, allowRefs)) {
passedRule = false;
}
} else {
passedRule = false;
}
if (!passedRule) {
org.apache.cxf.common.i18n.Message message
= new org.apache.cxf.common.i18n.Message("WRAPPED_RULE_4", LOG, opInfo.getName());
LOG.log(logLevel, message.toString());
return;
}
if (outputMessage != null) {
unwrappedOutput = new MessageInfo(unwrapped, MessageInfo.Type.OUTPUT, outputMessage.getName());
if (outputEl != null && outputEl.getSchemaType() instanceof XmlSchemaComplexType) {
xsct = (XmlSchemaComplexType)outputEl.getSchemaType();
if (xsct.isAbstract()) {
passedRule = false;