247296 [model] xsd:import element reconciled as a WSDLImport
diff --git a/bundles/org.eclipse.wst.wsdl/META-INF/MANIFEST.MF b/bundles/org.eclipse.wst.wsdl/META-INF/MANIFEST.MF
index 5977e2c..b10e75e 100644
--- a/bundles/org.eclipse.wst.wsdl/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.wst.wsdl/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.wst.wsdl; singleton:=true
-Bundle-Version: 1.0.105.qualifier
+Bundle-Version: 1.0.107.qualifier
 Bundle-Activator: org.eclipse.wst.wsdl.WSDLPluginImplementation
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
diff --git a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/util/WSDLUtil.java b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/util/WSDLUtil.java
index da79b04..6b2358c 100644
--- a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/util/WSDLUtil.java
+++ b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/util/WSDLUtil.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
+ * Copyright (c) 2001, 2008 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -63,10 +63,13 @@
   {
     int result = -1;
 
-    Integer integer = (Integer) elementNameToTypeMap.get(element.getLocalName());
-    if (integer != null)
+    if (WSDLConstants.isWSDLNamespace(element.getNamespaceURI()))
     {
-      result = integer.intValue();
+      Integer integer = (Integer) elementNameToTypeMap.get(element.getLocalName());
+      if (integer != null)
+      {
+        result = integer.intValue();
+      }
     }
     return result;
   }
diff --git a/tests/org.eclipse.wst.wsdl.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.wst.wsdl.tests/META-INF/MANIFEST.MF
index 18fd746..fed1d07 100644
--- a/tests/org.eclipse.wst.wsdl.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.wst.wsdl.tests/META-INF/MANIFEST.MF
@@ -1,8 +1,8 @@
 Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: WSDL JUnit Test
-Bundle-SymbolicName: org.eclipse.wst.wsdl.tests
-Bundle-Version: 1.0.1
+Bundle-SymbolicName: org.eclipse.wst.wsdl.tests;singleton:=true
+Bundle-Version: 1.0.2
 Bundle-ClassPath: wsdl.tests.jar
 Bundle-Activator: org.eclipse.wst.wsdl.tests.WSDLTestsPlugin
 Bundle-Localization: plugin
