Fix for constructing complex types.
diff --git a/src/main/java/net/sf/taverna/wsdl/parser/WSDLParser.java b/src/main/java/net/sf/taverna/wsdl/parser/WSDLParser.java
index e78f844..cdc3d49 100644
--- a/src/main/java/net/sf/taverna/wsdl/parser/WSDLParser.java
+++ b/src/main/java/net/sf/taverna/wsdl/parser/WSDLParser.java
@@ -923,7 +923,7 @@
 			// Changed this loop because of the 'offending' WSDL 
 			// (http://www.ncbi.nlm.nih.gov/soap/v2.0/efetch_snp.wsdl) which
 			// uncovered the problem 
-			do {
+			while (true) {
 				List containedElements = refType.getContainedElements();
 				if (containedElements != null) {
 					result.getElements().addAll(
@@ -934,9 +934,15 @@
 					result.getAttributes().addAll(
 							constructAttributes(containedAttributes));
 				}
-				refType.getClass();
-			} while ((refType = (DefinedType) refType
-					.getComplexTypeExtensionBase(getSymbolTable())) != null);
+				if ((refType.getComplexTypeExtensionBase(getSymbolTable()) != null && refType
+						.getComplexTypeExtensionBase(getSymbolTable()) instanceof DefinedType)) {
+					refType = (DefinedType) refType
+							.getComplexTypeExtensionBase(getSymbolTable());
+				} else {
+					break;
+				}
+			}
+		
 
 		}