[jbosstools-commits] JBoss Tools SVN: r31190 - in branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui: src/org/jboss/tools/ws/ui/utils and 1 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Tue May 10 12:54:01 EDT 2011


Author: bfitzpat
Date: 2011-05-10 12:54:01 -0400 (Tue, 10 May 2011)
New Revision: 31190

Added:
   branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/FragmentConstants.java
   branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/NetUtils.java
   branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/SchemaUtils.java
   branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/URIEncoder.java
   branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/URLUtils.java
   branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/Validator.java
   branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/WSDLPartsToXSDTypeMapper.java
Modified:
   branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF
   branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java
   branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/TestHistoryEntry.java
   branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/WSDLBrowseDialog.java
Log:
OPEN - issue JBDS-1602: Web Service Tester generates SOAP bodies that cause marshaling issues 
https://issues.jboss.org/browse/JBDS-1602

Modified: branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF
===================================================================
--- branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF	2011-05-10 16:52:16 UTC (rev 31189)
+++ branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF	2011-05-10 16:54:01 UTC (rev 31190)
@@ -33,7 +33,8 @@
  org.eclipse.osgi,
  org.eclipse.jst.ws.annotations.core,
  org.apache.commons.codec,
- org.apache.commons.discovery;bundle-version="[0.2.0,1.0.0)"
+ org.apache.commons.discovery;bundle-version="[0.2.0,1.0.0)",
+ org.eclipse.xsd
 Bundle-ActivationPolicy: lazy
 Export-Package: javax.ws.rs,
  javax.ws.rs.core,

Added: branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/FragmentConstants.java
===================================================================
--- branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/FragmentConstants.java	                        (rev 0)
+++ branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/FragmentConstants.java	2011-05-10 16:54:01 UTC (rev 31190)
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug      Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20070305   117034 makandre at ca.ibm.com - Andrew Mak, Web Services Explorer should support SOAP Headers
+ *******************************************************************************/
+package org.jboss.tools.ws.ui.utils;
+
+public class FragmentConstants
+{
+  // XSD minOccurs and maxOccurs
+  public static final int DEFAULT_MIN_OCCURS = 1;
+  public static final int DEFAULT_MAX_OCCURS = 1;
+  public static final int UNBOUNDED = -1;
+
+  // WSDL style
+  public static final int STYLE_DOCUMENT = 0;
+  public static final int STYLE_RPC = 1;
+
+  // WSDL Encoding styles
+  public static final int ENCODING_LITERAL = 0;
+  public static final int ENCODING_SOAP = 1;
+  public static final int ENCODING_URL = 2; // HTTP Get/Post
+
+  // IDs used by the fragment model
+  public static final String ID_SEPERATOR = "::"; //$NON-NLS-1$
+  public static final String INPUT_ID = "::input"; //$NON-NLS-1$
+  public static final String OUTPUT_ID = "::output"; //$NON-NLS-1$
+  public static final String TABLE_ID = "::tableID"; //$NON-NLS-1$
+  public static final String FRAGMENT_ID = "::fragmentID"; //$NON-NLS-1$
+  public static final String NAME_ANCHOR_ID = "::nameAnchorID"; //$NON-NLS-1$
+  public static final String FRAGMENT_VIEW_ID = "::fragmentViewID"; //$NON-NLS-1$
+  public static final String XSD_ATOMIC_ENUM_ID = "::xsdAtomicEnumID"; //$NON-NLS-1$
+  public static final String XSD_ALL_GROUP_ID = "::xsdAllGroupID"; //$NON-NLS-1$
+  public static final String PART_TOKEN = "^"; //$NON-NLS-1$
+
+  // Fragment view IDs
+  public static final String FRAGMENT_VIEW_SWITCH_FORM_TO_SOURCE = "::fragmentViewSwitchFormToSource"; //$NON-NLS-1$
+  public static final String FRAGMENT_VIEW_SWITCH_SOURCE_TO_FORM = "::fragmentViewSwitchSourceToForm"; //$NON-NLS-1$
+  public static final String SOURCE_CONTENT_HEADER = "::sourceContentHeader"; //$NON-NLS-1$
+  public static final String SOURCE_CONTENT = "::sourceContent"; //$NON-NLS-1$
+  public static final String SOURCE_CONTENT_NAMESPACE = "::sourceContentNS"; //$NON-NLS-1$
+
+  // Action input constants
+  public static final String NAME_ANCHOR = "nameAnchor"; //$NON-NLS-1$
+
+  // Namespaces contants
+  public static final String URI_XSD = "http://www.w3.org/2001/XMLSchema"; //$NON-NLS-1$
+  public static final String URI_SOAP = "http://schemas.xmlsoap.org/soap/encoding/"; //$NON-NLS-1$
+  public static final String URI_SOAP_ENV = "http://schemas.xmlsoap.org/soap/envelope/"; //$NON-NLS-1$
+  public static final String URI_WSDL = "http://schemas.xmlsoap.org/wsdl/"; //$NON-NLS-1$
+  public static final String URI_XSI = "http://www.w3.org/2001/XMLSchema-instance"; //$NON-NLS-1$
+  public static final String SOAP_ENC_ARRAY_TYPE = "arrayType"; //$NON-NLS-1$
+  public static final String XSI_TYPE = "type"; //$NON-NLS-1$
+  public static final String QNAME_PREFIX = "q"; //$NON-NLS-1$
+  public static final String QNAME_LOCAL_NAME_ARRAY_TYPE = "arrayType"; //$NON-NLS-1$
+  public static final String QNAME_LOCAL_NAME_ARRAY = "Array"; //$NON-NLS-1$
+  public static final String COLON = ":"; //$NON-NLS-1$
+  public static final String QNAME_LOCAL_NAME_HEADER = "Header";   //$NON-NLS-1$
+  public static final String QNAME_LOCAL_NAME_BODY = "Body"; //$NON-NLS-1$
+  public static final String QNAME_LOCAL_NAME_FAULT = "Fault"; //$NON-NLS-1$
+
+  // List
+  public static final String LIST_SEPERATOR = " "; //$NON-NLS-1$
+
+  // SOAP-ENC:Array
+  public static final String LEFT_SQUARE_BRACKET = "["; //$NON-NLS-1$
+  public static final String RIGHT_SQUARE_BRACKET = "]"; //$NON-NLS-1$
+
+  // XSDDefaultFragment
+  public static final String ROOT_ELEMENT_START_TAG = "<root>"; //$NON-NLS-1$
+  public static final String ROOT_ELEMENT_END_TAG = "</root>"; //$NON-NLS-1$
+
+  // Namespace URIs.
+  public static final String NS_URI_XMLNS = "http://www.w3.org/2000/xmlns/"; //$NON-NLS-1$
+  public static final String NS_URI_SOAP_ENV = "http://schemas.xmlsoap.org/soap/envelope/"; //$NON-NLS-1$
+  public static final String NS_URI_SOAP_ENC = "http://schemas.xmlsoap.org/soap/encoding/"; //$NON-NLS-1$
+  public static final String NS_URI_1999_SCHEMA_XSI = "http://www.w3.org/1999/XMLSchema-instance"; //$NON-NLS-1$
+  public static final String NS_URI_1999_SCHEMA_XSD = "http://www.w3.org/1999/XMLSchema"; //$NON-NLS-1$
+  public static final String NS_URI_2000_SCHEMA_XSI = "http://www.w3.org/2000/10/XMLSchema-instance"; //$NON-NLS-1$
+  public static final String NS_URI_2000_SCHEMA_XSD = "http://www.w3.org/2000/10/XMLSchema"; //$NON-NLS-1$
+  public static final String NS_URI_2001_SCHEMA_XSI = "http://www.w3.org/2001/XMLSchema-instance"; //$NON-NLS-1$
+  public static final String NS_URI_2001_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema"; //$NON-NLS-1$
+  public static final String NS_URI_CURRENT_SCHEMA_XSI = NS_URI_2001_SCHEMA_XSI;
+  public static final String NS_URI_CURRENT_SCHEMA_XSD = NS_URI_2001_SCHEMA_XSD;
+  public static final String NS_URI_XML_SOAP = "http://xml.apache.org/xml-soap"; //$NON-NLS-1$
+  public static final String NS_URI_XML_SOAP_DEPLOYMENT = "http://xml.apache.org/xml-soap/deployment"; //$NON-NLS-1$
+  public static final String NS_URI_LITERAL_XML = "http://xml.apache.org/xml-soap/literalxml"; //$NON-NLS-1$
+  public static final String NS_URI_XMI_ENC = "http://www.ibm.com/namespaces/xmi"; //$NON-NLS-1$
+}
\ No newline at end of file


Property changes on: branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/FragmentConstants.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/NetUtils.java
===================================================================
--- branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/NetUtils.java	                        (rev 0)
+++ branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/NetUtils.java	2011-05-10 16:54:01 UTC (rev 31190)
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.jboss.tools.ws.ui.utils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.apache.commons.codec.binary.Base64;
+
+public final class NetUtils
+{
+
+  /**
+   * Get the java.net.URLConnection given a string representing the URL. This class ensures
+   * that proxy settings in WSAD are respected.
+   * @param urlString String representing the URL.
+   * @return java.net.URLCDonnection URLConnection to the URL.
+   */
+  public static final URLConnection getURLConnection(String urlString)
+  {
+    try
+    {
+      URL url = createURL(urlString);
+      URLConnection uc = url.openConnection();
+      String proxyUserName = System.getProperty("http.proxyUserName"); //$NON-NLS-1$
+      String proxyPassword = System.getProperty("http.proxyPassword"); //$NON-NLS-1$
+      if (proxyUserName != null && proxyPassword != null)
+      {
+        StringBuffer userNamePassword = new StringBuffer(proxyUserName);
+        userNamePassword.append(':').append(proxyPassword);
+        Base64 encoder = new Base64();
+        String encoding = new String(encoder.encode(userNamePassword.toString().getBytes()));
+        userNamePassword.setLength(0);
+        userNamePassword.append("Basic ").append(encoding); //$NON-NLS-1$
+        uc.setRequestProperty("Proxy-authorization",userNamePassword.toString()); //$NON-NLS-1$
+      }
+      return uc;
+    }
+    catch (MalformedURLException e)
+    {
+    }
+    catch (IOException e)
+    {
+    }
+    return null;
+  }
+  
+  /**
+   * Get the java.io.InputStream for a URL given a string representing the URL. This class
+   * ensures that proxy settings in WSAD are respected.
+   * @param urlString String representing the URL.
+   * @return java.io.InputStream InputStream for reading the URL stream.
+   */
+  public static final InputStream getURLInputStream(String urlString)
+  {
+    try
+    {
+      URLConnection uc = getURLConnection(urlString);
+      if (uc != null)
+      {
+        InputStream is = uc.getInputStream();
+        return is;
+      }
+    }
+    catch (IOException e)
+    {
+    }
+    return null;
+  }
+
+  /**
+   * Create a URL from a string.
+   * @param urlString String representing the URL.
+   * @return URL java.lang.URL representation of the URL.
+   * @throws MalformedURLException
+   */
+  public static final URL createURL(String urlString) throws MalformedURLException
+  {
+  	return new URL(urlString);
+  }
+}