diff --git a/tests/org.eclipse.wst.wsdl.tests/samples/BugFixes/GetWSDLType/BadImport.wsdl b/tests/org.eclipse.wst.wsdl.tests/samples/BugFixes/GetWSDLType/BadImport.wsdl
new file mode 100644
index 0000000..7a8a7d1
--- /dev/null
+++ b/tests/org.eclipse.wst.wsdl.tests/samples/BugFixes/GetWSDLType/BadImport.wsdl
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.example.org/badwsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="badwsdl" targetNamespace="http://www.example.org/badwsdl/">
+  <wsdl:import namespace="http://www.example.org/ImportMe/" location="ImportMe.wsdl"></wsdl:import>
+  <xsd:import namespace="http://www.example.com/BadImport" schemaLocation="BadImport.xsd"></xsd:import>
+  <wsdl:types>
+    <xsd:schema targetNamespace="http://www.example.org/badwsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+      <xsd:element name="NewOperation">
+        <xsd:complexType>
+          <xsd:sequence>
+            <xsd:element name="in" type="xsd:string"/>
+          </xsd:sequence>
+        </xsd:complexType>
+      </xsd:element>
+      <xsd:element name="NewOperationResponse">
+        <xsd:complexType>
+          <xsd:sequence>
+            <xsd:element name="out" type="xsd:string"/>
+          </xsd:sequence>
+        </xsd:complexType>
+      </xsd:element>
+    </xsd:schema>
+  </wsdl:types>
+  <wsdl:message name="NewOperationRequest">
+    <wsdl:part element="tns:NewOperation" name="parameters"/>
+  </wsdl:message>
+  <wsdl:message name="NewOperationResponse">
+    <wsdl:part element="tns:NewOperationResponse" name="parameters"/>
+  </wsdl:message>
+  <wsdl:portType name="badwsdl">
+    <wsdl:operation name="NewOperation">
+      <wsdl:input message="tns:NewOperationRequest"/>
+      <wsdl:output message="tns:NewOperationResponse"/>
+    </wsdl:operation>
+  </wsdl:portType>
+  <wsdl:binding name="badwsdlSOAP" type="tns:badwsdl">
+    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+    <wsdl:operation name="NewOperation">
+      <soap:operation soapAction="http://www.example.org/badwsdl/NewOperation"/>
+      <wsdl:input>
+        <soap:body use="literal"/>
+      </wsdl:input>
+      <wsdl:output>
+        <soap:body use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+  </wsdl:binding>
+  <wsdl:service name="badwsdl">
+    <wsdl:port binding="tns:badwsdlSOAP" name="badwsdlSOAP">
+      <soap:address location="http://www.example.org/"/>
+    </wsdl:port>
+  </wsdl:service>
+</wsdl:definitions>
diff --git a/tests/org.eclipse.wst.wsdl.tests/samples/BugFixes/GetWSDLType/ImportMe.wsdl b/tests/org.eclipse.wst.wsdl.tests/samples/BugFixes/GetWSDLType/ImportMe.wsdl
new file mode 100644
index 0000000..d8899d1
--- /dev/null
+++ b/tests/org.eclipse.wst.wsdl.tests/samples/BugFixes/GetWSDLType/ImportMe.wsdl
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions name="ImportMe" targetNamespace="http://www.example.org/ImportMe/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.example.org/ImportMe/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+  <wsdl:types>
+    <xsd:schema targetNamespace="http://www.example.org/ImportMe/">
+      <xsd:element name="NewOperation">
+        <xsd:complexType>
+          <xsd:sequence>
+            <xsd:element name="in" type="xsd:string"/>
+          </xsd:sequence>
+        </xsd:complexType>
+      </xsd:element>
+      <xsd:element name="NewOperationResponse">
+        <xsd:complexType>
+          <xsd:sequence>
+            <xsd:element name="out" type="xsd:string"/>
+          </xsd:sequence>
+        </xsd:complexType>
+      </xsd:element>
+      <xsd:element name="NewOperationResponse1">
+      	<xsd:complexType>
+      		<xsd:sequence>
+
+      			<xsd:element name="out" type="xsd:string"></xsd:element>
+      		</xsd:sequence>
+      	</xsd:complexType>
+      </xsd:element>
+    </xsd:schema>
+  </wsdl:types>
+  <wsdl:message name="ImportMeMessageRequest">
+    <wsdl:part element="tns:NewOperation" name="parameters"/>
+  </wsdl:message>
+  <wsdl:message name="ImportMeMessageResponse">
+    <wsdl:part element="tns:NewOperationResponse" name="parameters"/>
+  </wsdl:message>
+  <wsdl:message name="ImportMeMessageExtra">
+  	<wsdl:part name="NewPart" type="xsd:string"></wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="NewOperationRequest">
+  	<wsdl:part name="parameters" element="tns:NewOperation"></wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="NewOperationResponse">
+  	<wsdl:part name="parameters" element="tns:NewOperationResponse1"></wsdl:part>
+  </wsdl:message>
+  <wsdl:portType name="ImportMe">
+    <wsdl:operation name="NewOperation">
+      <wsdl:input message="tns:ImportMeMessageRequest"/>
+      <wsdl:output message="tns:ImportMeMessageResponse"/>
+    </wsdl:operation>
+  </wsdl:portType>
+  <wsdl:portType name="ImportPortTypeExtra">
+  	<wsdl:operation name="NewOperation">
+  		<wsdl:input message="tns:NewOperationRequest"></wsdl:input>
+  		<wsdl:output message="tns:NewOperationResponse"></wsdl:output>
+  	</wsdl:operation>
+  </wsdl:portType>
+  <wsdl:binding name="ImportMeSOAP" type="tns:ImportMe">
+    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+    <wsdl:operation name="NewOperation">
+      <soap:operation soapAction="http://www.example.org/ImportMe/NewOperation"/>
+      <wsdl:input>
+        <soap:body use="literal"/>
+      </wsdl:input>
+      <wsdl:output>
+        <soap:body use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+  </wsdl:binding>
+  <wsdl:binding name="ImportBindingExtra"
+  	type="tns:ImportPortTypeExtra">
+  	<soap:binding style="document"
+  		transport="http://schemas.xmlsoap.org/soap/http" />
+  	<wsdl:operation name="NewOperation">
+  		<soap:operation
+  			soapAction="http://www.example.org/ImportMe/NewOperation" />
+  		<wsdl:input>
+  			<soap:body use="literal" />
+  		</wsdl:input>
+  		<wsdl:output>
+  			<soap:body use="literal" />
+  		</wsdl:output>
+  	</wsdl:operation>
+  </wsdl:binding>
+  <wsdl:service name="ImportMe">
+    <wsdl:port binding="tns:ImportMeSOAP" name="ImportMeSOAP">
+      <soap:address location="http://www.example.org/"/>
+    </wsdl:port>
+  </wsdl:service>
+  <wsdl:service name="ImportServiceExtra">
+  	<wsdl:port name="ImportPortExtra" binding="tns:ImportBindingExtra">
+  		<soap:address location="http://www.example.org/" />
+  	</wsdl:port>
+  </wsdl:service>
+</wsdl:definitions>
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/BugFixesTest.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/BugFixesTest.java
index cfd2e25..ed5a20b 100644
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/BugFixesTest.java
+++ b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/BugFixesTest.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -15,6 +15,7 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 import javax.wsdl.OperationType;
 import javax.xml.XMLConstants;
