Iterator iterator = typesList.getExtensibilityElements().iterator();
while (iterator.hasNext()) {
WSDLExtensibilityElement element = (WSDLExtensibilityElement) iterator.next();
boolean targetnamespaceFound = false;
if (ExtensionConstants.SCHEMA.equals(element.getType())) {
Schema schema = (Schema) element;
Element schemaElement = schema.getElement();
//first check whether the schema include only a single import statement.
//As per the nature of WSDL if the schema has a single import ONLY, then the
//schema element need not contain a target namespace.
NodeList importNodeList = schemaElement.getElementsByTagNameNS(schemaElement.getNamespaceURI(),"import");
NodeList allNodes = schemaElement.getElementsByTagName("*");
//checking the number of child elements and the number of import elements should get us what we need
if (importNodeList.getLength()==1 && allNodes.getLength()==1){
return;
}
NamedNodeMap attributes = schemaElement.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
if (TARGETNAMESPACE_STRING.equalsIgnoreCase(
attributes.item(i).getLocalName())){
targetnamespaceFound = true;
break;
}
}
if (!targetnamespaceFound)
throw new CodeGenerationException(
"Invalid WSDL: The WSDL Types Schema does not define a targetNamespace in "+schema.getName() );
}
}
}