Property changes on: branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/NetUtils.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/SchemaUtils.java
===================================================================
--- branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/SchemaUtils.java	                        (rev 0)
+++ branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/SchemaUtils.java	2011-05-10 16:54:01 UTC (rev 31190)
@@ -0,0 +1,1225 @@
+/******************************************************************************* 
+ * Copyright (c) 2011 Red Hat, Inc. 
+ * Distributed under license by Red Hat, Inc. All rights reserved. 
+ * This program is made available under the terms of the 
+ * Eclipse Public License v1.0 which accompanies this distribution, 
+ * and is available at http://www.eclipse.org/legal/epl-v10.html 
+ * 
+ * Contributors: 
+ * Red Hat, Inc. - initial API and implementation 
+ ******************************************************************************/
+package org.jboss.tools.ws.ui.utils;
+
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.wsdl.Binding;
+import javax.wsdl.BindingInput;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.Definition;
+import javax.wsdl.Import;
+import javax.wsdl.Message;
+import javax.wsdl.Operation;
+import javax.wsdl.Part;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.wsdl.Types;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.UnknownExtensibilityElement;
+import javax.wsdl.extensions.schema.Schema;
+import javax.wsdl.extensions.soap.SOAPHeader;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.xsd.XSDDiagnostic;
+import org.eclipse.xsd.XSDDiagnosticSeverity;
+import org.eclipse.xsd.XSDNamedComponent;
+import org.eclipse.xsd.XSDSchema;
+import org.eclipse.xsd.XSDSchemaContent;
+import org.eclipse.xsd.XSDSchemaDirective;
+import org.eclipse.xsd.impl.XSDSchemaImpl;
+import org.eclipse.xsd.util.XSDParser;
+import org.jdom.Element;
+import org.jdom.input.DOMBuilder;
+
+import com.ibm.wsdl.Constants;
+
+/**
+ * Some of this code was borrowed from the org.eclipse.wst.ws.explorer Web Services Explorer
+ * view from WTP. 
+ * @author bfitzpat
+ *
+ */
+public class SchemaUtils {
+
+	private static final String SIMPLE_TYPE_NAME = "simpleType"; //$NON-NLS-1$
+	private static final String DOUBLE_TYPE_NAME = "double"; //$NON-NLS-1$
+	private static final String INT_TYPE_NAME = "int"; //$NON-NLS-1$
+	private static final String STRING_TYPE_NAME = "string"; //$NON-NLS-1$
+	private static final String BOOLEAN_TYPE_NAME = "boolean"; //$NON-NLS-1$
+	private static final String DECIMAL_TYPE_NAME = "decimal"; //$NON-NLS-1$
+	private static final String PRECISION_DECIMAL_TYPE_NAME = "precisionDecimal"; //$NON-NLS-1$
+	private static final String FLOAT_TYPE_NAME = "float"; //$NON-NLS-1$
+	private static final String DURATION_TYPE_NAME = "duration"; //$NON-NLS-1$
+	private static final String DATETIME_TYPE_NAME = "dateTime"; //$NON-NLS-1$
+	private static final String DATE_TYPE_NAME = "date"; //$NON-NLS-1$
+	private static final String TIME_TYPE_NAME = "time"; //$NON-NLS-1$
+	private static final String GYEARMONTH_TYPE_NAME = "gYearMonth"; //$NON-NLS-1$
+	private static final String GYEAR_TYPE_NAME = "gYear"; //$NON-NLS-1$
+	private static final String GMONTHDAY_TYPE_NAME = "gMonthDay"; //$NON-NLS-1$
+	private static final String GDAY_TYPE_NAME = "gDay"; //$NON-NLS-1$
+	private static final String GMONTH_TYPE_NAME = "gMonth"; //$NON-NLS-1$
+	private static final String HEXBINARY_TYPE_NAME = "hexBinary"; //$NON-NLS-1$
+	private static final String BASE64BINARY_TYPE_NAME = "base64Binary"; //$NON-NLS-1$
+	private static final String ANYURI_TYPE_NAME = "anyURI"; //$NON-NLS-1$
+	private static final String NOTATION_TYPE_NAME = "NOTATION"; //$NON-NLS-1$
+
+	private static Vector<XSDSchema> schemaList_;
+	private static Vector<QName> w3SchemaQNameList_;
+	private static Vector<XSDSchema> constantSchemaList_;
+	private static HashMap<String, String> namespacesAndPrefixes_;
+	private static String wsdlUrl_;
+	private static Vector<String> schemaURI_;
+	private static Definition definition_;
+	private static boolean rootIsQualified_ = false;
+	private static String rootURI_ = null;
+
+	private final static String DEF_FACTORY_PROPERTY_NAME =
+			"javax.wsdl.factory.DefinitionFactory"; //$NON-NLS-1$
+	private final static String PRIVATE_DEF_FACTORY_CLASS =
+			"org.apache.wsif.wsdl.WSIFWSDLFactoryImpl"; //$NON-NLS-1$
+
+	public final static String SOAP_NS_URI = "http://schemas.xmlsoap.org/soap/envelope/"; //$NON-NLS-1$
+	public final static String SOAP12_ENVELOPE_NS_URI = "http://www.w3.org/2003/05/soap-envelope"; //$NON-NLS-1$
+	public final static String SOAP12_NS_URI = "http://schemas.xmlsoap.org/wsdl/soap12/"; //$NON-NLS-1$
+	public final static String SOAP12_PREFIX = "soap12"; //$NON-NLS-1$
+	public final static String SOAP_PREFIX = "soap"; //$NON-NLS-1$
+
+	static
+	{
+		// w3 schema URI list:
+		// http://www.w3.org/2001/XMLSchema
+		// http://www.w3.org/2000/10/XMLSchema
+		// http://www.w3.org/1999/XMLSchema
+		w3SchemaQNameList_ = new Vector<QName>();
+		w3SchemaQNameList_.addElement(new QName(FragmentConstants.NS_URI_CURRENT_SCHEMA_XSD,"schema")); //$NON-NLS-1$
+		w3SchemaQNameList_.addElement(new QName(FragmentConstants.NS_URI_2000_SCHEMA_XSD,"schema")); //$NON-NLS-1$
+		w3SchemaQNameList_.addElement(new QName(FragmentConstants.NS_URI_1999_SCHEMA_XSD,"schema")); //$NON-NLS-1$
+
+		// Constant schema URI list:
+		// http://www.w3.org/2001/XMLSchema
+		// http://www.w3.org/2000/10/XMLSchema
+		// http://www.w3.org/1999/XMLSchema
+		// http://schemas.xmlsoap.org/soap/encoding/
+		// http://schemas.xmlsoap.org/wsdl/
+		constantSchemaList_ = new Vector<XSDSchema>();
+		constantSchemaList_.addElement(XSDSchemaImpl.getSchemaForSchema(FragmentConstants.NS_URI_CURRENT_SCHEMA_XSD));
+		constantSchemaList_.addElement(XSDSchemaImpl.getSchemaForSchema(FragmentConstants.NS_URI_2000_SCHEMA_XSD));
+		constantSchemaList_.addElement(XSDSchemaImpl.getSchemaForSchema(FragmentConstants.NS_URI_1999_SCHEMA_XSD));
+		constantSchemaList_.addElement(XSDSchemaImpl.getSchemaForSchema(FragmentConstants.NS_URI_SOAP_ENC));
+		constantSchemaList_.addElement(XSDSchemaImpl.getSchemaForSchema(FragmentConstants.URI_WSDL));
+		
+		namespacesAndPrefixes_ = new HashMap<String, String>();
+	}
+
+	public static Vector<String> loadWSDL(Definition wsdlDefinition ) throws WSDLException
+	{
+
+		Vector<String> errorMessages = new Vector<String>();
+		definition_ = wsdlDefinition;
+
+
+		if (definition_ != null)
+		{
+			wsdlUrl_ = wsdlDefinition.getDocumentBaseURI();
+			gatherSchemas(definition_, wsdlUrl_);
+			// Validate the schemas.
+			for (int i=0;i<schemaList_.size();i++)
+			{
+				XSDSchema xsdSchema = (XSDSchema)schemaList_.elementAt(i);
+				//		        xsdSchema.clearDiagnostics();
+				//		        xsdSchema.validate();
+				if (xsdSchema == null) continue;
+				EList<XSDDiagnostic> errors = xsdSchema.getAllDiagnostics();
+				if (!errors.isEmpty())
+				{
+					for (ListIterator<XSDDiagnostic> li = errors.listIterator();li.hasNext();)
+					{
+						XSDDiagnostic xd = (XSDDiagnostic)li.next();
+						String msg = xd.getMessage();
+						// do not report low severity diagnostics or erroneous array reference errors.
+						if (xd.getSeverity().getValue() == XSDDiagnosticSeverity.FATAL_LITERAL.getValue() || (msg != null && msg.length() > 0 && msg.toLowerCase().indexOf("#array") != -1)) //$NON-NLS-1$
+							li.remove();
+						else
+						{
+							if (msg != null && msg.length() > 0)
+								errorMessages.addElement(xd.getMessage());
+						}
+					}
+				}
+			}
+
+			for (int i=0;i<constantSchemaList_.size();i++)
+				schemaList_.addElement(constantSchemaList_.elementAt(i));
+
+		}
+		return errorMessages;
+	}
+
+	public static String getSampleSOAPInputMessage ( Definition wsdlDefinition, String serviceName, String portName, String bindingName, String opName ) {
+
+		try {
+			loadWSDL (wsdlDefinition);
+		} catch (WSDLException e) {
+			e.printStackTrace();
+		}
+		namespacesAndPrefixes_ = new HashMap<String, String>();
+		Map<?, ?> services = wsdlDefinition.getServices();
+		Set<?> serviceKeys = services.keySet();
+		for( Iterator<?> it = serviceKeys.iterator(); it.hasNext(); ) {
+			QName serviceKey = (QName) it.next();
+			if (serviceName != null && serviceKey.getLocalPart().contentEquals(serviceName)) {
+				Service service = (Service) services.get( serviceKey );
+				Map<?, ?> ports = service.getPorts();
+				Set<?> portKeys = ports.keySet();
+				for( Iterator<?> it2 = portKeys.iterator(); it2.hasNext(); ) {
+					String portKey = (String) it2.next();
+					if (portName != null && portKey.contentEquals(portName)) {
+						Port port = (Port) ports.get( portKey );
+						Binding wsdlBinding = port.getBinding();
+						PortType portType = wsdlBinding.getPortType();
+						List<?> operations = portType.getOperations();
+						for (Iterator<?> it3 = operations.iterator(); it3.hasNext();){
+							Operation operation = (Operation) it3.next();
+							if (opName != null && operation.getName().contentEquals(opName)) {
+								Message inputMsg = operation.getInput().getMessage();
+								Collection<?> parts = inputMsg.getParts().values();
+								StringBuffer buf = new StringBuffer();
+								for( Iterator<?> it4 = parts.iterator(); it4.hasNext(); ) {
+									Part part = (Part) it4.next();
+									if (part.getName().equalsIgnoreCase("header")) { //$NON-NLS-1$
+										continue;
+									}
+									WSDLPartsToXSDTypeMapper mapper = new WSDLPartsToXSDTypeMapper();
+									mapper.addSchemas(schemaList_);
+
+									buf.append(startProcessingPartXML(wsdlDefinition, part));
+								}
+								return buf.toString();
+							}
+						}
+					}
+				}
+			}
+		}
+		return null;
+	}
+
+	public static Definition readWSDLURL(URL contextURL) throws WSDLException, NullPointerException {
+		Properties props = System.getProperties();
+		String oldPropValue = props.getProperty(DEF_FACTORY_PROPERTY_NAME);
+
+		wsdlUrl_ = contextURL.toExternalForm();
+		props.setProperty(DEF_FACTORY_PROPERTY_NAME, PRIVATE_DEF_FACTORY_CLASS);
+
+		WSDLFactory factory = WSDLFactory.newInstance();
+		WSDLReader wsdlReader = factory.newWSDLReader();
+		wsdlReader.setFeature(Constants.FEATURE_VERBOSE, false);
+		wsdlReader.setFeature("javax.wsdl.importDocuments", true); //$NON-NLS-1$
+		String context = null;
+		if (contextURL != null)
+			context = contextURL.toString();
+		Definition def = wsdlReader.readWSDL(context);
+
+		if (oldPropValue != null) {
+			props.setProperty(DEF_FACTORY_PROPERTY_NAME, oldPropValue);
+		} else {
+			props.remove(DEF_FACTORY_PROPERTY_NAME);
+		}
+		return def;
+	}
+
+	public static String getSampleSOAPMessageHeader ( Definition wsdlDefinition, String serviceName, String portName, String bindingName, String opName ) {
+
+		try {
+			loadWSDL (wsdlDefinition);
+		} catch (WSDLException e) {
+			e.printStackTrace();
+		}
+
+		namespacesAndPrefixes_ = new HashMap<String, String>();
+		Map<?, ?> services = wsdlDefinition.getServices();
+		Set<?> serviceKeys = services.keySet();
+		for( Iterator<?> it = serviceKeys.iterator(); it.hasNext(); ) {
+			QName serviceKey = (QName) it.next();
+			if (serviceName != null && serviceKey.getLocalPart().contentEquals(serviceName)) {
+				Service service = (Service) services.get( serviceKey );
+				Map<?, ?> ports = service.getPorts();
+				Set<?> portKeys = ports.keySet();
+				for( Iterator<?> it2 = portKeys.iterator(); it2.hasNext(); ) {
+					String portKey = (String) it2.next();
+					if (portName != null && portKey.contentEquals(portName)) {
+						Port port = (Port) ports.get( portKey );
+						Binding wsdlBinding = port.getBinding();
+						List<?> operations = wsdlBinding.getBindingOperations();
+						for (Iterator<?> it3 = operations.iterator(); it3.hasNext();){
+							BindingOperation operation = (BindingOperation) it3.next();
+							if (opName != null && operation.getName().contentEquals(opName)) {
+								BindingInput input = operation.getBindingInput();
+								List<?> extensions = input.getExtensibilityElements();
+								for (Iterator<?> extIter = extensions.iterator(); extIter.hasNext();) {
+									Object extension = extIter.next();
+									if (extension instanceof SOAPHeader) {
+										SOAPHeader header = (SOAPHeader) extension;
+										String part = header.getPart();
+										StringBuffer buf = new StringBuffer();
+										WSDLPartsToXSDTypeMapper mapper = new WSDLPartsToXSDTypeMapper();
+										mapper.addSchemas(schemaList_);
+										buf.append(startProcessingPartXML(wsdlDefinition, part, header.getMessage().getNamespaceURI()));
+										return buf.toString();
+									}
+								}
+							}
+						}
+					}
+				}
+			}
+		}
+		return null;
+	}
+
+	private static XSDSchema getSchemaForNamespace ( String namespaceURI ) {
+		Iterator<XSDSchema> iter = schemaList_.iterator();
+		while (iter.hasNext()) {
+			XSDSchema schema = (XSDSchema)iter.next();
+			if (schema != null && schema.getTargetNamespace() != null && schema.getTargetNamespace().equals(namespaceURI)) {
+				return schema;
+			}
+		}
+		return null;
+	}
+
+	private static String getURIForNamespacePrefix ( String nsPrefix ) {
+		Iterator<XSDSchema> iter = schemaList_.iterator();
+		while (iter.hasNext()) {
+			XSDSchema schema = (XSDSchema)iter.next();
+			String nsURI =
+					schema.getQNamePrefixToNamespaceMap().get(nsPrefix);
+			if (nsURI != null) {
+				return nsURI;
+			}
+		}
+		return null;
+	}
+
+	private final static void gatherSchemas(Definition definition, String definitionURL)
+	{
+		schemaList_ = new Vector<XSDSchema>();
+		Types types = definition.getTypes();
+		if (types != null)
+		{
+			List<?> extTypes = types.getExtensibilityElements();
+			if (extTypes != null)
+			{
+				//				org.eclipse.emf.common.util.URI uri = org.eclipse.emf.common.util.URI.createURI(definitionURL);    		
+				//				Resource resource = resourceSet.createResource(uri);
+				for (int i=0;i<extTypes.size();i++)
+				{
+					XSDSchema xsdSchema = null;
+					Object obj = extTypes.get(i);
+					if (obj instanceof Schema) {
+						Schema schemaElement = (Schema) obj;
+						if (isW3SchemaElementType(schemaElement.getElementType()))
+						{
+							xsdSchema = XSDSchemaImpl.createSchema(schemaElement.getElement());
+							if(!checkSchemaURI(definitionURL)){
+								schemaList_.addElement(xsdSchema);
+								gatherSchemaDirective(xsdSchema, definitionURL);
+							}
+							xsdSchema.update();
+							xsdSchema.updateElement();
+							//Add the Schema to the resource
+							//		        	  boolean success = resource.getContents().add(xsdSchema);
+							//		        	  System.out.println(success + "Added schema " + xsdSchema.getTargetNamespace() + " to wsdl resource " + uri.toString());
+						}
+					}
+					else if (obj instanceof UnknownExtensibilityElement)
+					{
+						UnknownExtensibilityElement schemaElement = (UnknownExtensibilityElement)obj;
+						if (isW3SchemaElementType(schemaElement.getElementType()))
+						{
+							xsdSchema = XSDSchemaImpl.createSchema(schemaElement.getElement());
+							if(!checkSchemaURI(definitionURL)){
+								schemaList_.addElement(xsdSchema);
+								gatherSchemaDirective(xsdSchema, definitionURL);
+							}
+							//Add the Schema to the resource
+							//	        	  boolean success = resource.getContents().add(xsdSchema);
+							//	        	  System.out.println(success + "Added schema " + xsdSchema.getTargetNamespace() + " to wsdl resource " + uri.toString());
+						}
+					} 	
+				}
+			}
+		}
+		Map<?, ?> imports = definition.getImports();
+		if (imports != null)
+			gatherImportedSchemas(definition,imports);
+	}
+
+	private final static boolean isW3SchemaElementType(QName qname)
+	{
+		for (int i=0;i<w3SchemaQNameList_.size();i++)
+		{
+			QName w3SchemaQName = (QName)w3SchemaQNameList_.elementAt(i);
+			if (w3SchemaQName.equals(qname))
+				return true;
+		}
+		return false;
+	}
+
+	private static boolean checkSchemaURI(String schemaURI){
+		boolean found = false;
+
+		if (schemaURI != null) {
+			schemaURI = normalize(schemaURI); 
+			if(schemaURI.equals(normalize(wsdlUrl_)))return false;
+			Enumeration<String> e = schemaURI_.elements();
+			while(e.hasMoreElements()){
+				String uri = (String)e.nextElement();	
+				if(schemaURI.equals(uri)){ 
+					found = true;
+					break;
+				}	
+			}
+	
+			if (!found){
+				schemaURI_.addElement(schemaURI);
+			}
+		}
+		return found;
+
+	}
+
+	private static String normalize(String uri )
+	{
+		try {
+			String encodedURI = URIEncoder.encode(uri,"UTF-8"); //$NON-NLS-1$
+			URI normalizedURI = new URI(encodedURI);
+			normalizedURI = normalizedURI.normalize();
+			return normalizedURI.toString();
+		} catch (URISyntaxException e) {
+			return uri;
+		} catch (UnsupportedEncodingException e) {
+			return uri;
+		}
+	}
+
+	private final static void gatherSchemaDirective(XSDSchema xsdSchema, String xsdSchemaURL)
+	{
+		if (xsdSchema != null)
+		{
+			EList<XSDSchemaContent> xsdSchemaContents = xsdSchema.getContents();
+			for (Iterator<XSDSchemaContent> it = xsdSchemaContents.iterator(); it.hasNext();)
+			{
+				Object content = it.next();
+				if (content instanceof XSDSchemaDirective)
+				{
+					XSDSchemaDirective xsdSchemaDirective = (XSDSchemaDirective)content;
+					StringBuffer xsdSchemaDirectiveURL = new StringBuffer();
+					String xsdSchemaDirectiveLocation = xsdSchemaDirective.getSchemaLocation();
+					if (xsdSchemaDirectiveLocation != null && xsdSchemaDirectiveLocation.indexOf(':') == -1 && xsdSchemaURL != null && xsdSchemaURL.indexOf(':') != -1)
+					{
+						// relative URL
+						int index = xsdSchemaURL.lastIndexOf('/');
+						if (index != -1)
+							xsdSchemaDirectiveURL.append(xsdSchemaURL.substring(0, index+1));
+						else
+						{
+							xsdSchemaDirectiveURL.append(xsdSchemaURL);
+							xsdSchemaDirectiveURL.append('/');
+						}
+					}
+					xsdSchemaDirectiveURL.append(xsdSchemaDirectiveLocation);
+
+					//encode the URL so that Schemas with non-ASCII filenames can be resolved
+					String xsdSchemaDirectiveURLString = URLUtils.encodeURLString(xsdSchemaDirectiveURL.toString());      
+					// resolve schema directive
+					XSDSchema resolvedSchema = xsdSchemaDirective.getResolvedSchema();
+					if (resolvedSchema == null && xsdSchemaDirectiveURLString.length() > 0)
+						resolvedSchema = getSchema(xsdSchemaDirectiveURLString);
+					if (resolvedSchema != null)
+					{
+						if(!checkSchemaURI(xsdSchemaDirectiveURLString)){
+							schemaList_.addElement(resolvedSchema);
+							gatherSchemaDirective(resolvedSchema, xsdSchemaDirectiveURLString);
+						}
+					}
+				}
+			}
+		}
+	}
+
+	private final static XSDSchema getSchema(String locURI)
+	{
+		locURI = URLUtils.encodeURLString(locURI);
+		XSDSchema xsdSchema = XSDSchemaImpl.getSchemaForSchema(locURI);
+		if (xsdSchema == null)
+		{
+			@SuppressWarnings("deprecation")
+			XSDParser p = new XSDParser();
+			InputStream is = NetUtils.getURLInputStream(locURI);
+			if (is != null)
+			{
+				p.parse(is);
+				xsdSchema = p.getSchema();
+			}
+		}
+		return xsdSchema;
+	}
+
+	private final static void gatherImportedSchemas(Definition definition,Map<?, ?> imports)
+	{
+		for (Iterator<?> iterator = imports.keySet().iterator();iterator.hasNext();)
+		{
+			List<?> importList = (List<?>)imports.get(iterator.next());
+			for (int i=0;i<importList.size();i++)
+			{
+				Import imp = (Import)importList.get(i);
+				StringBuffer locURI = new StringBuffer(imp.getLocationURI());
+				if (!Validator.validateURL(locURI.toString()))
+				{
+					String base = definition.getDocumentBaseURI();
+					locURI.insert(0,base.substring(0,base.lastIndexOf('/')+1));
+				}
+				try
+				{
+					URL tryURL = new URL ( locURI.toString());
+					Definition importDef = readWSDLURL( tryURL );
+					gatherSchemas(importDef, locURI.toString());
+				}
+				catch (WSDLException e)
+				{
+					// May be an XSD file.
+					gatherSchema(locURI.toString());
+				} catch (MalformedURLException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+	}
+
+	private final static void gatherSchema(String locURI)
+	{
+		XSDSchema xsdSchema = getSchema(locURI);
+		if (xsdSchema != null)
+		{
+			schemaList_.addElement(xsdSchema);
+			gatherSchemaDirective(xsdSchema, locURI);
+		}
+	}
+
+	private static XSDSchema findFirstSchemaWithPartNameAsChild ( String partName ) {
+		for (Iterator<XSDSchema> schemaIter = schemaList_.iterator(); schemaIter.hasNext(); ) {
+			XSDSchema schema = schemaIter.next();
+			DOMBuilder domBuilder = new DOMBuilder();
+			org.jdom.Element jdomSchemaElement = domBuilder.build(schema.getElement());
+			List<?> kids = jdomSchemaElement.getChildren();
+			for (Iterator<?> kidIter = kids.iterator(); kidIter.hasNext(); ) {
+				Object kid = kidIter.next();
+				if (kid instanceof org.jdom.Element) {
+					org.jdom.Element kidElement = (org.jdom.Element) kid;
+					if (kidElement.getAttribute("name") != null) { //$NON-NLS-1$
+						if (kidElement.getAttributeValue("name").equals(partName)) { //$NON-NLS-1$
+							return schema;
+						}
+					}
+				}
+			}
+		}
+		return null;
+	}
+	
+	private static org.jdom.Element findFirstElementWithPartNameInSchema( XSDSchema schema, String partName ) {
+		DOMBuilder domBuilder = new DOMBuilder();
+		org.jdom.Element jdomSchemaElement = domBuilder.build(schema.getElement());
+		List<?> kids = jdomSchemaElement.getChildren();
+		for (Iterator<?> kidIter = kids.iterator(); kidIter.hasNext(); ) {
+			Object kid = kidIter.next();
+			if (kid instanceof org.jdom.Element) {
+				org.jdom.Element kidElement = (org.jdom.Element) kid;
+				if (kidElement.getAttribute("name") != null) { //$NON-NLS-1$
+					if (kidElement.getAttributeValue("name").equals(partName)) { //$NON-NLS-1$
+						return kidElement;
+					}
+				}
+			}
+		}
+		return null;
+	}
+
+	private static String startProcessingPartXML ( Definition wsdlDefinition, String partName, String partUri ) {
+		
+		XSDSchema schema = findFirstSchemaWithPartNameAsChild(partName);
+		DOMBuilder domBuilder = new DOMBuilder();
+		org.jdom.Element jdomSchemaElement = domBuilder.build(schema.getElement());
+		
+		org.jdom.Element jdomElement = findFirstElementWithPartNameInSchema(schema, partName);
+		
+		String typeAttr = jdomElement.getAttributeValue("type"); //$NON-NLS-1$
+		String nsprefix = null;
+		String nstypename = typeAttr;
+		if (typeAttr.indexOf(':') > 0) {
+			nsprefix = typeAttr.substring(0, typeAttr.indexOf(':'));
+			nstypename = typeAttr.substring(typeAttr.indexOf(':') + 1, typeAttr.length());
+		}
+		
+		String uri = schema.getTargetNamespace();
+		if (nsprefix != null && !nsprefix.equalsIgnoreCase("tns")) { //$NON-NLS-1$
+			uri = getNSURI(nsprefix, wsdlDefinition);
+		}
+
+		StringBuffer buf = new StringBuffer();
+
+		if (nsprefix != null && !nsprefix.equalsIgnoreCase("tns")) { //$NON-NLS-1$
+			if (schema.getTargetNamespace().equals(uri)) {
+				// cool, we're good
+				buf.append(createXMLForJDOMElement2( jdomSchemaElement, jdomElement ));
+			} else {
+				XSDSchema importXSD = getSchemaForNamespace(uri);
+				if (importXSD != null) {
+					importXSD.updateElement(true);
+					org.jdom.Element jdomSchemaElement2 = domBuilder.build(importXSD.getElement());
+					Element child = 
+							jdomSchemaElement2.getChild(nstypename);
+					buf.append(createXMLForJDOMElement2( jdomSchemaElement2, child ));
+				}
+			}
+		} else {
+			buf.append(createXMLForJDOMElement2( jdomSchemaElement, jdomElement ));
+		}
+
+		return buf.toString();
+	}
+
+	private static String startProcessingPartXML ( Definition wsdlDefinition, Part part ) {
+		DOMBuilder domBuilder = new DOMBuilder();
+		WSDLPartsToXSDTypeMapper mapper = new WSDLPartsToXSDTypeMapper();
+		mapper.addSchemas(schemaList_);
+		XSDNamedComponent xsdComponent = mapper.getXSDTypeFromSchema(part);
+		xsdComponent.updateElement(true);
+		
+		XSDSchema schema = xsdComponent.getSchema();
+		schema.updateElement(true);
+
+		if (!schema.getTargetNamespace().equals(FragmentConstants.NS_URI_CURRENT_SCHEMA_XSD)) {
+			rootIsQualified_ = true;
+			rootURI_ = schema.getTargetNamespace();
+		}
+		
+		org.jdom.Element jdomSchemaElement = domBuilder.build(schema.getElement());
+		org.jdom.Element jdomElement = domBuilder.build(xsdComponent.getElement());
+		
+		String typeAttr = xsdComponent.getElement().getAttribute("type"); //$NON-NLS-1$
+		String nsprefix = null;
+		String nstypename = typeAttr;
+		if (typeAttr.indexOf(':') > 0) {
+			nsprefix = typeAttr.substring(0, typeAttr.indexOf(':'));
+			nstypename = typeAttr.substring(typeAttr.indexOf(':') + 1, typeAttr.length());
+		}
+		
+		String uri = schema.getTargetNamespace();
+		if (nsprefix != null && !nsprefix.equalsIgnoreCase("tns")) { //$NON-NLS-1$
+			uri = getNSURI(nsprefix, wsdlDefinition);
+		}
+
+		StringBuffer buf = new StringBuffer();
+
+		if (nsprefix != null && !nsprefix.equalsIgnoreCase("tns")) { //$NON-NLS-1$
+			if (schema.getTargetNamespace().equals(uri)) {
+				// cool, we're good
+				org.jdom.Element jdomSchemaElement2 = domBuilder.build(xsdComponent.getElement());
+				buf.append(createXMLForJDOMElement2( jdomSchemaElement, jdomSchemaElement2 ));
+			} else {
+				XSDSchema importXSD = getSchemaForNamespace(uri);
+				if (importXSD != null) {
+					importXSD.updateElement(true);
+					org.jdom.Element jdomSchemaElement2 = domBuilder.build(importXSD.getElement());
+					Element child = 
+							jdomSchemaElement2.getChild(nstypename);
+					buf.append(createXMLForJDOMElement2( jdomSchemaElement2, child ));
+				}
+			}
+		} else {
+			buf.append(createXMLForJDOMElement2( jdomSchemaElement, jdomElement ));
+		}
+
+		return buf.toString();
+	}
+	
+	private static org.jdom.Element findJDOMTypeInSchema ( org.jdom.Element schemaElement, String typeName ) {
+		if (schemaElement != null) {
+			String nstypename = null;
+			if (typeName.indexOf(':') > -1) {
+				nstypename = typeName.substring(typeName.indexOf(':') + 1, typeName.length());
+			} else {
+				nstypename = typeName;
+			}
+			List<?> kids = schemaElement.getChildren();
+			for (Iterator<?> kidsIter = kids.iterator(); kidsIter.hasNext(); ) {
+				Object kid = kidsIter.next();
+				if (kid instanceof org.jdom.Element) {
+					org.jdom.Element kidelement = (org.jdom.Element)kid;
+					if (kidelement.getName().equals("complexType")) { //$NON-NLS-1$
+						if (kidelement.getAttributeValue("name").equals(nstypename)) //$NON-NLS-1$
+							return kidelement;
+					}
+					if (kidelement.getName().equals("attribute")) { //$NON-NLS-1$
+						if (kidelement.getAttributeValue("name").equals(nstypename)) //$NON-NLS-1$
+							return kidelement;
+					}
+				}
+			}
+		}
+		return null;
+	}
+
+	private static org.jdom.Element findJDOMTypeInSchemaByNameAttr ( org.jdom.Element schemaElement, String name ) {
+		if (schemaElement != null) {
+			List<?> kids = schemaElement.getChildren();
+			for (Iterator<?> kidsIter = kids.iterator(); kidsIter.hasNext(); ) {
+				Object kid = kidsIter.next();
+				if (kid instanceof org.jdom.Element) {
+					org.jdom.Element kidelement = (org.jdom.Element)kid;
+					if (kidelement.getName().equals("complexType")) { //$NON-NLS-1$
+						if (kidelement.getAttributeValue("name").equals(name)) //$NON-NLS-1$
+							return kidelement;
+					}
+					if (kidelement.getName().equals("attribute")) { //$NON-NLS-1$
+						if (kidelement.getAttributeValue("name").equals(name)) //$NON-NLS-1$
+							return kidelement;
+					}
+					if (kidelement.getName().equals("element")) { //$NON-NLS-1$
+						if (kidelement.getAttributeValue("name").equals(name)) //$NON-NLS-1$
+							return kidelement;
+					}
+				}
+			}
+		}
+		return null;
+	}
+
+	private static org.jdom.Element findJDOMElementInSchema ( org.jdom.Element schemaElement, String typeName ) {
+		if (schemaElement != null) {
+			List<?> kids = schemaElement.getChildren();
+			for (Iterator<?> kidsIter = kids.iterator(); kidsIter.hasNext(); ) {
+				Object kid = kidsIter.next();
+				if (kid instanceof org.jdom.Element) {
+					org.jdom.Element kidelement = (org.jdom.Element)kid;
+					if (kidelement.getName().equals("element")) { //$NON-NLS-1$
+						String attrvalue = kidelement.getAttributeValue("type"); //$NON-NLS-1$
+						if (attrvalue != null && attrvalue.equals(typeName)) {
+							kidelement = findJDOMTypeInSchema(schemaElement, typeName);
+							return kidelement;
+						}
+					}
+				}
+			}
+		}
+		return null;
+	}
+	
+	private static org.jdom.Element findJDOMElementInSchemaByName ( org.jdom.Element schemaElement, String typeName ) {
+		if (schemaElement != null) {
+			List<?> kids = schemaElement.getChildren();
+			for (Iterator<?> kidsIter = kids.iterator(); kidsIter.hasNext(); ) {
+				Object kid = kidsIter.next();
+				if (kid instanceof org.jdom.Element) {
+					org.jdom.Element kidelement = (org.jdom.Element)kid;
+					if (kidelement.getName().equals("element")) { //$NON-NLS-1$
+						String attrvalue = kidelement.getAttributeValue("name"); //$NON-NLS-1$
+						if (attrvalue != null && attrvalue.equals(typeName)) {
+							String elemType = kidelement.getAttributeValue("type"); //$NON-NLS-1$
+							if (elemType != null) {
+								String nsprefix = elemType.substring(0, elemType.indexOf(':'));
+								String testUri = getURIForNamespacePrefix(nsprefix);
+								XSDSchema importXSD = getSchemaForNamespace(testUri);
+								if (importXSD != null) {
+									DOMBuilder domBuilder = new DOMBuilder();
+									importXSD.updateElement(true);
+									org.jdom.Element importXSDSchema = domBuilder.build(importXSD.getElement());
+									org.jdom.Element element2 = findJDOMTypeInSchema(importXSDSchema, elemType);
+									if (element2 != null) {
+										return element2;
+									} else {
+										element2 = findJDOMElementInSchema(importXSDSchema, elemType);
+										if (element2 != null) {
+											return element2;
+										}
+									}
+								}
+							}
+						}
+					}
+				}
+			}
+		}
+		return null;
+	}
+
+	private static String handleAttributes ( org.jdom.Element element ) {
+		StringBuffer buf = new StringBuffer();
+		List<?> kids = element.getChildren();
+		boolean isQualified = false;
+		for (Iterator<?> kidIter = kids.iterator(); kidIter.hasNext(); ) {
+			Element kid = (Element) kidIter.next();
+			if (kid.getName().equals("attribute") ) {//$NON-NLS-1$
+// 				<xs:attribute ref="ns3:C" use="required" />
+				if (kid.getAttribute("ref") != null) {//$NON-NLS-1$
+					String elemType = kid.getAttributeValue("ref");//$NON-NLS-1$
+					String nsprefix = elemType.substring(0, elemType.indexOf(':'));
+					String typename = elemType.substring(elemType.indexOf(':') + 1, elemType.length());
+					if (elemType.indexOf(':') > -1) {
+						if (!(elemType.startsWith("xs:") || elemType.startsWith("xsd:"))) //$NON-NLS-1$ //$NON-NLS-2$
+							isQualified = true;
+					}
+
+					String testUri = getURIForNamespacePrefix(nsprefix);
+					XSDSchema importXSD = getSchemaForNamespace(testUri);
+					if (importXSD != null) {
+						DOMBuilder domBuilder = new DOMBuilder();
+						importXSD.updateElement(true);
+						org.jdom.Element importXSDSchema = domBuilder.build(importXSD.getElement());
+						org.jdom.Element element2 = findJDOMTypeInSchema(importXSDSchema, typename);
+						if (element2 != null) {
+							element = element2;
+						} else {
+							element2 = findJDOMElementInSchema(importXSDSchema, typename);
+							if (element2 != null) {
+								element = element2;
+							}
+						}
+						if (element != null) {
+							if (isQualified) {
+								String prefix = makePrefixFromURI(testUri);
+								// xmlns:ns1="http://schemas.xmlsoap.org/soap/http"
+								if (!namespacesAndPrefixes_.containsKey(prefix)) {
+									buf.append(" xmlns:" + prefix + "=\"" + testUri + "\"");  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+									namespacesAndPrefixes_.put(prefix, testUri);
+								}
+								buf.append(' ' + prefix + ':');
+							}
+							String name = element.getAttributeValue("name"); //$NON-NLS-1$
+							buf.append(name + "=\"?\" "); //$NON-NLS-1$
+						}
+					}
+				}
+			}
+		}
+		return buf.toString();
+	}
+	
+	private static boolean namespacePrefixListContainsURI ( String uri ) {
+		if (namespacesAndPrefixes_ != null) {
+			if (namespacesAndPrefixes_.containsValue(uri)) {
+				return true;
+			}
+		}
+		return false;
+	}
+	
+	private static String makePrefixFromURI ( String uri ) {
+		
+		if (namespacePrefixListContainsURI(uri)) {
+			Iterator<Entry<String, String>> iter = namespacesAndPrefixes_.entrySet().iterator();
+			while (iter.hasNext()) {
+				Map.Entry<String, String> entry = iter.next();
+				if (entry.getValue().equals(uri)) {
+					return entry.getKey();
+				}
+			}
+		}
+		
+		String tnsprefix = uri.substring(uri.indexOf("://") + 3, uri.length()); //$NON-NLS-1$
+		if (tnsprefix.length() > 4) {
+			if (tnsprefix.endsWith("/")) { //$NON-NLS-1$
+				tnsprefix = tnsprefix.substring(0, tnsprefix.length() - 1);
+			}
+			if (tnsprefix.lastIndexOf('/') > -1) {
+				tnsprefix = tnsprefix.substring(tnsprefix.lastIndexOf('/') + 1, tnsprefix.length());
+			}
+			if (tnsprefix.length() > 4) {
+				tnsprefix = tnsprefix.substring(0, 4);
+			}
+			tnsprefix = tnsprefix.toLowerCase();
+			
+			if (namespacesAndPrefixes_.containsKey(tnsprefix)) {
+				int i = 1;
+				String test = tnsprefix + i;
+				while (namespacesAndPrefixes_.containsKey(test)) {
+					i++;
+					test = tnsprefix + i;
+				}
+				tnsprefix = test;
+			}
+		}
+		return tnsprefix;
+	}
+
+	private static boolean elementHasChildren ( org.jdom.Element element ) {
+		boolean rtnflag = false;
+		if (element.getChildren() != null && element.getChildren().size() > 0) {
+			List<?> kids = element.getChildren();
+			for (Iterator<?> kidIter = kids.iterator(); kidIter.hasNext(); ) {
+				Element kid = (Element) kidIter.next();
+				if (kid.getName().equals("element")) { //$NON-NLS-1$
+					rtnflag = true;
+				}
+				boolean kidflag = elementHasChildren(kid);
+				if (kidflag) 
+					rtnflag = true;
+			}
+		}
+		return rtnflag;
+	}
+	
+	private static String createXMLForJDOMElement2 ( org.jdom.Element schemaElement, org.jdom.Element element ) {
+		StringBuffer buf = new StringBuffer();
+		String nstypename = null;
+
+		String tns = null;
+		String tnsprefix = null;
+		if (schemaElement.getNamespace("tns") != null) {//$NON-NLS-1$
+			tns = schemaElement.getNamespace("tns").getURI();//$NON-NLS-1$
+			tnsprefix = makePrefixFromURI(tns);
+		}
+		
+		boolean isQualified = false;
+
+		if (element.getAttribute("name") != null) {//$NON-NLS-1$
+			nstypename = element.getAttributeValue("name");//$NON-NLS-1$
+		}
+		if (element.getAttribute("type") != null) {//$NON-NLS-1$
+			String type2FindName = element.getAttributeValue("type");//$NON-NLS-1$
+			if (type2FindName.indexOf(':') > -1) {
+				if (!(type2FindName.startsWith("xs:") || type2FindName.startsWith("xsd:"))) //$NON-NLS-1$ //$NON-NLS-2$
+					isQualified = true;
+			}
+			org.jdom.Element element2 = findJDOMTypeInSchema(schemaElement, type2FindName);
+			if (element2 != null) {
+				element = element2;
+				if (element.getParentElement() != null) {
+					org.jdom.Element parent = element.getParentElement();
+					if (parent.getNamespace("tns") != null) {//$NON-NLS-1$
+						tns = parent.getNamespace("tns").getURI();//$NON-NLS-1$
+						tnsprefix = makePrefixFromURI(tns);
+					}
+				}
+			}
+		}
+		if (element.getAttribute("ref") != null) {//$NON-NLS-1$
+			String ref2FindName = element.getAttributeValue("ref");//$NON-NLS-1$
+			if (ref2FindName.indexOf(':') > -1) {
+				if (!(ref2FindName.startsWith("xs:") || ref2FindName.startsWith("xsd:"))) //$NON-NLS-1$ //$NON-NLS-2$
+					isQualified = true;
+			}
+			org.jdom.Element element2 = findJDOMTypeInSchema(schemaElement, ref2FindName);
+			if (element2 != null) {
+				element = element2;
+				if (element.getParentElement() != null) {
+					org.jdom.Element parent = element.getParentElement();
+					if (parent.getNamespace("tns") != null) {//$NON-NLS-1$
+						tns = parent.getNamespace("tns").getURI();//$NON-NLS-1$
+						tnsprefix = makePrefixFromURI(tns);
+					}
+				}
+			} else {
+				element2 = findJDOMElementInSchema(schemaElement, ref2FindName);
+				if (element2 != null) {
+					element = element2;
+					if (element.getParentElement() != null) {
+						org.jdom.Element parent = element.getParentElement();
+						if (parent.getNamespace("tns") != null) {//$NON-NLS-1$
+							tns = parent.getNamespace("tns").getURI();//$NON-NLS-1$
+							tnsprefix = makePrefixFromURI(tns);
+						}
+					}
+				}
+			}
+		}
+		Integer minOccurs = 1;
+		String elemType = null;
+		
+		if (element.getAttributes().size() > 0) {
+			if (element.getAttribute("minOccurs") != null) {//$NON-NLS-1$
+				String value = element.getAttributeValue("minOccurs");//$NON-NLS-1$
+				minOccurs = Integer.decode(value);
+			}
+			if (element.getAttribute("type") != null) {//$NON-NLS-1$
+				elemType = element.getAttributeValue("type");//$NON-NLS-1$
+				String nsprefix = elemType.substring(0, elemType.indexOf(':'));
+				String testUri = getURIfromSchemaPrefix(element, nsprefix);
+				if (elemType.indexOf(':') > -1) {
+					if (!(elemType.startsWith("xs:") || elemType.startsWith("xsd:"))){ //$NON-NLS-1$ //$NON-NLS-2$
+						isQualified = true;
+					}
+				}
+				XSDSchema importXSD = getSchemaForNamespace(testUri);
+				if (importXSD != null) {
+					DOMBuilder domBuilder = new DOMBuilder();
+					importXSD.updateElement(true);
+					org.jdom.Element importXSDSchema = domBuilder.build(importXSD.getElement());
+					org.jdom.Element element2 = findJDOMTypeInSchema(importXSDSchema, elemType);
+					if (element2 != null) {
+						element = element2;
+					} else {
+						element2 = findJDOMElementInSchema(importXSDSchema, elemType);
+						if (element2 != null) {
+							element = element2;
+						}
+					}
+				}
+			}
+			if (element.getAttribute("ref") != null) {//$NON-NLS-1$
+				elemType = element.getAttributeValue("ref");//$NON-NLS-1$
+				String nsprefix = elemType.substring(0, elemType.indexOf(':'));
+				String typename = elemType.substring(elemType.indexOf(':') + 1, elemType.length());
+				nstypename = typename;
+
+				String testUri = getURIfromSchemaPrefix(element, nsprefix);
+				if (elemType.indexOf(':') > -1) {
+					if (!elemType.startsWith("xs:")) { //$NON-NLS-1$
+						isQualified = true;
+						tns = testUri;
+						tnsprefix = makePrefixFromURI(tns);
+					}
+				}
+				XSDSchema importXSD = getSchemaForNamespace(testUri);
+				if (importXSD != null) {
+					DOMBuilder domBuilder = new DOMBuilder();
+					importXSD.updateElement(true);
+					org.jdom.Element importXSDSchema = domBuilder.build(importXSD.getElement());
+					org.jdom.Element element2 = findJDOMTypeInSchema(importXSDSchema, elemType);
+					if (element2 != null) {
+						element = element2;
+					} else {
+						element2 = findJDOMElementInSchema(importXSDSchema, elemType);
+						if (element2 != null) {
+							element = element2;
+						} else {
+							element2 = findJDOMElementInSchemaByName(importXSDSchema, nstypename);
+							if (element2 != null) {
+								element = element2;
+							}
+						}
+					}
+				}
+			}
+		}
+
+		boolean hasKids = false;
+		if (elementHasChildren(element)) {
+			hasKids = true;
+		}
+		
+		boolean isSimpleType = false;
+		if (elemType != null && isTypeBaseXSDOrSimple(tns, elemType)) {
+			isSimpleType = true;
+		}
+
+		boolean includeTNSInRoot = false;
+		if (rootIsQualified_ && !isQualified) {
+			includeTNSInRoot = true;
+			isQualified = true;
+			tnsprefix = "tns"; //$NON-NLS-1$
+		} else if (isQualified) {
+			rootIsQualified_ = false;
+		}
+		
+		boolean isSequence = element.getName().equals("sequence"); //$NON-NLS-1$
+		if (!isSequence) {
+			// open tag
+			if (minOccurs.intValue() == 0) {
+				buf.append("<!-- optional -->\n");//$NON-NLS-1$
+			}
+			buf.append('<');
+			if (isQualified) {
+				buf.append(tnsprefix + ':');
+			}
+			
+			buf.append(nstypename);
+			String attributes = handleAttributes(element);
+			if (attributes != null && attributes.trim().length() > 0) {
+				buf.append(' ');
+				buf.append(attributes);
+			}
+			
+			if (isQualified) {
+				// xmlns:ns1="http://schemas.xmlsoap.org/soap/http"
+				if (includeTNSInRoot && !namespacePrefixListContainsURI(rootURI_)) {
+					buf.append(" xmlns:tns=\"" + rootURI_ + "\""); //$NON-NLS-1$ //$NON-NLS-2$
+					namespacesAndPrefixes_.put(tnsprefix, rootURI_);
+				}
+				else if (!namespacesAndPrefixes_.containsKey(tnsprefix)) {
+					buf.append(" xmlns:" + tnsprefix + "=\"" + tns + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+					namespacesAndPrefixes_.put(tnsprefix, tns);
+				}
+			}
+
+			
+			if (hasKids || isSimpleType)
+				buf.append(">"); //$NON-NLS-1$
+			else
+				buf.append("/>");//$NON-NLS-1$
+		}
+
+		if (hasKids) {
+			if (!isSequence) {
+				buf.append('\n');
+			}
+			List<?> kids = element.getChildren();
+			for (Iterator<?> kidIter = kids.iterator(); kidIter.hasNext(); ) {
+				Element kid = (Element) kidIter.next();
+				if (kid.getName().equals("complexType") || kid.getName().equals("sequence")) {//$NON-NLS-1$//$NON-NLS-2$
+					List<?> innerkids = kid.getChildren();
+					for (Iterator<?> kidIter2 = innerkids.iterator(); kidIter2.hasNext(); ) {
+						Element innerkid = (Element) kidIter2.next();
+						String out = createXMLForJDOMElement2 ( schemaElement, innerkid );
+						buf.append(out);
+					}
+				} else if (kid.getName().equals("element")) {//$NON-NLS-1$
+					String out = createXMLForJDOMElement2 (schemaElement, kid);
+					buf.append(out);
+				}
+			}
+		}
+
+		if (!isSequence && ( hasKids || isSimpleType )) {
+			// add ? for value 
+			if (!hasKids || isSimpleType)
+				buf.append('?');
+			
+			// close tag
+			buf.append("</");//$NON-NLS-1$
+			
+			if (isQualified) {
+				buf.append(tnsprefix + ':');
+			}
+			buf.append(nstypename);
+			buf.append(">\n"); //$NON-NLS-1$
+		}
+		
+		return buf.toString();
+	}
+	
+	private static HashMap<String, String> getDefinitionNamespaces ( Definition wsdlDefinition) {
+		HashMap<String, String> namespaceMap = new HashMap<String, String>();
+		namespaceMap.put(SOAP_NS_URI, SOAP_PREFIX);
+		namespaceMap.put(SOAP12_ENVELOPE_NS_URI, SOAP12_PREFIX);
+		namespaceMap.put("http://www.w3.org/2001/XMLSchema-instance", "xsi");  //$NON-NLS-1$//$NON-NLS-2$
+		namespaceMap.put("http://www.w3.org/2001/XMLSchema", "xsd");  //$NON-NLS-1$//$NON-NLS-2$
+
+		Map<?,?> namespaces = wsdlDefinition.getNamespaces();
+		Set<?> namespaceKeys = namespaces.keySet();
+		int i = 1;
+		for ( Iterator<?> it = namespaceKeys.iterator(); it.hasNext();  ) {
+			String prefix = (String) it.next();
+			String url = wsdlDefinition.getNamespace(prefix);
+			if (!namespaceMap.containsKey(url)) {
+				String newprefix = "ns" + i++; //$NON-NLS-1$
+				namespaceMap.put(url, newprefix);
+			}
+		}
+		return namespaceMap;
+	}
+
+	private static String getNSURI ( String inPrefix, Definition wsdlDefinition) {
+		HashMap<String, String> map = getDefinitionNamespaces(wsdlDefinition);
+		if (map.containsValue(inPrefix)) {
+			for (Iterator<Entry<String, String>> mapIter = map.entrySet().iterator(); mapIter.hasNext(); ) {
+				Map.Entry<String, String> test = (Entry<String, String>) mapIter.next();
+				if (test.getValue().equals(inPrefix)) 
+					return test.getKey();
+			}
+		}
+		return null;
+	}
+
+
+
+	private static String getURIfromSchemaPrefix(Element el, String prefix) {
+		Element e = el;
+		while (e.getParentElement() != null) {
+			e = e.getParentElement();
+		}
+		if (e.getNamespace(prefix) != null) {
+			return e.getNamespace(prefix).getURI();
+		}
+		return null;
+	}
+
+	private static boolean isTypeBaseXSDOrSimple ( String uri, String type ) {
+		
+		if (uri != null) {
+			XSDSchema schema = getSchemaForNamespace(uri);
+			DOMBuilder domBuilder = new DOMBuilder();
+			schema.updateElement(true);
+			org.jdom.Element importXSDSchema = domBuilder.build(schema.getElement());
+			if (type.indexOf(':') > -1) {
+				String typename = type.substring(type.indexOf(':') + 1, type.length());
+				org.jdom.Element element = findJDOMTypeInSchemaByNameAttr(importXSDSchema, typename);
+				if (element != null) {
+					if (element.getAttribute("type") != null) { //$NON-NLS-1$
+						type = element.getAttributeValue("type"); //$NON-NLS-1$
+					}
+				}
+			}
+		}
+		// typically the type starts with a namespace prefix, so
+		// we want to compare the end of the string with the actual
+		// type name
+		if (type.endsWith(STRING_TYPE_NAME) || 
+				type.endsWith(BOOLEAN_TYPE_NAME) || 
+				type.endsWith(DECIMAL_TYPE_NAME) ||
+				type.endsWith(INT_TYPE_NAME) || 
+				type.endsWith(DOUBLE_TYPE_NAME) || 
+				type.endsWith(FLOAT_TYPE_NAME) ||
+				type.endsWith(DURATION_TYPE_NAME) || 
+				type.endsWith(DATE_TYPE_NAME) || 
+				type.endsWith(TIME_TYPE_NAME) ||
+				type.endsWith(DATETIME_TYPE_NAME) ||
+				type.endsWith(ANYURI_TYPE_NAME) ||
+				type.endsWith(BASE64BINARY_TYPE_NAME) ||
+				type.endsWith(GDAY_TYPE_NAME) ||
+				type.endsWith(GMONTH_TYPE_NAME) ||
+				type.endsWith(GMONTHDAY_TYPE_NAME) ||
+				type.endsWith(GYEAR_TYPE_NAME) ||
+				type.endsWith(GYEARMONTH_TYPE_NAME) ||
+				type.endsWith(HEXBINARY_TYPE_NAME) ||
+				type.endsWith(NOTATION_TYPE_NAME) ||
+				type.endsWith(PRECISION_DECIMAL_TYPE_NAME)
+				) {
+			return true;
+		} else if (type.contains(SIMPLE_TYPE_NAME)) {
+			return true;
+		}
+		return false;
+	}
+}


Property changes on: branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/SchemaUtils.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/URIEncoder.java
===================================================================
--- branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/URIEncoder.java	                        (rev 0)
+++ branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/URIEncoder.java	2011-05-10 16:54:01 UTC (rev 31190)
@@ -0,0 +1,204 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - Initial API and implementation
+ *     Jens Lukowski/Innoopract - initial renaming/restructuring
+ *******************************************************************************/
+package org.jboss.tools.ws.ui.utils;
+
+import java.io.BufferedWriter;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.util.BitSet;
+
+/**
+ *  This class is a modified version of java.lang.URLEncoder.
+ */
+public class URIEncoder 
+{
+  static BitSet dontNeedEncoding;
+  static final int caseDiff = ('a' - 'A');
+  static String dfltEncName = null;
+  
+
+  static 
+  {            
+	  dontNeedEncoding = new BitSet(256);
+	  int i;
+	  for (i = 'a'; i <= 'z'; i++) 
+    {
+	    dontNeedEncoding.set(i);
+	  }
+	  for (i = 'A'; i <= 'Z'; i++) 
+    {
+	    dontNeedEncoding.set(i);
+	  }
+	  for (i = '0'; i <= '9'; i++) 
+    {
+	    dontNeedEncoding.set(i);
+	  }
+
+	  //dontNeedEncoding.set(' '); // cs.. removed so that space character will be replaced by %20
+	  dontNeedEncoding.set('-');
+	  dontNeedEncoding.set('_');
+	  dontNeedEncoding.set('.');
+	  dontNeedEncoding.set('*');
+	  dontNeedEncoding.set(':');   // cs.. added 
+	  dontNeedEncoding.set('/');   // cs.. added so that slashes don't get encoded as %2F
+
+  	// dfltEncName = (String)AccessController.doPrivileged(new GetPropertyAction("file.encoding"));
+  	// As discussed with Sandy, we should encode URIs with UTF8
+   dfltEncName = "UTF8"; //$NON-NLS-1$
+    //System.out.println("dfltEncName " + dfltEncName);
+   }
+
+  /**
+   * You can't call the constructor.
+   */
+  private URIEncoder() { }
+
+  /**
+   * Translates a string into <code>x-www-form-urlencoded</code>
+   * format. This method uses the platform's default encoding
+   * as the encoding scheme to obtain the bytes for unsafe characters.
+   *
+   * @param   s   <code>String</code> to be translated.
+   * @deprecated The resulting string may vary depending on the platform's
+   *             default encoding. Instead, use the encode(String,String)
+   *             method to specify the encoding.
+   * @return  the translated <code>String</code>.
+   */
+  public static String encode(String s) 
+  {
+	  String str = null;
+	  try 
+    {
+	    str = encode(s, dfltEncName);
+	  } 
+    catch (UnsupportedEncodingException e) 
+    {
+	    // The system should always have the platform default
+	  }
+	  return str;
+  }
+
+  /**
+   * Translates a string into <code>application/x-www-form-urlencoded</code>
+   * format using a specific encoding scheme. This method uses the
+   * supplied encoding scheme to obtain the bytes for unsafe
+   * characters.
+   * <p>
+   * <em><strong>Note:</strong> The <a href=
+   * "http://www.w3.org/TR/html40/appendix/notes.html#non-ascii-chars">
+   * World Wide Web Consortium Recommendation</a> states that
+   * UTF-8 should be used. Not doing so may introduce
+   * incompatibilites.</em>
+   *
+   * @param   s   <code>String</code> to be translated.
+   * @param   enc   The name of a supported 
+   *    <a href="../lang/package-summary.html#charenc">character
+   *    encoding</a>.
+   * @return  the translated <code>String</code>.
+   * @exception  UnsupportedEncodingException
+   *             If the named encoding is not supported
+   * @see java.net.URLDecoder#decode(java.lang.String, java.lang.String)
+   */
+  public static String encode(String s, String enc) throws UnsupportedEncodingException 
+  {
+	  boolean needToChange = false;
+	  boolean wroteUnencodedChar = false; 
+	  int maxBytesPerChar = 10; // rather arbitrary limit, but safe for now
+    StringBuffer out = new StringBuffer(s.length());
+	  ByteArrayOutputStream buf = new ByteArrayOutputStream(maxBytesPerChar);
+	  BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(buf, enc));
+
+	  for (int i = 0; i < s.length(); i++) 
+    {
+	    int c = s.charAt(i);
+	    //System.out.println("Examining character: " + c);
+	    if (dontNeedEncoding.get(c))
+      {
+		   //if (c == ' ')
+       //{
+		   //  c = '+';
+		   //  needToChange = true;
+		   //}
+		   //System.out.println("Storing: " + c);
+		   out.append((char)c);
+		   wroteUnencodedChar = true;
+	    }
+      else
+      {
+		    // convert to external encoding before hex conversion
+		    try
+        {
+		      if (wroteUnencodedChar) 
+          { // Fix for 4407610
+		    	  writer = new BufferedWriter(new OutputStreamWriter(buf, enc));
+			      wroteUnencodedChar = false;
+		      }
+		      writer.write(c);
+		        
+		      // If this character represents the start of a Unicode
+		      // surrogate pair, then pass in two characters. It's not
+		      // clear what should be done if a bytes reserved in the 
+		      // surrogate pairs range occurs outside of a legal
+		      // surrogate pair. For now, just treat it as if it were 
+		      // any other character.
+		      // 
+		      if (c >= 0xD800 && c <= 0xDBFF) 
+          {
+			      //  System.out.println(Integer.toHexString(c) + " is high surrogate");			      
+			      if ( (i+1) < s.length()) 
+            {
+			        int d = s.charAt(i+1);
+			        // System.out.println("\tExamining " + Integer.toHexString(d));			      
+			        if (d >= 0xDC00 && d <= 0xDFFF) 
+              {
+				        // System.out.println("\t" + Integer.toHexString(d) + " is low surrogate");				
+				        writer.write(d);
+				        i++;
+			        }
+			      }
+		      }
+		      writer.flush();
+		    } 
+        catch(IOException e) 
+        {
+		      buf.reset();
+		      continue;
+		    }
+		    byte[] ba = buf.toByteArray();
+
+		    for (int j = 0; j < ba.length; j++) 
+        {
+		      out.append('%');
+		      char ch = Character.forDigit((ba[j] >> 4) & 0xF, 16);
+		      // converting to use uppercase letter as part of
+		      // the hex value if ch is a letter.
+		      if (Character.isLetter(ch)) 
+          {
+			      ch -= caseDiff;
+		      }
+		      out.append(ch);
+		      ch = Character.forDigit(ba[j] & 0xF, 16);
+		      if (Character.isLetter(ch)) 
+          {
+			      ch -= caseDiff;
+		      }
+		      out.append(ch);
+		    }
+		    buf.reset();
+		    needToChange = true;
+	    }
+	  }
+	  return (needToChange? out.toString() : s);
+  }
+}


Property changes on: branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/URIEncoder.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/URLUtils.java
===================================================================
--- branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/URLUtils.java	                        (rev 0)
+++ branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/URLUtils.java	2011-05-10 16:54:01 UTC (rev 31190)
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug      Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20081119   255374 mahutch at ca.ibm.com - Mark Hutchinson
+ *******************************************************************************/
+package org.jboss.tools.ws.ui.utils;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+
+/**
+ * This class contains utility methods for managing URLs
+ * as used by the Web Services Explorer Web application.
+ * @author cbrealey at ca.ibm.com
+ */
+public final class URLUtils
+{
+	/**
+	 * Objects of this class should not be constructed.
+	 */
+	private URLUtils ()
+	{
+	}
+
+	/**
+	 * UTF-8
+	 */
+	public static final String UTF8 = "UTF-8"; //$NON-NLS-1$
+
+	/**
+	 * Equivalent to {@link #encode(String,String)}
+	 * with second parameter set to the "UTF-8" encoding.
+	 * @param s The string to encode.
+	 * @return The encoded string.
+	 */
+	public static String encode(String s)
+	{
+		return encode(s,UTF8);
+	}
+	
+	/**
+	 * Equivalent to {@link URLEncoder#encode(String,String)},
+	 * only throws an unchecked {@link RuntimeException} wrapped
+	 * around an {@link UnsupportedEncodingException} instead of
+	 * an {@link UnsupportedEncodingException}.
+	 * @param s The string to encode.
+	 * @param enc The encoding to use.
+	 * @return The encoded string.
+	 */
+	public static String encode(String s, String enc)
+	{
+		try
+		{
+			return URLEncoder.encode(s,enc);
+		}
+		catch (UnsupportedEncodingException e)
+		{
+			// TODO: MSG_BROKEN_VM_DOES_NOT_SUPPORT_UTF-8
+			throw new RuntimeException("%MSG_BROKEN_VM_DOES_NOT_SUPPORT_UTF-8",e); //$NON-NLS-1$
+		}
+	}
+	
+	/**
+	 * Equivalent to {@link #decode(String,String)}
+	 * with second parameter set to the "UTF-8" encoding.
+	 * @param s The string to decode.
+	 * @return The decoded string.
+	 */
+	public static String decode(String s)
+	{
+		return decode(s,UTF8);
+	}
+	
+	/**
+	 * Equivalent to {@link URLEncoder#decode(String,String)},
+	 * only throws an unchecked {@link RuntimeException} wrapped
+	 * around an {@link UnsupportedEncodingException} instead of
+	 * an {@link UnsupportedEncodingException}.
+	 * @param s The string to decode.
+	 * @param enc The encoding to use.
+	 * @return The decoded string.
+	 */
+	public static String decode(String s, String enc)
+	{
+		try
+		{
+			return URLDecoder.decode(s,enc);
+		}
+		catch (UnsupportedEncodingException e)
+		{
+			// TODO: MSG_BROKEN_VM_DOES_NOT_SUPPORT_UTF-8
+			throw new RuntimeException("%MSG_BROKEN_VM_DOES_NOT_SUPPORT_UTF-8",e); //$NON-NLS-1$
+		}
+	}
+	
+	/**
+	 * Encodes non-ASCII characters in a URL string.
+	 * @param urlString The URL string to encode 
+	 * @return The URL as an encoded string
+	 */
+	public static String encodeURLString(String urlString) {
+		try { 
+			URI uri = new URI(urlString);
+			return uri.toASCIIString();
+		} catch (Exception e) {
+			//do nothing, we will just return the original string
+		}
+		return urlString;
+	}
+}


Property changes on: branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/URLUtils.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/Validator.java
===================================================================
--- branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/Validator.java	                        (rev 0)
+++ branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/Validator.java	2011-05-10 16:54:01 UTC (rev 31190)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2006 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug      Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20060612   142290 gilberta at ca.ibm.com - Gilbert Andrews
+ *******************************************************************************/
+
+package org.jboss.tools.ws.ui.utils;
+
+public class Validator
+{
+  public static final boolean validateString(String input)
+  {
+    return ((input != null) && (input.trim().length() > 0));
+  }
+
+  public static final boolean validateURL(String input)
+  {
+	  return (input != null && input.matches("[a-zA-Z\\+\\-\\.]++:.*")); //$NON-NLS-1$
+  }
+  
+  public static final boolean validateInteger(String input)
+  {
+    try
+    {
+      Integer.parseInt(input);
+      return true;
+    }
+    catch (NumberFormatException e)
+    {
+      return false;
+    }
+  }
+}


Property changes on: branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/Validator.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/WSDLPartsToXSDTypeMapper.java
===================================================================
--- branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/WSDLPartsToXSDTypeMapper.java	                        (rev 0)
+++ branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/WSDLPartsToXSDTypeMapper.java	2011-05-10 16:54:01 UTC (rev 31190)
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.ws.ui.utils;
+
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Vector;
+import javax.wsdl.Part;
+import javax.xml.namespace.QName;
+import org.eclipse.xsd.XSDComponent;
+import org.eclipse.xsd.XSDElementDeclaration;
+import org.eclipse.xsd.XSDModelGroupDefinition;
+import org.eclipse.xsd.XSDNamedComponent;
+import org.eclipse.xsd.XSDSchema;
+import org.eclipse.xsd.XSDTypeDefinition;
+
+public class WSDLPartsToXSDTypeMapper
+{
+  private final char POUND = '#';
+  private Vector<Object> xsdSchemaList_;
+  private Hashtable<String, XSDNamedComponent> partToXSDCache_;
+
+  public WSDLPartsToXSDTypeMapper() {
+    xsdSchemaList_ = new Vector<Object>();
+    partToXSDCache_ = new Hashtable<String, XSDNamedComponent>();
+  }
+
+  public void addSchemas(Vector<?> schemaList) {
+    for (int i=0;i<schemaList.size();i++) {
+      Object schema = schemaList.elementAt(i);
+      if (schema != null)
+        xsdSchemaList_.addElement(schema);
+    }
+  }
+
+  public XSDNamedComponent getXSDType(Part part, String id) {
+    XSDNamedComponent component = getXSDTypeFromCache(id);
+    if (component != null)
+      return component;
+    component = getXSDTypeFromSchema(part);
+    if (component != null)
+      addToCache(id, component);
+    return component;
+  }
+
+  public XSDNamedComponent getXSDTypeFromCache(String id) {
+    return (XSDNamedComponent)partToXSDCache_.get(id);
+  }
+
+  public XSDNamedComponent getXSDTypeFromSchema(Part part) {
+    boolean isElementDeclaration = (part.getTypeName() == null);
+    QName qName = isElementDeclaration ? part.getElementName() : part.getTypeName();
+    return getXSDTypeFromSchema(qName.getNamespaceURI(), qName.getLocalPart(), isElementDeclaration);
+  }
+
+  public XSDNamedComponent getXSDTypeFromSchema(String namespaceURI, String localName, boolean isElementDeclaration) {
+    for (int i = 0; i < xsdSchemaList_.size(); i++) {
+      XSDSchema xsdSchema = (XSDSchema)xsdSchemaList_.elementAt(i);
+      Vector<Object> components = new Vector<Object>();
+      if (isElementDeclaration)
+        components.addAll(xsdSchema.getElementDeclarations());
+      else
+        components.addAll(xsdSchema.getTypeDefinitions());
+      for (Iterator<Object> it = components.iterator(); it.hasNext(); ) {
+        XSDNamedComponent component  = (XSDNamedComponent)it.next();
+        String compNSURI = component.getTargetNamespace();
+        String compLocalname = component.getName();
+        if (compNSURI != null && compLocalname != null && compNSURI.equals(namespaceURI) && compLocalname.equals(localName))
+          return component;
+      }
+    }
+    return null;
+  }
+
+  public XSDNamedComponent resolveXSDNamedComponent(XSDNamedComponent component)
+  {
+    if (component != null)
+    {
+      String uri = component.getURI();
+      String qname = component.getQName();
+      for (int i = 0; i < xsdSchemaList_.size(); i++)
+      {
+        XSDSchema xsdSchema = (XSDSchema)xsdSchemaList_.elementAt(i);
+        if (xsdSchema != null)
+        {
+          String targetNS = xsdSchema.getTargetNamespace();
+          if (targetNS != null && targetNS.equals(trimQName(uri, qname)))
+          {
+            XSDNamedComponent resolvedComponent = null;
+            if (component instanceof XSDTypeDefinition)
+              resolvedComponent = xsdSchema.resolveTypeDefinition(qname);
+            else if (component instanceof XSDElementDeclaration)
+              resolvedComponent = xsdSchema.resolveElementDeclaration(qname);
+            else if (component instanceof XSDModelGroupDefinition)
+              resolvedComponent = xsdSchema.resolveModelGroupDefinition(qname);
+            if (isComponentResolvable(resolvedComponent))
+              return resolvedComponent;
+          }
+        }
+      }
+    }
+    return null;
+  }
+
+  private String trimQName(String uri, String qname)
+  {
+    int index = uri.indexOf(qname);
+    if (index != -1)
+    {
+      String ns = uri.substring(0, index);
+      if (ns.charAt(index-1) == POUND)
+        return ns.substring(0, index-1);
+      else
+        return ns;
+    }
+    else
+      return uri;
+  }
+
+  private void addToCache(String id, XSDNamedComponent component) {
+    partToXSDCache_.put(id,component);
+  }
+
+  protected boolean isComponentResolvable(XSDComponent component)
+  {
+    if (component == null)
+      return false;
+    XSDSchema schema = component.getSchema();
+    if (schema == null)
+      return false;
+    if (schema.getTargetNamespace() == null)
+      return false;
+    return true;
+  }
+}


Property changes on: branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/WSDLPartsToXSDTypeMapper.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java
===================================================================
--- branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java	2011-05-10 16:52:16 UTC (rev 31189)
+++ branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java	2011-05-10 16:54:01 UTC (rev 31190)
@@ -109,6 +109,7 @@
 import org.jboss.tools.ws.ui.utils.JAXWSTester2;
 import org.jboss.tools.ws.ui.utils.ResultsXMLStorage;
 import org.jboss.tools.ws.ui.utils.ResultsXMLStorageInput;
+import org.jboss.tools.ws.ui.utils.SchemaUtils;
 import org.jboss.tools.ws.ui.utils.TesterWSDLUtils;
 import org.jboss.tools.ws.ui.utils.WSTestUtils;
 import org.w3c.dom.Element;
@@ -421,7 +422,6 @@
 			getCurrentHistoryEntry().setOperationName(null);
 
 			serviceNSMessage = null;
-//			actionText = null;
 			
 			Definition wsdlDef = wbDialog.getWSDLDefinition();
 			getCurrentHistoryEntry().setWsdlDef(wsdlDef);
@@ -432,7 +432,7 @@
 			getCurrentHistoryEntry().setUrl(wbDialog.getWSDLText());
 			urlCombo.setText(wbDialog.getWSDLText());
 			
-			String output = TesterWSDLUtils.getSampleSOAPInputMessage(wsdlDef, 
+			String output = SchemaUtils.getSampleSOAPInputMessage(wsdlDef, 
 					wbDialog.getServiceTextValue(), 
 					wbDialog.getPortTextValue(), 
 					wbDialog.getBindingValue(), 
@@ -463,8 +463,14 @@
 					wbDialog.getServiceTextValue(), 
 					wbDialog.getPortTextValue());
 			getCurrentHistoryEntry().setSOAP12(isSOAP12);
+			
+			String headerText = SchemaUtils.getSampleSOAPMessageHeader(wsdlDef, 
+					wbDialog.getServiceTextValue(), 
+					wbDialog.getPortTextValue(), 
+					wbDialog.getBindingValue(), 
+					wbDialog.getOperationTextValue());
 
-			String soapIn = generateSampleSOAP(output, isSOAP12);
+			String soapIn = generateSampleSOAP(headerText, output, isSOAP12);
 			if (opName != null) {
 				if (bodyText.getText().length() > 0) {
 					
@@ -487,15 +493,6 @@
 							}
 					}
 				}
-//				if (MessageDialog.openQuestion(getSite().getShell(),
-//					JBossWSUIMessages.JAXRSWSTestView2_Title_Msg_May_Be_Out_of_Date, 
-//					JBossWSUIMessages.JAXRSWSTestView2_Text_Msg_May_Be_Out_of_Date)) {
-//					
-//						bodyText.setText(soapIn);
-//						getCurrentHistoryEntry().setBody(soapIn);
-//						getCurrentHistoryEntry().setAction(actionURL);
-//						
-//				}
 			} else if (bodyText.getText().length() > 0) {
 				
 				String opNameInBody = getOpNameFromRequestBody();
@@ -520,9 +517,6 @@
 				}
 			}
 			
-//			urlCombo.setText(endpointURL);
-//			actionText = actionURL;
-			
 			setControlsForWSType(getCurrentTestType());
 			setControlsForMethodType(methodCombo.getText());
 			setControlsForSelectedURL();
@@ -984,25 +978,40 @@
 		super.dispose();
 	}
 