@@ -56,6 +57,7 @@
 import org.eclipse.wst.wsdl.binding.soap.SOAPPackage;
 import org.eclipse.wst.wsdl.binding.soap.internal.util.SOAPConstants;
 import org.eclipse.wst.wsdl.internal.util.WSDLResourceFactoryImpl;
+import org.eclipse.wst.wsdl.internal.util.WSDLUtil;
 import org.eclipse.wst.wsdl.tests.util.DefinitionLoader;
 import org.eclipse.wst.wsdl.util.WSDLConstants;
 import org.eclipse.xsd.XSDElementDeclaration;
@@ -195,6 +197,22 @@
       }
     });
     
+    suite.addTest(new BugFixesTest("GetWSDLType") //$NON-NLS-1$
+    {
+      protected void runTest()
+      {
+        testGetWSDLType();
+      }
+    });
+    
+    suite.addTest(new BugFixesTest("InvalidXSDImports") //$NON-NLS-1$
+    {
+      protected void runTest()
+      {
+        testInvalidXSDImports();
+      }
+    });
+    
     return suite;
   }
 
@@ -913,6 +931,113 @@
       Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage());
     }
   }
+  
+  /**
+   * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=247296
+   */
+  public void testGetWSDLType()
+  {
+    try
+    {
+      // load a wsdl
+      Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/GetWSDLType/BadImport.wsdl", true); //$NON-NLS-1$
+      definition.updateElement();
+
+      // test all direct child elements of definition to make sure they are expected type
+      Element definitionElement = definition.getElement();
+      int type = WSDLUtil.getInstance().getWSDLType(definitionElement);
+      assertEquals("Definition type incorrectly identified", WSDLConstants.DEFINITION, type);  //$NON-NLS-1$
+
+      NodeList childNodes = definitionElement.getChildNodes();
+      Node n = childNodes.item(0);
+      // skip over text node
+      if (n.getNodeType() != Node.ELEMENT_NODE)
+        n = n.getNextSibling();
+      type = WSDLUtil.getInstance().getWSDLType((Element)n);
+      assertEquals("Import type incorrectly identified", WSDLConstants.IMPORT, type);  //$NON-NLS-1$
+      
+      n = n.getNextSibling();
+      // skip over text node
+      if (n.getNodeType() != Node.ELEMENT_NODE)
+        n = n.getNextSibling();
+      type = WSDLUtil.getInstance().getWSDLType((Element)n);
+      assertEquals("xsd:import type incorrectly identified", -1, type);  //$NON-NLS-1$
+      
+      n = n.getNextSibling();
+      // skip over text node
+      if (n.getNodeType() != Node.ELEMENT_NODE)
+        n = n.getNextSibling();
+      type = WSDLUtil.getInstance().getWSDLType((Element)n);
+      assertEquals("Types type incorrectly identified", WSDLConstants.TYPES, type); //$NON-NLS-1$
+      
+      n = n.getNextSibling();
+      // skip over text node
+      if (n.getNodeType() != Node.ELEMENT_NODE)
+        n = n.getNextSibling();
+      type = WSDLUtil.getInstance().getWSDLType((Element)n);
+      assertEquals("Message type incorrectly identified", WSDLConstants.MESSAGE, type); //$NON-NLS-1$
+      n = n.getNextSibling();
+      
+      n = n.getNextSibling();
+      // skip over text node
+      if (n.getNodeType() != Node.ELEMENT_NODE)
+        n = n.getNextSibling();
+      type = WSDLUtil.getInstance().getWSDLType((Element)n);
+      assertEquals("Message type incorrectly identified", WSDLConstants.MESSAGE, type); //$NON-NLS-1$
+      
+      n = n.getNextSibling();
+      // skip over text node
+      if (n.getNodeType() != Node.ELEMENT_NODE)
+        n = n.getNextSibling();
+      type = WSDLUtil.getInstance().getWSDLType((Element)n);
+      assertEquals("Port type type incorrectly identified", WSDLConstants.PORT_TYPE, type); //$NON-NLS-1$
+      
+      n = n.getNextSibling();
+      // skip over text node
+      if (n.getNodeType() != Node.ELEMENT_NODE)
+        n = n.getNextSibling();
+      type = WSDLUtil.getInstance().getWSDLType((Element)n);
+      assertEquals("Binding type incorrectly identified", WSDLConstants.BINDING, type); //$NON-NLS-1$
+      
+      n = n.getNextSibling();
+      // skip over text node
+      if (n.getNodeType() != Node.ELEMENT_NODE)
+        n = n.getNextSibling();
+      type = WSDLUtil.getInstance().getWSDLType((Element)n);
+      assertEquals("Service type incorrectly identified", WSDLConstants.SERVICE, type); //$NON-NLS-1$
+    }
+    catch (Exception e)
+    {
+      e.printStackTrace();
+      fail();
+    }      
+  }
+  
+  /**
+   * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=247296
+   */
+  public void testInvalidXSDImports()
+  {
+    try
+    {
+      // load a wsdl that contains an xsd:import outside of wsdl:types
+      Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/GetWSDLType/BadImport.wsdl", true); //$NON-NLS-1$
+      String targetNamespace = definition.getTargetNamespace();
+      
+      // there should only be one valid wsdl:import
+      Map imports = definition.getImports();
+      assertEquals("Incorrect number of imports", 1, imports.size()); //$NON-NLS-1$
+      
+      // the bad xsd:import should be considered an extensibility element
+      List extElements = definition.getExtensibilityElements();
+      assertEquals("Incorrect number of extensibility elements", 1, extElements.size());  //$NON-NLS-1$
+    }
+    catch (Exception e)
+    {
+      e.printStackTrace();
+      fail();
+    }      
+  }
 
   private Element getNextElement(Element anElement)
   {