Index: META-INF/MANIFEST.MF
===================================================================
--- META-INF/MANIFEST.MF (revision 30593)
+++ META-INF/MANIFEST.MF (working copy)
@@ -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,
Index: .classpath
===================================================================
--- .classpath (revision 30593)
+++ .classpath (working copy)
@@ -1,10 +1,10 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
Index: src/org/jboss/tools/ws/ui/utils/FragmentConstants.java
===================================================================
--- src/org/jboss/tools/ws/ui/utils/FragmentConstants.java (revision 0)
+++ src/org/jboss/tools/ws/ui/utils/FragmentConstants.java (revision 0)
@@ -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@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 = ""; //$NON-NLS-1$
+ public static final String ROOT_ELEMENT_END_TAG = ""; //$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
Index: src/org/jboss/tools/ws/ui/utils/Validator.java
===================================================================
--- src/org/jboss/tools/ws/ui/utils/Validator.java (revision 0)
+++ src/org/jboss/tools/ws/ui/utils/Validator.java (revision 0)
@@ -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@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;
+ }
+ }
+}
Index: src/org/jboss/tools/ws/ui/utils/URLUtils.java
===================================================================
--- src/org/jboss/tools/ws/ui/utils/URLUtils.java (revision 0)
+++ src/org/jboss/tools/ws/ui/utils/URLUtils.java (revision 0)
@@ -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@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@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;
+ }
+}
Index: src/org/jboss/tools/ws/ui/utils/TesterWSDLUtils.java
===================================================================
--- src/org/jboss/tools/ws/ui/utils/TesterWSDLUtils.java (revision 30946)
+++ src/org/jboss/tools/ws/ui/utils/TesterWSDLUtils.java (working copy)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
+ * 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,
@@ -15,29 +15,21 @@
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import java.util.Vector;
import javax.wsdl.Binding;
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.ExtensibilityElement;
-import javax.wsdl.extensions.schema.Schema;
-import javax.wsdl.extensions.schema.SchemaImport;
import javax.wsdl.extensions.soap.SOAPAddress;
import javax.wsdl.extensions.soap.SOAPOperation;
import javax.wsdl.extensions.soap12.SOAP12Address;
@@ -46,51 +38,19 @@
import javax.wsdl.xml.WSDLReader;
import javax.xml.namespace.QName;
-//import org.jdom.Attribute;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.jboss.tools.ws.core.utils.StatusUtils;
import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
-import org.jdom.Namespace;
-import org.jdom.input.DOMBuilder;
import com.ibm.wsdl.Constants;
/**
+ * Cleaned up and separated WSDL from Schema utilities
* @author bfitzpat
*
*/
public class TesterWSDLUtils {
- private static final String IMPORT_TAG = "import"; //$NON-NLS-1$
- private static final String VALUE_ATTR = "value"; //$NON-NLS-1$
- private static final String SEQUENCE_NAME = "sequence"; //$NON-NLS-1$
- private static final String COMPLEX_TYPE_NAME = "complexType"; //$NON-NLS-1$
- private static final String ENUMERATION_NAME = "enumeration"; //$NON-NLS-1$
- private static final String RESTRICTION_NAME = "restriction"; //$NON-NLS-1$
- 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 final String MIN_OCCURS_ATTR = "minOccurs"; //$NON-NLS-1$
- private static final String TYPE_ATTR = "type"; //$NON-NLS-1$
- private static final String NAME_ATTR = "name"; //$NON-NLS-1$
private final static String DEF_FACTORY_PROPERTY_NAME =
"javax.wsdl.factory.DefinitionFactory"; //$NON-NLS-1$
@@ -210,77 +170,6 @@
return false;
}
- public static String getSampleSOAPInputMessage ( Definition wsdlDefinition, String serviceName, String portName, String bindingName, String opName ) {
- 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();
- String ns = portType.getQName().getNamespaceURI();
- 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();
- if (parts.size() > 1) {
- buf.append('<' + operation.getName());
- buf.append(" xmlns = \"" + ns + "\""); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append(">\n"); //$NON-NLS-1$
- }
- for( Iterator> it4 = parts.iterator(); it4.hasNext(); ) {
- Part part = (Part) it4.next();
- String schemaName = null;
- if (part.getElementName() != null) {
- schemaName = part.getElementName().getLocalPart();
- } else {
- schemaName = part.getName();
- }
- if (parts.size() > 1) {
- if (part != null && part.getTypeName() != null && !part.getTypeName().getNamespaceURI().
- equalsIgnoreCase("http://www.w3.org/2001/XMLSchema")) { //$NON-NLS-1$
- buf.append(createMessageForSchemaElement(wsdlDefinition, part.getName(), part.getTypeName().getLocalPart(), ns));
- } else {
- buf.append('<' + part.getName());
- // buf.append(" xmlns = \"" + ns + "\""); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append(">?"); //$NON-NLS-1$
- buf.append("" + part.getName() + ">\n");//$NON-NLS-1$//$NON-NLS-2$
- }
- } else {
- String partName = part.getName();
- if (parts.size() == 1) partName = null;
- String out = createMessageForSchemaElement(wsdlDefinition, partName, schemaName, ns);
- if (out == null) {
- StringBuffer tempBuffer = new StringBuffer();
- tempBuffer.append('<' + part.getName());
- // tempBuffer.append(" xmlns = \"" + ns + "\""); //$NON-NLS-1$ //$NON-NLS-2$
- tempBuffer.append(">?"); //$NON-NLS-1$
- tempBuffer.append("" + part.getName() + ">\n");//$NON-NLS-1$//$NON-NLS-2$
- out = tempBuffer.toString();
- }
- return out;
- }
- }
- return buf.toString();
- }
- }
- }
- }
- }
- }
- return null;
- }
-
public static String[] getNSServiceNameAndMessageNameArray (Definition wsdlDefinition, String serviceName, String portName, String bindingName, String opName ) {
Map, ?> services = wsdlDefinition.getServices();
Set> serviceKeys = services.keySet();
@@ -380,421 +269,6 @@
return null;
}
- private static org.jdom.Element getNamedSchemaElement (Definition wsdlDefinition, Types types, String elementName) {
- if (types != null &&types.getExtensibilityElements().size() > 0) {
- Schema schema = (Schema) types.getExtensibilityElements().get(0);
- DOMBuilder domBuilder = new DOMBuilder();
- org.jdom.Element jdomSchemaElement = domBuilder.build(schema.getElement());
- if (elementName.indexOf(":") > 0 ) { //$NON-NLS-1$
- elementName = elementName.substring(elementName.indexOf(":") + 1, elementName.length()); //$NON-NLS-1$
- }
- List> list = jdomSchemaElement.getChildren();
- if (list.size() > 0) {
- org.jdom.Element checkForImport = (org.jdom.Element) list.get(0);
- if (checkForImport.getName().equals(IMPORT_TAG)) {
- Map, ?> imports = schema.getImports();
- Iterator> importIter = imports.values().iterator();
- while (importIter.hasNext()) {
- Object obj = importIter.next();
- Vector> schemaImportVector = (Vector>) obj;
- Iterator> vectorIter = schemaImportVector.iterator();
- while (vectorIter.hasNext()) {
- SchemaImport schemaImport = (SchemaImport) vectorIter.next();
- org.jdom.Element jdomSchemaImportElement = domBuilder.build(schemaImport.getReferencedSchema().getElement());
- List> innerList = jdomSchemaImportElement.getChildren();
- for (int i = 0; i < innerList.size(); i++){
- org.jdom.Element temp = (org.jdom.Element) innerList.get(i);
- String rootName = null;
- if (temp.getAttribute(NAME_ATTR) != null)
- rootName = temp.getAttribute(NAME_ATTR).getValue();
- String tempName = temp.getNamespacePrefix() + ":" + rootName; //$NON-NLS-1$
- if (rootName.equalsIgnoreCase(elementName)) {
- return temp;
- } else if (tempName.equalsIgnoreCase(elementName) ) {
- return temp;
- }
- }
- }
- }
- } else {
- for (int i = 0; i < list.size(); i++){
- org.jdom.Element temp = (org.jdom.Element) list.get(i);
- String rootName = null;
- if (temp.getAttribute(NAME_ATTR) != null)
- rootName = temp.getAttribute(NAME_ATTR).getValue();
- String tempName = temp.getNamespacePrefix() + ":" + rootName; //$NON-NLS-1$
- if (rootName.equalsIgnoreCase(elementName)) {
- return temp;
- } else if (tempName.equalsIgnoreCase(elementName) ) {
- return temp;
- }
- }
- }
- }
- }
- return null;
- }
-
- private static org.jdom.Element getNamedSchemaElement ( Definition wsdlDefinition, String messageName ) {
- Types types = wsdlDefinition.getTypes();
-
- if (types == null) {
- Map, ?> imports = wsdlDefinition.getImports();
- Set> importKeys = imports.keySet();
- for( Iterator> it2 = importKeys.iterator(); it2.hasNext(); ) {
- String importKey = (String) it2.next();
- Vector> importVector = (Vector>) imports.get(importKey);
- Iterator> iter = importVector.iterator();
- while (iter.hasNext()) {
- Import importInstance = (Import) iter.next();
- if (importInstance.getDefinition().getTypes() != null) {
- types = importInstance.getDefinition().getTypes();
- org.jdom.Element attempt = getNamedSchemaElement(wsdlDefinition, types, messageName);
- if (attempt != null)
- return attempt;
- } else if (importInstance.getDefinition().getImports() != null) {
- org.jdom.Element attempt = getNamedSchemaElement(importInstance.getDefinition(), messageName);
- if (attempt != null)
- return attempt;
- }
- }
- }
- } else {
- org.jdom.Element attempt = getNamedSchemaElement(wsdlDefinition, types, messageName);
- if (attempt != null)
- return attempt;
- }
- return null;
- }
-
- private static String createMessageForSchemaElementFromTypes ( Definition wsdlDefinition, Types types, String partName, String messageName, String namespace ) {
- if (types != null &&types.getExtensibilityElements().size() > 0) {
- Schema schema = (Schema) types.getExtensibilityElements().get(0);
- DOMBuilder domBuilder = new DOMBuilder();
- org.jdom.Element jdomSchemaElement = domBuilder.build(schema.getElement());
-
- List> list = jdomSchemaElement.getChildren();
- if (list.size() > 0) {
- org.jdom.Element checkForImport = (org.jdom.Element) list.get(0);
- if (checkForImport.getName().equals(IMPORT_TAG)) {
- Map, ?> imports = schema.getImports();
- Iterator> importIter = imports.values().iterator();
- while (importIter.hasNext()) {
- Object obj = importIter.next();
- Vector> schemaImportVector = (Vector>) obj;
- Iterator> vectorIter = schemaImportVector.iterator();
- while (vectorIter.hasNext()) {
- SchemaImport schemaImport = (SchemaImport) vectorIter.next();
- if (schemaImport.getReferencedSchema() != null) {
- org.jdom.Element jdomSchemaImportElement = domBuilder.build(schemaImport.getReferencedSchema().getElement());
- List> innerList = jdomSchemaImportElement.getChildren();
-
- for (int i = 0; i < innerList.size(); i++){
- org.jdom.Element temp = (org.jdom.Element) innerList.get(i);
- String rootName = null;
- if (temp.getAttribute(NAME_ATTR) != null)
- rootName = temp.getAttribute(NAME_ATTR).getValue();
-
- if (rootName != null && rootName.equalsIgnoreCase(messageName)) {
- StringBuffer buf = new StringBuffer();
- buf.append('<' + rootName);
- buf.append(" xmlns = \"" + namespace + "\""); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append(">\n"); //$NON-NLS-1$
- if (!temp.getChildren().isEmpty()){
- org.jdom.Element temp2 = (org.jdom.Element)temp.getChildren().get(0);
- if (temp2.getName().contains(COMPLEX_TYPE_NAME)) {
- String elementStr = processComplexType(wsdlDefinition, temp2);
- buf.append(elementStr);
- } else if (temp2.getName().contains(RESTRICTION_NAME)){
- String elementStr = processType(wsdlDefinition, temp2, RESTRICTION_NAME, false);
- buf.append(elementStr);
- } else {
- String elementStr = processChild(wsdlDefinition, temp2);
- buf.append(elementStr);
- }
- }
- buf.append("" + rootName + ">\n");//$NON-NLS-1$//$NON-NLS-2$
- return buf.toString();
- }
- }
- }
- }
- }
- } else {
- for (int i = 0; i < list.size(); i++){
- org.jdom.Element temp = (org.jdom.Element) list.get(i);
- String rootName = null;
- if (temp.getAttribute(NAME_ATTR) != null)
- rootName = temp.getAttribute(NAME_ATTR).getValue();
-
- if (rootName.equalsIgnoreCase(messageName)) {
- if (temp.getParentElement().getAdditionalNamespaces() != null && temp.getParentElement().getAdditionalNamespaces().size() > 0) {
- @SuppressWarnings("unchecked")
- List addlNamespaces = temp.getParentElement().getAdditionalNamespaces();
- for (int j = 0; j < addlNamespaces.size(); j++) {
- Namespace addlNS = addlNamespaces.get(j);
- if (addlNS.getPrefix().equalsIgnoreCase("tns")) { //$NON-NLS-1$
- if (!addlNS.getURI().equalsIgnoreCase(namespace)) {
- namespace = addlNS.getURI();
- break;
- }
- }
- }
- }
-
- StringBuffer buf = new StringBuffer();
- buf.append('<');
- if (partName != null) {
- buf.append(partName);
- }
- else {
- buf.append(rootName);
- buf.append(" xmlns = \"" + namespace + "\""); //$NON-NLS-1$ //$NON-NLS-2$
- }
- buf.append(">\n"); //$NON-NLS-1$
- if (temp.getChildren().isEmpty()) {
- String nstemp = namespace;
- String typeName = temp.getAttributeValue(TYPE_ATTR);
- String prefix = null;
- if (typeName.indexOf(':') > 0) {
- prefix = typeName.substring(0, typeName.indexOf(':'));
- nstemp = temp.getNamespace(prefix).getURI();
- typeName = typeName.substring(typeName.indexOf(':') + 1, typeName.length());
- }
- temp = getNodeFromSchema(temp.getParentElement(), typeName, nstemp, prefix);
- }
- if (temp != null && !temp.getChildren().isEmpty()){
- org.jdom.Element temp2 = (org.jdom.Element)temp.getChildren().get(0);
- if (temp2.getName().contains(COMPLEX_TYPE_NAME)) {
- String elementStr = processComplexType(wsdlDefinition, temp2);
- buf.append(elementStr);
- } else {
- String elementStr = processChild(wsdlDefinition, temp2);
- buf.append(elementStr);
- }
- }
- buf.append("");//$NON-NLS-1$
- if (partName != null)
- buf.append(partName);
- else
- buf.append(rootName);
- buf.append(">\n");//$NON-NLS-1$
- return buf.toString();
- } else {
- Message msg = wsdlDefinition.getMessage(new QName(namespace, messageName));
- if (msg != null) {
- StringBuffer buf = new StringBuffer();
- buf.append('<');
- if (partName != null)
- buf.append(partName);
- else
- buf.append(rootName);
- buf.append(" xmlns = \"" + namespace + "\""); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append(">?"); //$NON-NLS-1$
- buf.append("");//$NON-NLS-1$
- if (partName != null)
- buf.append(partName);
- else
- buf.append(rootName);
- buf.append(">\n");//$NON-NLS-1$
- return buf.toString();
- }
- }
- }
- }
- }
- }
- return null;
- }
-
- private static org.jdom.Element getNodeFromSchema ( org.jdom.Element root, String name, String ns, String prefix) {
- if (root != null) {
- List> childList = root.getChildren();
- Iterator> iter1 = childList.iterator();
- while (iter1.hasNext()) {
- Object test = iter1.next();
- if (test instanceof org.jdom.Element) {
- org.jdom.Element childEl = (org.jdom.Element) test;
- if (childEl.getAttributeValue(NAME_ATTR, ns).equalsIgnoreCase(name)) {
- String typeName = childEl.getAttributeValue(TYPE_ATTR);
- if (typeName == null || !typeName.equalsIgnoreCase(prefix + ':' + name))
- return childEl;
- }
- }
- }
- }
- return null;
- }
-
- private static String processComplexType (Definition wsdlDefinition, org.jdom.Element childEl ) {
- StringBuffer buf = new StringBuffer();
- if (!childEl.getChildren().isEmpty()) {
- org.jdom.Element temp3 = (org.jdom.Element)childEl.getChildren().get(0);
- if (temp3.getName().contains(SEQUENCE_NAME)) {
- for (int j = 0; j < temp3.getChildren().size(); j++) {
- org.jdom.Element tempEl = (org.jdom.Element) temp3.getChildren().get(j);
- String elementStr = processChild(wsdlDefinition, tempEl);
- buf.append(elementStr);
- }
- } else {
- String elementStr = processChild(wsdlDefinition, temp3);
- buf.append(elementStr);
- }
- }
- return buf.toString();
- }
-
- private static boolean isTypeBaseXSDOrSimple ( String type ) {
- // 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;
- }
-
- private static String processType (Definition wsdlDefinition, org.jdom.Element childEl, String type, boolean isOptional) {
- StringBuffer buf = new StringBuffer();
- if (isTypeBaseXSDOrSimple(type)) {
- buf.append("?"); //$NON-NLS-1$
- } else if (type.contains(RESTRICTION_NAME)) {
- for (int j = 0; j < childEl.getChildren().size(); j++) {
- org.jdom.Element tempEl = (org.jdom.Element) childEl.getChildren().get(j);
- String innerType = tempEl.getName();
- String elementStr = processType(wsdlDefinition, tempEl, innerType, isOptional );
- buf.append(elementStr);
- }
- } else if (type.contains(ENUMERATION_NAME)) {
- String enumerationType = null;
- if (childEl.getAttribute(VALUE_ATTR) != null) {
- enumerationType = childEl.getAttribute(VALUE_ATTR).getValue();
- buf.append(enumerationType + " | "); //$NON-NLS-1$
- }
- } else {
- org.jdom.Element typeEl = getNamedSchemaElement(wsdlDefinition, type);
- if (typeEl != null) {
- if (typeEl.getName().contains(COMPLEX_TYPE_NAME) || typeEl.getName().contains(SEQUENCE_NAME)) {
- String elementStr = processComplexType(wsdlDefinition, typeEl);
- buf.append(elementStr);
- } else {
- String elementStr = processChild(wsdlDefinition, typeEl);
- buf.append(elementStr);
- }
- } else {
- buf.append("?"); //$NON-NLS-1$
- }
- }
- return buf.toString();
- }
-
- private static String processChild ( Definition wsdlDefinition, org.jdom.Element childEl ) {
- StringBuffer buf = new StringBuffer();
- String innerChildName = null;
- if (childEl.getAttribute(NAME_ATTR) != null) {
- innerChildName = childEl.getAttribute(NAME_ATTR).getValue();
- }
- String innerChildType = null;
- if (childEl.getAttribute(TYPE_ATTR) != null) {
- innerChildType = childEl.getAttribute(TYPE_ATTR).getValue();
- }
- String innerMinOccurs = null;
- Integer innerMinOccursNum = null;
- if (childEl.getAttribute(MIN_OCCURS_ATTR) != null) {
- innerMinOccurs = childEl.getAttribute(MIN_OCCURS_ATTR).getValue();
- innerMinOccursNum = Integer.decode(innerMinOccurs);
- }
- if (innerChildName != null && !childEl.getName().contains(SIMPLE_TYPE_NAME)){
- buf.append('<' + innerChildName);
- buf.append(">"); //$NON-NLS-1$
- }
-
- if (childEl.getChildren().size() > 0) {
- if (childEl.getName().contains(SIMPLE_TYPE_NAME)) {
- String elementStr = processType(wsdlDefinition, childEl, SIMPLE_TYPE_NAME, (innerMinOccursNum == null || innerMinOccursNum.intValue() == 0));
- buf.append(elementStr);
- } else {
- for (int j = 0; j < childEl.getChildren().size(); j++) {
- org.jdom.Element tempEl = (org.jdom.Element) childEl.getChildren().get(j);
- if (tempEl.getName().contains(COMPLEX_TYPE_NAME)) {
- String elementStr = processComplexType(wsdlDefinition, tempEl);
- buf.append(elementStr);
- } else {
- String elementStr = processChild(wsdlDefinition, tempEl);
- buf.append(elementStr);
- }
- }
- }
- } else if ((innerMinOccursNum == null || innerMinOccursNum.intValue() == 0) && (innerChildType != null)) {
- String elementStr = processType(wsdlDefinition, childEl, innerChildType, true);
- buf.append(elementStr);
- } else if (innerChildType != null){
- String elementStr = processType(wsdlDefinition, childEl, innerChildType, false);
- buf.append(elementStr);
- }
- if (innerChildName != null && !childEl.getName().contains(SIMPLE_TYPE_NAME))
- buf.append("" + innerChildName + ">\n"); //$NON-NLS-1$//$NON-NLS-2$
- return buf.toString();
- }
-
- public static String createMessageForSchemaElement ( Definition wsdlDefinition, String partName, String messageName, String namespace ) {
- Types types = wsdlDefinition.getTypes();
- if (types == null || wsdlDefinition.getImports().size() > 0) {
- Map, ?> imports = wsdlDefinition.getImports();
- Set> importKeys = imports.keySet();
- for( Iterator> it2 = importKeys.iterator(); it2.hasNext(); ) {
- String importKey = (String) it2.next();
- Vector> importVector = (Vector>) imports.get(importKey);
- Iterator> iter = importVector.iterator();
- while (iter.hasNext()) {
- Import importInstance = (Import) iter.next();
-// namespace = importInstance.getNamespaceURI();
- if (importInstance.getDefinition().getTypes() != null) {
- Types temptypes = importInstance.getDefinition().getTypes();
- String attempt = createMessageForSchemaElementFromTypes(wsdlDefinition, temptypes, partName, messageName, namespace);
- if (attempt != null)
- return attempt;
- } else if (importInstance.getDefinition().getImports() != null) {
- String attempt = createMessageForSchemaElement(importInstance.getDefinition(), partName, messageName, namespace);
- if (attempt != null)
- return attempt;
- }
- }
- }
- // if we got this far, it wasn't found in the imports
- String attempt = createMessageForSchemaElementFromTypes(wsdlDefinition, types, partName, messageName, namespace);
- if (attempt != null)
- return attempt;
- } else {
- String attempt = createMessageForSchemaElementFromTypes(wsdlDefinition, types, partName, messageName, namespace);
- if (attempt != null)
- return attempt;
- }
- return null;
- }
-
public static String getFileContents (URL inURL){
try {
BufferedReader in = new BufferedReader(
Index: src/org/jboss/tools/ws/ui/utils/NetUtils.java
===================================================================
--- src/org/jboss/tools/ws/ui/utils/NetUtils.java (revision 0)
+++ src/org/jboss/tools/ws/ui/utils/NetUtils.java (revision 0)
@@ -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);
+ }
+}
Index: src/org/jboss/tools/ws/ui/utils/JAXWSTester.java
===================================================================
--- src/org/jboss/tools/ws/ui/utils/JAXWSTester.java (revision 30593)
+++ src/org/jboss/tools/ws/ui/utils/JAXWSTester.java (working copy)
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.xml.soap.MimeHeader;
-import javax.xml.soap.MimeHeaders;
-import javax.xml.soap.SOAPMessage;
-
-import org.apache.axis.AxisFault;
-import org.apache.axis.Message;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.Call;
-import org.apache.axis.client.Service;
-import org.apache.axis.message.SOAPEnvelope;
-import org.apache.axis.transport.http.HTTPConstants;
-
-/**
- * Tester class for JAX-WS services
- * @author bfitzpat
- *
- */
-public class JAXWSTester {
-
- // the response message to pass back
- private String resultBody;
-
- private SOAPEnvelope resultSOAP;
-
- // the result HTTP headers to pass back
- private HashMap resultHeaders;
-
- // utility constant
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
-
- /**
- * Constructor
- */
- public JAXWSTester() {
- // empty
- }
-
- /**
- * Return the response message
- * @return
- */
- public String getResultBody() {
- return this.resultBody;
- }
-
- /**
- * Return a map of HTTP headers from the response
- * @return
- */
- public Map getResultHeaders() {
- return this.resultHeaders;
- }
-
- public SOAPEnvelope getResultSOAP(){
- return this.resultSOAP;
- }
-
- /**
- * Invoke the JAX-WS service
- * @param endpointurl
- * @param actionurl
- * @param body
- * @throws Exception
- */
- public void doTest( String endpointurl, String actionurl, String body ) throws Exception {
- /*
- * the endpoint & action urls + the soap in are what we
- * need to invoke the WS
- */
- String endpoint = endpointurl;
- String action = actionurl;
- String soapIn = body;
-
- /* Use AXIS to call the WS */
- String document = WSTestUtils.stripNLsFromXML(soapIn);
- Service service = new Service();
- Call call= (Call) service.createCall();
- call.setTargetEndpointAddress( new java.net.URL(endpoint) );
- call.setOperationStyle( org.apache.axis.constants.Style.MESSAGE );
- if ( action != null ) {
- call.setProperty(Call.SOAPACTION_USE_PROPERTY,Boolean.TRUE);
- call.setProperty(Call.SOAPACTION_URI_PROPERTY,action);
- }
- Message message = new Message(document);
-
- resultSOAP = null;
-
- this.resultBody = EMPTY_STRING;
-
- try {
- resultSOAP = call.invoke( message );
-
- // Get back the response message
- if (resultSOAP != null && resultSOAP.getBody() != null) {
- this.resultBody = resultSOAP.getBody().toString();
- }
-
- // Get back the response HTTP headers and pass back as a Map
- if (call != null && call.getMessageContext() != null) {
- MessageContext mc = call.getMessageContext();
- if (mc != null){
- String statusCode = mc.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE).toString();
- String statusMessage = mc.getProperty(HTTPConstants.MC_HTTP_STATUS_MESSAGE).toString();
- String protocol = mc.getTransportName();
- resultHeaders = new HashMap();
- resultHeaders.put(null, protocol + " " + statusCode + " " + statusMessage); //$NON-NLS-1$//$NON-NLS-2$
-// System.out.println(protocol + " " + statusCode + " " + statusMessage);
- SOAPMessage sm = mc.getResponseMessage();
- if (sm != null){
- MimeHeaders mh = sm.getMimeHeaders();
- if (mh != null){
- Iterator> iter = mh.getAllHeaders();
- while (iter.hasNext()) {
- MimeHeader next = (MimeHeader)iter.next();
- resultHeaders.put(next.getName(), next.getValue());
- }
- }
- }
- }
- }
- } catch (AxisFault fault){
-
- // Get back the response message
- if (fault.getFaultString() != null) {
- this.resultBody = fault.getFaultString();
- }
-
- // Get back the response HTTP headers and pass back as a Map
- if (fault.getHeaders() != null && !fault.getHeaders().isEmpty()) {
- Iterator> iter = fault.getHeaders().iterator();
- resultHeaders = new HashMap();
- while (iter.hasNext()) {
- Object next = iter.next();
- resultHeaders.put(next.toString(), ""); //$NON-NLS-1$
- }
- } else if (call != null && call.getMessageContext() != null) {
- MessageContext mc = call.getMessageContext();
- if (mc.getMessage() != null && mc.getMessage().getMimeHeaders() != null) {
- MimeHeaders mh = mc.getMessage().getMimeHeaders();
- Iterator> iter = mh.getAllHeaders();
- resultHeaders = new HashMap();
- while (iter.hasNext()) {
- MimeHeader next = (MimeHeader)iter.next();
- resultHeaders.put(next.getName(), next.getValue());
- }
- }
- }
-
- }
-
- }
-}
\ No newline at end of file
Index: src/org/jboss/tools/ws/ui/utils/URIEncoder.java
===================================================================
--- src/org/jboss/tools/ws/ui/utils/URIEncoder.java (revision 0)
+++ src/org/jboss/tools/ws/ui/utils/URIEncoder.java (revision 0)
@@ -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 x-www-form-urlencoded
+ * format. This method uses the platform's default encoding
+ * as the encoding scheme to obtain the bytes for unsafe characters.
+ *
+ * @param s String 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 String.
+ */
+ 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 application/x-www-form-urlencoded
+ * format using a specific encoding scheme. This method uses the
+ * supplied encoding scheme to obtain the bytes for unsafe
+ * characters.
+ *
+ * Note: The
+ * World Wide Web Consortium Recommendation states that
+ * UTF-8 should be used. Not doing so may introduce
+ * incompatibilites.
+ *
+ * @param s String to be translated.
+ * @param enc The name of a supported
+ * character
+ * encoding.
+ * @return the translated String.
+ * @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);
+ }
+}
Index: src/org/jboss/tools/ws/ui/utils/WSDLPartsToXSDTypeMapper.java
===================================================================
--- src/org/jboss/tools/ws/ui/utils/WSDLPartsToXSDTypeMapper.java (revision 0)
+++ src/org/jboss/tools/ws/ui/utils/WSDLPartsToXSDTypeMapper.java (revision 0)
@@ -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