private BindingElement parseBinding(
XMLElement bindEl,
DescriptionElement desc)
throws WSDLException {
BindingElement binding = desc.addBindingElement();
String name = bindEl.getAttributeValue(Constants.ATTR_NAME);
if(name != null)
{
binding.setName(new NCName(name));
}
QName intfaceQN = null;
String intface = bindEl.getAttributeValue(Constants.ATTR_INTERFACE);
if(intface != null)
{
try {
intfaceQN = bindEl.getQName(intface);
binding.setInterfaceName(intfaceQN);
} catch (WSDLException e) {
getErrorReporter().reportError(
new ErrorLocatorImpl(), //TODO line&col nos.
"WSDL505",
new Object[] {intface, bindEl.getQName()},
ErrorReporter.SEVERITY_ERROR);
}
}
String type = bindEl.getAttributeValue(Constants.ATTR_TYPE);
if(type != null) {
binding.setType(getURI(type));
}
parseExtensionAttributes(bindEl, BindingElement.class, binding, desc);
/* Parse the child elements of <binding>.
* As per WSDL 2.0 spec, they must be in the following order if present:
* <documentation>
* <fault> <operation> or extension elements in any order
* TODO validate that the elements are in correct order
*/
XMLElement[] children = bindEl.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, binding);
}
else if (Constants.Q_ELEM_FAULT.equals(tempElQN))
{
parseBindingFault(tempEl, desc, binding);
}
else if (Constants.Q_ELEM_OPERATION.equals(tempElQN))
{
parseBindingOperation(tempEl, desc, binding);
}
else
{
binding.addExtensionElement(
parseExtensionElement(BindingElement.class, binding, tempEl, desc) );
}
}
return binding;