XMLElement faultRefEl,
DescriptionElement desc,
InterfaceOperationElement parent)
throws WSDLException {
InterfaceFaultReferenceElement faultRef = parent.addInterfaceFaultReferenceElement();
if(Constants.ELEM_INFAULT.equals(faultRefEl.getLocalName())) {
faultRef.setDirection(Direction.IN);
}
else if(Constants.ELEM_OUTFAULT.equals(faultRefEl.getLocalName())){
faultRef.setDirection(Direction.OUT);
}
String ref = faultRefEl.getAttributeValue(Constants.ATTR_REF);
if(ref != null)
{
try {
QName qname = faultRefEl.getQName(ref);
faultRef.setRef(qname);
} 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.
InterfaceOperationElement iop = (InterfaceOperationElement)faultRef.getParentElement();
URI mep = iop.getPattern();
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, InterfaceFaultReferenceElement.class, faultRef, desc);
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(InterfaceFaultReferenceElement.class, faultRef, tempEl, desc) );
}
}
return faultRef;