TWSDLParserContextImpl context,
Element e) {
context.push();
context.registerNamespaces(e);
Operation operation = new Operation(forest.locatorTable.getStartLocation(e));
String name = Util.getRequiredAttribute(e, Constants.ATTR_NAME);
operation.setName(name);
String parameterOrderAttr =
XmlUtil.getAttributeOrNull(e, Constants.ATTR_PARAMETER_ORDER);
operation.setParameterOrder(parameterOrderAttr);
boolean gotDocumentation = false;
boolean gotInput = false;
boolean gotOutput = false;
boolean gotFault = false;
boolean inputBeforeOutput = false;
for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
Element e2 = Util.nextElement(iter);
if (e2 == null)
break;
if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_DOCUMENTATION)) {
if (gotDocumentation) {
errReceiver.error(forest.locatorTable.getStartLocation(e2), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e2.getLocalName()));
}
gotDocumentation = true;
if(operation.getDocumentation() == null)
operation.setDocumentation(getDocumentationFor(e2));
} else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_INPUT)) {
if (gotInput) {
errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_TOO_MANY_ELEMENTS(Constants.TAG_INPUT,
Constants.TAG_OPERATION,
name));
}
context.push();
context.registerNamespaces(e2);
Input input = new Input(forest.locatorTable.getStartLocation(e2), errReceiver);
input.setParent(operation);
String messageAttr =
Util.getRequiredAttribute(e2, Constants.ATTR_MESSAGE);
input.setMessage(context.translateQualifiedName(context.getLocation(e2), messageAttr));
String nameAttr =
XmlUtil.getAttributeOrNull(e2, Constants.ATTR_NAME);
input.setName(nameAttr);
operation.setInput(input);
gotInput = true;
if (gotOutput) {
inputBeforeOutput = false;
}
// check for extensiblity attributes
for (Iterator iter2 = XmlUtil.getAllAttributes(e2);
iter2.hasNext();
) {
Attr e3 = (Attr)iter2.next();
if (e3.getLocalName().equals(Constants.ATTR_MESSAGE) ||
e3.getLocalName().equals(Constants.ATTR_NAME))
continue;
// possible extensibility element -- must live outside the WSDL namespace
checkNotWsdlAttribute(e3);
if (!handleExtension(context, input, e3, e2)) {
// ignore the extensiblity attribute
// TODO throw a WARNING
}
}
// verify that there is at most one child element and it is a documentation element
boolean gotDocumentation2 = false;
for (Iterator iter2 = XmlUtil.getAllChildren(e2);
iter2.hasNext();
) {
Element e3 = Util.nextElement(iter2);
if (e3 == null)
break;
if (XmlUtil
.matchesTagNS(e3, WSDLConstants.QNAME_DOCUMENTATION)) {
if (gotDocumentation2) {
errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName()));
}
gotDocumentation2 = true;
input.setDocumentation(getDocumentationFor(e3));
} else {
errReceiver.error(forest.locatorTable.getStartLocation(e3), WsdlMessages.PARSING_INVALID_ELEMENT(e3.getTagName(),
e3.getNamespaceURI()));
}
}
context.pop();
} else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_OUTPUT)) {
if (gotOutput) {
errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_TOO_MANY_ELEMENTS(Constants.TAG_INPUT,
Constants.TAG_OPERATION,
name));
}
context.push();
context.registerNamespaces(e2);
Output output = new Output(forest.locatorTable.getStartLocation(e2), errReceiver);
output.setParent(operation);
String messageAttr =
Util.getRequiredAttribute(e2, Constants.ATTR_MESSAGE);
output.setMessage(context.translateQualifiedName(context.getLocation(e2), messageAttr));
String nameAttr =
XmlUtil.getAttributeOrNull(e2, Constants.ATTR_NAME);
output.setName(nameAttr);
operation.setOutput(output);
gotOutput = true;
if (gotInput) {
inputBeforeOutput = true;
}
// check for extensiblity attributes
for (Iterator iter2 = XmlUtil.getAllAttributes(e2);
iter2.hasNext();
) {
Attr e3 = (Attr)iter2.next();
if (e3.getLocalName().equals(Constants.ATTR_MESSAGE) ||
e3.getLocalName().equals(Constants.ATTR_NAME))
continue;
// possible extensibility element -- must live outside the WSDL namespace
checkNotWsdlAttribute(e3);
if (!handleExtension(context, output, e3, e2)) {
// ignore the extensiblity attribute
// TODO throw a WARNING
}
}
// verify that there is at most one child element and it is a documentation element
boolean gotDocumentation2 = false;
for (Iterator iter2 = XmlUtil.getAllChildren(e2);
iter2.hasNext();
) {
Element e3 = Util.nextElement(iter2);
if (e3 == null)
break;
if (XmlUtil
.matchesTagNS(e3, WSDLConstants.QNAME_DOCUMENTATION)) {
if (gotDocumentation2) {
errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName()));
}
gotDocumentation2 = true;
output.setDocumentation(getDocumentationFor(e3));
} else {
errReceiver.error(forest.locatorTable.getStartLocation(e3), WsdlMessages.PARSING_INVALID_ELEMENT(e3.getTagName(),
e3.getNamespaceURI()));
}
}
context.pop();
} else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_FAULT)) {
context.push();
context.registerNamespaces(e2);
Fault fault = new Fault(forest.locatorTable.getStartLocation(e2));
fault.setParent(operation);
String messageAttr =
Util.getRequiredAttribute(e2, Constants.ATTR_MESSAGE);
fault.setMessage(context.translateQualifiedName(context.getLocation(e2), messageAttr));
String nameAttr =
XmlUtil.getAttributeOrNull(e2, Constants.ATTR_NAME);
fault.setName(nameAttr);
operation.addFault(fault);
gotFault = true;
// check for extensiblity attributes
for (Iterator iter2 = XmlUtil.getAllAttributes(e2);
iter2.hasNext();
) {
Attr e3 = (Attr)iter2.next();
if (e3.getLocalName().equals(Constants.ATTR_MESSAGE) ||
e3.getLocalName().equals(Constants.ATTR_NAME))
continue;
// possible extensibility element -- must live outside the WSDL namespace
checkNotWsdlAttribute(e3);
if (!handleExtension(context, fault, e3, e2)) {
// ignore the extensiblity attribute
// TODO throw a WARNING
}
}
// verify that there is at most one child element and it is a documentation element
boolean gotDocumentation2 = false;
for (Iterator iter2 = XmlUtil.getAllChildren(e2);
iter2.hasNext();
) {
Element e3 = Util.nextElement(iter2);
if (e3 == null)
break;
if (XmlUtil
.matchesTagNS(e3, WSDLConstants.QNAME_DOCUMENTATION)) {
if (gotDocumentation2) {
errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName()));
}
gotDocumentation2 = true;
if(fault.getDocumentation() == null)
fault.setDocumentation(getDocumentationFor(e3));
} else {
// possible extensibility element -- must live outside the WSDL namespace
checkNotWsdlElement(e3);
if (!handleExtension(context, fault, e3)) {
checkNotWsdlRequired(e3);
}
}/*else {
Util.fail(
"parsing.invalidElement",
e3.getTagName(),
e3.getNamespaceURI());
}*/
}
context.pop();
} else {
// possible extensibility element -- must live outside the WSDL namespace
checkNotWsdlElement(e2);
if (!handleExtension(context, operation, e2)) {
checkNotWsdlRequired(e2);
}
}/*else {
Util.fail(
"parsing.invalidElement",
e2.getTagName(),
e2.getNamespaceURI());
}*/
}
if (gotInput && !gotOutput && !gotFault) {
operation.setStyle(OperationStyle.ONE_WAY);
} else if (gotInput && gotOutput && inputBeforeOutput) {
operation.setStyle(OperationStyle.REQUEST_RESPONSE);
} else if (gotInput && gotOutput && !inputBeforeOutput) {
operation.setStyle(OperationStyle.SOLICIT_RESPONSE);
} else if (gotOutput && !gotInput && !gotFault) {
operation.setStyle(OperationStyle.NOTIFICATION);
} else {
errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_INVALID_OPERATION_STYLE(name));
}
context.pop();