-	private String generateSampleSOAP ( String innerText, boolean isSOAP12 ) {
+	private String generateSampleSOAP ( String headerText, String innerText, boolean isSOAP12 ) {
 		String prefix = TesterWSDLUtils.SOAP_PREFIX;
 		String soapURI = TesterWSDLUtils.SOAP_NS_URI;
 		if (isSOAP12) {
 			prefix = TesterWSDLUtils.SOAP12_PREFIX;
 			soapURI = TesterWSDLUtils.SOAP12_ENVELOPE_NS_URI;
 		}
-		String soapIn = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n" + //$NON-NLS-1$
-		"<" + prefix + ":Envelope xmlns:" + prefix + "=\"" + soapURI + "\" " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-		"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +  //$NON-NLS-1$
-		"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +  //$NON-NLS-1$
-		">\n" + //$NON-NLS-1$
-		"<" + prefix + ":Body>\n";//$NON-NLS-1$ //$NON-NLS-2$
+		StringBuffer buffer = new StringBuffer();
+		buffer.append("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n");//$NON-NLS-1$
+		buffer.append("<" + prefix + ":Envelope xmlns:" + prefix + "=\"" + soapURI + "\" ");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+		buffer.append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " );//$NON-NLS-1$
+		buffer.append("xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" >\n");//$NON-NLS-1$
+		buffer.append("<" + prefix + ":Header>\n");//$NON-NLS-1$ //$NON-NLS-2$
+		if (headerText != null) 
+			buffer.append(headerText);
+		buffer.append("</" + prefix + ":Header>\n");;//$NON-NLS-1$ //$NON-NLS-2$
+		buffer.append("<" + prefix + ":Body>\n");//$NON-NLS-1$ //$NON-NLS-2$
 		if (innerText != null)
-			soapIn = soapIn + innerText;
-		soapIn = soapIn +
-		"</" + prefix + ":Body>\n" + //$NON-NLS-1$ //$NON-NLS-2$
-		"</" + prefix + ":Envelope>";	 //$NON-NLS-1$ //$NON-NLS-2$
-		return soapIn;
+			buffer.append(innerText);
+		buffer.append("</" + prefix + ":Body>\n");;//$NON-NLS-1$ //$NON-NLS-2$
+		buffer.append("</" + prefix + ":Envelope>");//$NON-NLS-1$ //$NON-NLS-2$ 
+		
+//		String soapIn = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n" + //$NON-NLS-1$
+//		"<" + prefix + ":Envelope xmlns:" + prefix + "=\"" + soapURI + "\" " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+//		"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +  //$NON-NLS-1$
+//		"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +  //$NON-NLS-1$
+//		">\n" + //$NON-NLS-1$
+//		"<" + prefix + ":Body>\n";//$NON-NLS-1$ //$NON-NLS-2$
+//		if (innerText != null)
+//			soapIn = soapIn + innerText;
+//		soapIn = soapIn +
+//		"</" + prefix + ":Body>\n" + //$NON-NLS-1$ //$NON-NLS-2$
+//		"</" + prefix + ":Envelope>";	 //$NON-NLS-1$ //$NON-NLS-2$
+		return buffer.toString();
 	}
 
 	private void setMenusForCurrentState() {
@@ -1087,7 +1096,7 @@
 			dlsList.setEnabled(false);
 
 			String emptySOAP = 
-				generateSampleSOAP(null, false);
+				generateSampleSOAP(null, null, false);
 			emptySOAP = WSTestUtils.addNLsToXML(emptySOAP);
 
 			if (bodyText.getText().trim().length() == 0) {

Modified: branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/TestHistoryEntry.java
===================================================================
--- branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/TestHistoryEntry.java	2011-05-10 16:52:16 UTC (rev 31189)
+++ branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/TestHistoryEntry.java	2011-05-10 16:54:01 UTC (rev 31190)
@@ -24,7 +24,6 @@
 	private String portName;
 	private String bindingName;
 	private String operationName;
-//	private String wsMethod;
 	private Definition wsdlDef = null;
 	private String[] serviceNSMessage = null;
 	private boolean isSOAP12 = false;
@@ -126,14 +125,6 @@
 		this.operationName = operationName;
 	}
 
-//	public void setWsMethod(String wsMethod) {
-//		this.wsMethod = wsMethod;
-//	}
-//
-//	public String getWsMethod() {
-//		return wsMethod;
-//	}
-
 	public void setWsdlDef(Definition wsdlDef) {
 		this.wsdlDef = wsdlDef;
 	}

Modified: branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/WSDLBrowseDialog.java
===================================================================
--- branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/WSDLBrowseDialog.java	2011-05-10 16:52:16 UTC (rev 31189)
+++ branches/jbosstools-3.2.x/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/WSDLBrowseDialog.java	2011-05-10 16:54:01 UTC (rev 31190)
@@ -173,21 +173,25 @@
 	 * @param arg0
 	 */
 	private void validateLocation ( ModifyEvent arg0 ) {
-		this.getContents().getDisplay().asyncExec( new Runnable() {
-			public void run() {
-				setMessage(JBossWSUIMessages.WSDLBrowseDialog_Message);
-				IStatus status = validate(false);
-				if (status != Status.OK_STATUS) {
-					setMessage(status.getMessage(), IMessageProvider.WARNING);
-					if (showServicePortOperaton)
-						setGroupEnabled(false);
-				} else {
-					setMessage(JBossWSUIMessages.WSDLBrowseDialog_Message);
-					if (showServicePortOperaton)
-						setGroupEnabled(true);
-				}
+		if (this.getContents() != null) {
+			if (this.getContents().getDisplay() != null) {
+				this.getContents().getDisplay().asyncExec( new Runnable() {
+					public void run() {
+						setMessage(JBossWSUIMessages.WSDLBrowseDialog_Message);
+						IStatus status = validate(false);
+						if (status != Status.OK_STATUS) {
+							setMessage(status.getMessage(), IMessageProvider.WARNING);
+							if (showServicePortOperaton)
+								setGroupEnabled(false);
+						} else {
+							setMessage(JBossWSUIMessages.WSDLBrowseDialog_Message);
+							if (showServicePortOperaton)
+								setGroupEnabled(true);
+						}
+					}
+				});
 			}
-		});
+		}
 	}
 	
 	@Override



More information about the jbosstools-commits mailing list