XMLElement faultRefEl,
DescriptionElement desc,
BindingOperationElement parent)
throws WSDLException {
BindingFaultReferenceElement faultRef = parent.addBindingFaultReferenceElement();
QName refQN = null;
String ref = faultRefEl.getAttributeValue(Constants.ATTR_REF);
if(ref != null)
{
try {
refQN = faultRefEl.getQName(ref);
faultRef.setRef(refQN);
} catch (WSDLException e) {
getErrorReporter().reportError(
new ErrorLocatorImpl(), //TODO line&col nos.
"WSDL505",
new Object[] {ref, faultRefEl.getQName()},
ErrorReporter.SEVERITY_ERROR);
}
}
String msgLabel = faultRefEl.getAttributeValue(Constants.ATTR_MESSAGE_LABEL);
if(msgLabel != null)
{
faultRef.setMessageLabel(new NCName(msgLabel));
}
else
{
//This is a limited solution supporting the 3 MEPs in the Part 2 spec.
//TODO generic support for user-defined, extensible MEPs.
BindingOperationElement bop = (BindingOperationElement)faultRef.getParentElement();
InterfaceOperationElement iop = bop.getInterfaceOperationElement();
URI mep = (iop != null ? iop.getPattern() : null); //iop might be null if the WSDL is invalid
if(Constants.MEP_URI_IN_OUT.equals(mep))
{
//Ruleset is fault-replaces-message, so fault is in same direction as msg.
//The <output> is replaced by an <outfault>.
//The <input> is replaced by an <infault>.
//The <outfault> msg label should match the <output> msg label.
if(Constants.ELEM_OUTFAULT.equals(faultRefEl.getLocalName()))
{
faultRef.setMessageLabel(MessageLabel.OUT);
}
else
{
faultRef.setMessageLabel(MessageLabel.IN);
}
}
else if(Constants.MEP_URI_ROBUST_IN_ONLY.equals(mep))
{
//Ruleset is message-triggers-fault, so fault is opposite direction to msg.
//The <input> can trigger an <outfault>.
//The <outfault> msg label should match the <input> msg label.
if(Constants.ELEM_OUTFAULT.equals(faultRefEl.getLocalName()))
{
faultRef.setMessageLabel(MessageLabel.IN); //the <outfault> is triggered by the <input>
}
else
{
//TODO this MEP may have only <outfault>s, not <infault>s, so treat this as an error.
faultRef.setMessageLabel(MessageLabel.OUT);
}
}
else if(Constants.MEP_URI_IN_ONLY.equals(mep))
{
//TODO Ruleset is no-faults, so treat this as an error.
}
}
parseExtensionAttributes(faultRefEl, BindingFaultReferenceElement.class, faultRef, desc);
/* Parse the child elements of binding operation <infault> or <outfault>.
* As per WSDL 2.0 spec, they must be in the following order if present:
* <documentation>
* extension elements in any order
* TODO validate that the elements are in correct order
*/
XMLElement[] children = faultRefEl.getChildElements();
XMLElement tempEl = null;
QName tempElQN = null;
for(int i=0; i<children.length; i++)
{
tempEl = children[i];
tempElQN = tempEl.getQName();
if (Constants.Q_ELEM_DOCUMENTATION.equals(tempElQN))
{
parseDocumentation(tempEl, desc, faultRef);
}
else
{
faultRef.addExtensionElement(
parseExtensionElement(BindingFaultReferenceElement.class, faultRef, tempEl, desc) );
}
}
return faultRef;