[jboss-svn-commits] JBL Code SVN: r25706 - in labs/jbossesb/trunk: product/rosetta/src/org/jboss/internal/soa/esb/webservice and 13 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Mar 18 07:57:14 EDT 2009


Author: beve
Date: 2009-03-18 07:57:14 -0400 (Wed, 18 Mar 2009)
New Revision: 25706

Added:
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/SchemaResolver.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/SchemaResolverUnitTest.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/request2.xsd
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/sample-request.xml
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/schemas/
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/schemas/request.xsd
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/types/
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/types/custom-type.xsd
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/types/subtypes/
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/types/subtypes/custom-subtype-type.xsd
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/types/type2-type.xsd
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployerUnitTest.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir.esb
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir/
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir/mock.xsd
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir/request.xsd
   labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/types/
   labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/types/custom-request-type.xsd
   labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/types/custom-response-type.xsd
   labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/types/subtypes/
   labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/types/subtypes/custom-subtype-type.xsd
   labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/types/type2-type.xsd
   labs/jbossesb/trunk/testlib/jetty-6.1.15.jar
   labs/jbossesb/trunk/testlib/jetty-util-6.1.15.jar
Modified:
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/XMLHelper.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBContractGenerator.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/XMLHelperUnitTest.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/ESBContractGeneratorUnitTest.java
   labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/build.xml
   labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/error-soap-message.xml
   labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/jboss-esb.xml
   labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/readme.txt
   labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/request.xsd
   labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/response.xsd
   labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/soap-userpass-message.xml
Log:
https://jira.jboss.org/jira/browse/JBESB-2323 "Implement support for schema import in EBWS WSDL generation/action pipeline validation."


Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/SchemaResolver.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/SchemaResolver.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/SchemaResolver.java	2009-03-18 11:57:14 UTC (rev 25706)
@@ -0,0 +1,286 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.internal.soa.esb.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+
+import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.soa.esb.util.ClassUtil;
+import org.w3c.dom.ls.LSInput;
+import org.w3c.dom.ls.LSResourceResolver;
+
+/**
+ * SchemaResolver is a {@link LSResourceResolver} implemention that locates
+ * resources by first trying to locate the resource on the local filesystem, 
+ * and failing to find it there it will try the classpath. 
+ * </p>
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class SchemaResolver implements LSResourceResolver
+{
+    private Logger log = Logger.getLogger(SchemaResolver.class);
+
+    /**
+     * The encoding to use when reading resources.
+     */
+    final private String encoding;
+
+    /**
+     * Base URI that resources will be resolved realtive to.
+     */
+    private final URI parentSchemaUri;
+
+    /**
+     * Constructs an instance with the default encoding (UTF-8) and
+     * using the passed in baseUri.
+     * 
+     * @param baseUri Base URI that resources will be resolved realtive to.
+     */
+    public SchemaResolver(final URI baseUri)
+    {
+        this("UTF-8", baseUri);
+    }
+
+    /**
+     * Constructs an instance with the specified encoding.
+     * 
+     * @param encoding The encoding to use when reading resources. Must not be null;
+     * @param baseUri Base URI that resources will be resolved realtive to.
+     */
+    public SchemaResolver(final String encoding, final URI baseUri)
+    {
+        AssertArgument.isNotNullAndNotEmpty(encoding, "encoding");
+        AssertArgument.isNotNull(baseUri, "baseUri");
+        this.encoding = encoding;
+        this.parentSchemaUri = baseUri;
+    }
+    
+    /**
+     * Tries to resolve the resource.
+     * 
+     * @return LSInput  A new {@link LSInputImpl} object instance.
+     */
+    public LSInput resolveResource(final String type, final String namespaceURI, final String publicId, String systemId, final String baseURI)
+    {
+        if (log.isDebugEnabled())
+        {
+            log.debug(String.format("parentSchemaUri='%s', systemId='%s', baseURI='%s'", this.parentSchemaUri, systemId, baseURI));
+        }
+        
+        LSInputImpl inputImpl = new LSInputImpl();
+
+        URI resolvedUri;
+        if (baseURI != null)
+        {
+            // Resolve relative to the baseUri passed in. 
+            URI uri = URI.create(baseURI);
+            log.debug("Try to resolve " + uri + "/" + systemId);
+            resolvedUri = uri.resolve(systemId);
+        }
+        else
+        {
+            // Resolve the systemId (the schema path) relative to the parent schema.
+            resolvedUri = parentSchemaUri.resolve(systemId);
+        }
+        log.debug("Resolved Schema '" + resolvedUri + "'");
+        
+        inputImpl.setSystemId(resolvedUri.toString());
+        inputImpl.setCharacterStream(getReader(resolvedUri));
+        return inputImpl;
+    }
+    
+    private Reader getReader(final URI resolvedUri)
+    {
+        String scheme = resolvedUri.getScheme();
+        if (resolvedUri.isAbsolute())
+        {
+            if (scheme.equals("file"))
+            {
+                try
+                {
+                    // Try to locate the resource from the local filesystem.
+                    InputStream in = getFileInputStream(resolvedUri);
+                    return new StringReader(StreamUtils.readStreamString(in, encoding));
+                } 
+                catch (final FileNotFoundException e)
+                {
+                    log.error(e.getMessage(), e);
+                } 
+                catch (UnsupportedEncodingException e)
+                {
+                    log.error(e.getMessage(), e);
+                }
+            }
+            else if (scheme.equals("classpath"))
+            {
+                InputStream in = ClassUtil.getResourceAsStream(resolvedUri.getPath(), getClass());
+                if (in != null)
+                {
+                    try
+                    {
+                        return new StringReader(StreamUtils.readStreamString(in, encoding));
+                    } 
+                    catch (final UnsupportedEncodingException e)
+                    {
+                        log.error(e.getMessage(), e);
+                    }
+                }
+                else
+                {
+                    log.info("Could not read resource : " + resolvedUri.getPath());
+                }
+            }
+        }
+        return null;
+    }
+
+    private class LSInputImpl implements LSInput
+    {
+        private String publicId;
+        private String systemId;
+        private String baseUri;
+        private Reader reader;
+        
+        public LSInputImpl()
+        {
+        }
+        
+        public Reader getCharacterStream()
+        {
+            return reader;
+        }
+
+        /**
+         * @return null
+         */
+        public InputStream getByteStream()
+        {
+            return null;
+        }
+
+        /**
+         * @return null
+         */
+        public String getStringData()
+        {
+            return null;
+        }
+
+        public String getSystemId()
+        {
+            return systemId;
+        }
+
+        public String getBaseURI()
+        {
+            return baseUri;
+        }
+
+        public String getPublicId()
+        {
+            return publicId;
+        }
+
+        public String getEncoding()
+        {
+            return encoding;
+        }
+
+        /**
+         * @return false
+         */
+        public boolean getCertifiedText()
+        {
+            return false;
+        }
+
+        public void setBaseURI(String baseURI)
+        {
+            this.baseUri = baseURI;
+        }
+
+        public void setByteStream(InputStream byteStream)
+        {
+        }
+
+        /**
+         * @throws UnsupportedOperationException
+         */
+        public void setCertifiedText(boolean certifiedText)
+        {
+            throw new UnsupportedOperationException("setCertifiedText is not supported");
+        }
+
+        /**
+         * @throws UnsupportedOperationException
+         */
+        public void setCharacterStream(Reader characterStream)
+        {
+            this.reader = characterStream;
+        }
+
+        /**
+         * @throws UnsupportedOperationException
+         */
+        public void setEncoding(String encoding)
+        {
+            throw new UnsupportedOperationException("setEncoding is not supported");
+        }
+
+        public void setPublicId(String publicId)
+        {
+            this.publicId = publicId;
+        }
+
+        /**
+         * @throws UnsupportedOperationException
+         */
+        public void setStringData(String stringData)
+        {
+            throw new UnsupportedOperationException("setStringData is not supported");
+        }
+
+        public void setSystemId(String systemId)
+        {
+            this.systemId = systemId;
+        }
+    }
+
+    private InputStream getFileInputStream(final URI uri) throws FileNotFoundException
+    {
+        File file = new File(uri);
+        if (file.exists() && !file.isDirectory())
+        {
+            return new FileInputStream(file);
+        }
+
+        throw new FileNotFoundException("Could not locate '" + uri + "' on local filesystem");
+    }
+}

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/XMLHelper.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/XMLHelper.java	2009-03-18 09:02:17 UTC (rev 25705)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/XMLHelper.java	2009-03-18 11:57:14 UTC (rev 25706)
@@ -20,12 +20,17 @@
  */
 package org.jboss.internal.soa.esb.util;
 
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.Reader;
 import java.io.StringReader;
 import java.io.Writer;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLInputFactory;
@@ -39,10 +44,12 @@
 import javax.xml.validation.SchemaFactory;
 import javax.xml.validation.Validator;
 
+import org.apache.log4j.Logger;
 import org.jboss.internal.soa.esb.util.stax.ParsingSupport;
 import org.jboss.internal.soa.esb.util.stax.StreamHelper;
 import org.jboss.soa.esb.util.ClassUtil;
 import org.jboss.util.StringPropertyReplacer;
+import org.w3c.dom.ls.LSResourceResolver;
 import org.xml.sax.SAXException;
 
 /**
@@ -52,6 +59,8 @@
  */
 public class XMLHelper
 {
+    private static Logger log = Logger.getLogger(XMLHelper.class);
+    
     /**
      * The XML input factory.
      */
@@ -165,14 +174,106 @@
      * @return The resource schema for validation. 
      * @throws SAXException For errors during parsing.
      */
-    public static Schema getSchema(final String resource)
-        throws SAXException
+    public static Schema getSchema(final String resource) throws SAXException
     {
-        final InputStream resourceIS = ClassUtil.getResourceAsStream(resource, XMLHelper.class) ;
-        return newSchemaFactory().newSchema(new StreamSource(resourceIS)) ;
+        SchemaResolver schemaResolver;
+        try
+        {
+            URI schemaUri = getResourceUri(resource, XMLHelper.class) ;
+            log.debug("schemaUri : " + schemaUri);
+            schemaResolver = new SchemaResolver(schemaUri);
+            
+            URL schemaUrl;
+            if (schemaUri.getScheme().equals("classpath"))
+            {
+                schemaUrl = ClassUtil.getResource(schemaUri.getPath(), XMLHelper.class) ;
+            }
+            else
+            {
+                schemaUrl = schemaUri.toURL();
+            }
+            log.debug("schemaUrl : " + schemaUrl);
+            
+            return getSchema(schemaUrl, schemaResolver);
+        } 
+        catch (final URISyntaxException e)
+        {
+            throw new SAXException("URISyntaxException while trying to locate '" + resource + "'");
+        } 
+        catch (final MalformedURLException e)
+        {
+            throw new SAXException("MalformedURLException while trying to located '" + resource + "'");
+        } 
+        catch (final IOException e)
+        {
+            throw new SAXException("IOException while trying to locate '" + resource + "'");
+        }
     }
     
     /**
+     * Get the schema for the specified resource and use the specified resolver to locate 
+     * external resources, for example import schemas in the xsd.
+     * 
+     * @param resource  The schema resource to parse.
+     * @param resolver  The {@link LSResourceResolver} for locating external resources.
+     * @return Schema   The resource schema for validation. 
+     * @throws SAXException
+     * @throws IOException 
+     */
+    public static Schema getSchema(final URL resource, final LSResourceResolver resolver) throws SAXException, IOException
+    {
+        final SchemaFactory schemaFactory = newSchemaFactory();
+        schemaFactory.setResourceResolver(resolver);
+        
+        final InputStream resourceIS = resource.openStream();
+        return schemaFactory.newSchema(new StreamSource(resourceIS)) ;
+    }
+    
+    public static URI getResourceUri(final String resourceName, final Class<?> caller) throws URISyntaxException, MalformedURLException
+    {
+        File file = new File(resourceName);
+        if (file.exists() && !file.isDirectory())
+        {
+            return file.toURI();
+        }
+        
+        String resource = resourceName;
+        if (resourceName.startsWith("/"))
+        {
+            resource = resourceName.substring(1) ;
+        }
+        
+        final ClassLoader threadClassLoader = Thread.currentThread().getContextClassLoader() ;
+        if (threadClassLoader != null)
+        {
+            final URL url = threadClassLoader.getResource(resource) ;
+            if (url != null)
+            {
+                return URI.create("classpath://" + resourceName);
+            }
+        }
+        
+        final ClassLoader classLoader = caller.getClassLoader() ;
+        if (classLoader != null)
+        {
+            final URL url = classLoader.getResource(resource) ;
+            if (url != null)
+            {
+                return URI.create("classpath://" + resourceName);
+            }
+        }
+        
+        URL systemResource = ClassLoader.getSystemResource(resource);
+        if (systemResource != null)
+        {
+            return systemResource.toURI();
+        }
+        
+        return new URI(resourceName);
+    }
+
+    
+    /**
      * Get the schema for the specified resources.
      * @param resources The schema resources to parse.
      * @return The resource schema for validation. 
@@ -205,8 +306,14 @@
             validator.validate(new StreamSource(new StringReader(xml))) ;
             return true ;
         }
-        catch (final IOException ioe) {} // fall through
-        catch (final SAXException saxe)  {} // fall through
+        catch (final IOException ioe) 
+        {
+            log.debug(ioe.getMessage(), ioe);
+        } 
+        catch (final SAXException saxe)  
+        {
+            log.debug(saxe.getMessage(), saxe);
+        } 
         
         return false ;
     }

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBContractGenerator.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBContractGenerator.java	2009-03-18 09:02:17 UTC (rev 25705)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBContractGenerator.java	2009-03-18 11:57:14 UTC (rev 25706)
@@ -112,10 +112,12 @@
 						.getResourceAsStream(inXsd, ESBContractGenerator.class),
 						false, false);
 				if (doc != null) {
+				    /*
             		String schemaNs = getSchemaNs(doc);
             		if (schemaNs != null) {
                 		schemasAdded.add(schemaNs);
             		}
+            		*/
             		
 					reqMessage = addMessage(def, doc.getDocumentElement(),
 							serviceInfo.getRequestName(), "in", ++nsSuffixCounter);
@@ -131,10 +133,10 @@
 						.getResourceAsStream(outXsd, ESBContractGenerator.class),
 						false, false);
 				if (doc != null) {
-            		if (!schemasAdded.contains(getSchemaNs(doc))) {
+            		//if (!schemasAdded.contains(getSchemaNs(doc))) {
     					resMessage = addMessage(def, doc.getDocumentElement(),
 							serviceInfo.getResponseName(), "out", ++nsSuffixCounter);
-            		}
+            		//}
 				}
 			} catch (Exception e) {
 				throw new ConfigurationException("File defined in outXsd attribute '" + outXsd + "' not found in classpath.", e);
@@ -151,10 +153,10 @@
 						.getResourceAsStream(xsd, ESBContractGenerator.class),
 						false, false);
 					if (doc != null) {
-                		if (!schemasAdded.contains(getSchemaNs(doc))) {
+                		//if (!schemasAdded.contains(getSchemaNs(doc))) {
     						addFaultMessage(faultMessages, def, doc.getDocumentElement(),
 							serviceInfo.getFaultName(), "fault", ++nsSuffixCounter);
-                		}
+                		//}
 					}
 				}
 			} catch (Exception e) {

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java	2009-03-18 09:02:17 UTC (rev 25705)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java	2009-03-18 11:57:14 UTC (rev 25706)
@@ -24,12 +24,17 @@
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.FilenameFilter;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -37,7 +42,11 @@
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
+import java.util.Map.Entry;
 import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipInputStream;
 import java.util.zip.ZipOutputStream;
 
 import javax.management.MalformedObjectNameException;
@@ -48,6 +57,7 @@
 import org.jboss.deployment.SubDeployer;
 import org.jboss.deployment.SubDeployerSupport;
 import org.jboss.internal.soa.esb.publish.ContractReferencePublisher;
+import org.jboss.internal.soa.esb.util.StreamUtils;
 import org.jboss.internal.soa.esb.util.XMLHelper;
 import org.jboss.internal.soa.esb.webservice.AddressingHandler;
 import org.jboss.internal.soa.esb.webservice.ESBContractGenerator;
@@ -66,6 +76,7 @@
 import org.jboss.soa.esb.listeners.config.model.ModelAdapter;
 import org.jboss.soa.esb.listeners.config.model.ModelParser;
 import org.jboss.soa.esb.util.ClassUtil;
+import org.jboss.soa.esb.util.FileUtil;
 import org.jboss.system.ServiceControllerMBean;
 import org.jboss.system.server.ServerConfig;
 import org.jboss.system.server.ServerConfigLocator;
@@ -149,8 +160,8 @@
       }
       return false;
    }
-
-   /**
+   
+    /**
     * Returns true if this deployer can deploy the given DeploymentInfo.
     *
     * @return True if this deployer can deploy the given DeploymentInfo.
@@ -293,7 +304,7 @@
          try
          {
              Thread.currentThread().setContextClassLoader(di.localCl) ;
-             warFile = createWebserviceWars(di.shortName, model, deploymentName, publishers) ;
+             warFile = createWebserviceWars(di, model, deploymentName, publishers) ;
          }
          finally
          {
@@ -461,10 +472,11 @@
       }
    }
    
-   private File createWebserviceWars(final String esbName, final ModelAdapter model, final String deploymentName,
+   private File createWebserviceWars(final DeploymentInfo di, final ModelAdapter model, final String deploymentName,
        final List<ContractReferencePublisher> publishers)
        throws DeploymentException
    {
+       final String esbName = di.shortName;
        final List<WebserviceInfo> endpointServices =  model.getWebserviceServices() ;
        if (endpointServices != null)
        {
@@ -484,11 +496,29 @@
                    
                    for(WebserviceInfo webserviceInfo: endpointServices)
                    {
+                       final Service service = webserviceInfo.getService() ;
+                       
+                       // Copy all schemas to the wsdl directory to support imports.
+                       final File esbArchive = new File(di.watch.getFile());
+                       final Map<String, String> schemasMap = JBoss4ESBDeployer.getSchemas(esbArchive);
+                	   final String wsdlDir = "WEB-INF/wsdl/" + service.getCategory().replace('/', '_') + "/";
+                       for (Entry<String, String> schemaEntry : schemasMap.entrySet())
+                       {
+                           try 
+                           {
+                               addFile(zos, wsdlDir + schemaEntry.getKey(), schemaEntry.getValue()) ;
+                               log.debug("Added schema " + wsdlDir + schemaEntry.getKey());
+                           }
+                           catch (final ZipException e)
+                           {
+                               log.debug(e.getMessage(), e);
+                           }
+                       }
+                       
                        final ESBServiceEndpointInfo serviceInfo = new ESBServiceEndpointInfo(webserviceInfo) ;
                        final String wsdl = ESBContractGenerator.generateWSDL(webserviceInfo, serviceInfo) ;
                        addFile(zos, serviceInfo.getWSDLFileName(), wsdl) ;
                        
-                       final Service service = webserviceInfo.getService() ;
                        final String handlers = getHandlers(serviceInfo) ;
                        final boolean includeHandlers = (handlers != null) ;
                        if (includeHandlers)
@@ -550,10 +580,11 @@
                    webXml.append("</web-app>") ;
                    
                    addFile(zos, "WEB-INF/web.xml", webXml.toString()) ;
-                   zos.close() ;
                    
                    final File warFile = getESBWarFile(deploymentName, esbName, true) ;
                    
+                   zos.close() ;
+                   
                    final FileOutputStream fos = new FileOutputStream(warFile) ;
                    fos.write(baos.toByteArray()) ;
                    fos.close() ;
@@ -709,4 +740,113 @@
         }
         return result ;
     }
+
+    static Map<String, String> getSchemas(final File file) throws DeploymentException
+    {
+        if (file == null)
+        {
+            return Collections.emptyMap();
+        }
+        
+        if (file.isDirectory())
+        {
+            return getSchemasFromDirectory(file);
+        }
+        else
+        {
+            return getSchemasFromArchive(file);
+        }
+    }
+
+    static Map<String, String> getSchemasFromDirectory(final File directory) throws DeploymentException
+    {
+        if (directory != null)
+        {
+            if (directory.isDirectory())
+            {
+                final File[] schemas = directory.listFiles(new FilenameFilter() {
+                    public boolean accept(File dir, String name)
+                    {
+                        return isXsd(name);
+                    }
+                });
+                if (schemas.length > 0)
+                {
+                    final Map<String, String> schemasMap = new HashMap<String, String>();
+                    for (File file : schemas)
+                    {
+                        try
+                        {
+                            schemasMap.put(file.getName(), FileUtil.readTextFile(file));
+                        } 
+                        catch (final IOException e)
+                        {
+                            throw new DeploymentException("IOException while trying to read xsd '" + file.getName() + "'", e);
+                        }
+                    }
+                    return schemasMap;
+                }
+            }
+        }
+        
+        return Collections.emptyMap();
+    }
+
+    private static boolean isXsd(final String fileName)
+    {
+        return fileName.endsWith(".xsd");
+    }
+
+    static Map<String, String> getSchemasFromArchive(final File archive) throws DeploymentException
+    {
+        if (archive == null || !archive.isFile() || !archive.getName().endsWith(".esb"))
+        {
+            return Collections.emptyMap();
+        }
+        
+        final HashMap<String, String> schemas = new HashMap<String, String>();
+        final ZipFile zip = getZipFile(archive);
+                
+        final Enumeration<? extends ZipEntry> entries = zip.entries();
+        while (entries.hasMoreElements()) 
+        {
+            ZipEntry entry = entries.nextElement();
+                    
+            final String fileName = entry.getName();
+            if (isXsd(fileName))
+            {
+                InputStream in = null;
+                try
+                {
+                    in = zip.getInputStream(entry);
+                    schemas.put(fileName, StreamUtils.readStreamString(in, "UTF-8"));
+                } 
+                catch (final IOException e)
+                {
+                    throw new DeploymentException("IOException while trying to read from file '" + fileName + "' from archive '" + archive + "'", e);
+                }
+                finally
+                {
+                    try { in.close(); } catch (IOException ignore) { log.error("Error while trying to close in stream for file '" + fileName + "'", ignore); }
+                }
+            }
+        }
+        return schemas;
+    }
+
+    private static ZipFile getZipFile(final File archive) throws DeploymentException
+    {
+        try
+        {
+            return new ZipFile(archive);
+        } 
+        catch (ZipException e)
+        {
+            throw new DeploymentException(e.getMessage(), e);
+        } 
+        catch (IOException e)
+        {
+            throw new DeploymentException(e.getMessage(), e);
+        }
+    }
 }

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java	2009-03-18 09:02:17 UTC (rev 25705)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java	2009-03-18 11:57:14 UTC (rev 25706)
@@ -34,6 +34,7 @@
 import org.apache.log4j.Logger;
 import org.jboss.internal.soa.esb.services.security.SecurityContextPropagator;
 import org.jboss.internal.soa.esb.services.security.SecurityContextPropagatorFactory;
+import org.jboss.internal.soa.esb.util.SchemaResolver;
 import org.jboss.internal.soa.esb.util.XMLHelper;
 import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.actions.ActionLifecycle;
@@ -199,7 +200,7 @@
 			final String outXsd = config.getAttribute(ListenerTagNames.OUT_XSD_ATTRIBUTE_TAG) ;
 			try
 			{
-				responseSchema = (outXsd == null ? null : XMLHelper.getSchema(outXsd)) ;
+				responseSchema = (outXsd == null ? null : XMLHelper.getSchema(outXsd));
 			}
 			catch (final SAXException saxe)
 			{

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/SchemaResolverUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/SchemaResolverUnitTest.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/SchemaResolverUnitTest.java	2009-03-18 11:57:14 UTC (rev 25706)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.internal.soa.esb.util;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.Reader;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.w3c.dom.ls.LSInput;
+
+/**
+ * Unit test for {@link SchemaResolver}.
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class SchemaResolverUnitTest
+{
+    private SchemaResolver schemaResolver;
+    
+    @Before
+    public void setup() throws URISyntaxException
+    {
+        URL resource = getClass().getResource("/org/jboss/internal/soa/esb/util/types/custom-type.xsd");
+        schemaResolver = new SchemaResolver(resource.toURI());
+    }
+    
+    @Test
+    public void testSchemaOnClasspath()
+    {
+        final String type = "http://www.w3.org/2001/XMLSchema";
+        final String systemId = "custom-type.xsd";
+        
+        LSInput lsInput = schemaResolver.resolveResource(type, "http://www.jboss.org/custom", null, systemId, null);
+        Reader characterStream = lsInput.getCharacterStream();
+        assertNotNull(characterStream);
+    }
+    
+    @Test
+    public void testSchemaWithHttpUrlSystemId()
+    {
+        final String type = "http://www.w3.org/2001/XMLSchema";
+        
+        final String systemId = "http://www.jboss.org/esb/custom-type.xsd";
+        
+        LSInput lsInput = schemaResolver.resolveResource(type, "http://www.jboss.org/custom", null, systemId, null);
+        assertNull(lsInput.getCharacterStream());
+        assertNotNull(lsInput.getSystemId());
+    }
+    
+    public static junit.framework.Test suite()
+    {
+        return new JUnit4TestAdapter(SchemaResolverUnitTest.class);
+    }
+
+}

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/XMLHelperUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/XMLHelperUnitTest.java	2009-03-18 09:02:17 UTC (rev 25705)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/XMLHelperUnitTest.java	2009-03-18 11:57:14 UTC (rev 25706)
@@ -20,23 +20,50 @@
  */
 package org.jboss.internal.soa.esb.util;
 
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
+import java.net.URL;
 import java.util.Properties;
 
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import javax.xml.stream.XMLStreamReader;
+import javax.xml.validation.Schema;
 
+import junit.framework.JUnit4TestAdapter;
+
+import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.testutils.StringUtils;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.Request;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.AbstractHandler;
+import org.xml.sax.SAXException;
 
-import junit.framework.TestCase;
-
 /**
  * Tests associated with the XML helper class.
  * 
  * @author <a href='mailto:kevin.conner at jboss.com'>Kevin Conner</a>
  */
-public class XMLHelperUnitTest extends TestCase
+public class XMLHelperUnitTest
 {
+    private static String returnUrl;
+    private static Server server;
+    
+    private static final int PORT = 9999;
+    private static final String CONTEXT = "schematest";
+
+    @Test
     public void testReplaceSystemProperties()
         throws Exception
     {
@@ -64,4 +91,98 @@
         final boolean match = StringUtils.compareXMLContent(expectedContents, contents) ;
         assertTrue("System property replacement", match) ;
     }
+    
+    @Test
+    public void testValidateSchemaOnCPWithImportsFromSubdir() throws ConfigurationException, UnsupportedEncodingException, SAXException
+    {
+        final Schema schema = XMLHelper.getSchema("/org/jboss/internal/soa/esb/util/schemas/request.xsd");
+        
+        final String xml = StreamUtils.readStreamString(getClass().getResourceAsStream("sample-request.xml"), "UTF-8");
+        assertTrue(XMLHelper.validate(schema, xml));
+    }
+    
+    @Test
+    public void testValidateSchemaOnCPWithImports() throws ConfigurationException, UnsupportedEncodingException, SAXException
+    {
+        final Schema schema = XMLHelper.getSchema("/org/jboss/internal/soa/esb/util/request2.xsd");
+        
+        final String xml = StreamUtils.readStreamString(getClass().getResourceAsStream("sample-request.xml"), "UTF-8");
+        assertTrue(XMLHelper.validate(schema, xml));
+    }
+    
+    @Test
+    public void testValidateSchemaOnFSWithImports() throws ConfigurationException, UnsupportedEncodingException, SAXException
+    {
+        URL resource = getClass().getResource("/org/jboss/internal/soa/esb/util/request2.xsd");
+        File file = new File(resource.getFile());
+        final Schema schema = XMLHelper.getSchema(file.getAbsolutePath());
+        
+        final String xml = StreamUtils.readStreamString(getClass().getResourceAsStream("sample-request.xml"), "UTF-8");
+        assertTrue(XMLHelper.validate(schema, xml));
+    }
+    
+    /**
+     * This is an integration test that is intended to be run manually.
+     */
+    @Test
+    public void testValidateSchemaHttpWithImports() throws ConfigurationException, UnsupportedEncodingException, SAXException
+    {
+        final Schema schema = XMLHelper.getSchema("http://localhost:9999/schemastest/request2.xsd");
+        
+        final String xml = StreamUtils.readStreamString(getClass().getResourceAsStream("sample-request.xml"), "UTF-8");
+        assertTrue(XMLHelper.validate(schema, xml));
+    }
+    
+    
+    @BeforeClass
+    public static void setupJetty() throws Exception
+    {
+        server = new Server(PORT);  
+        Handler handler = new AbstractHandler()   
+        {  
+            public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch)   throws IOException, ServletException  
+            {  
+                handleHttpRequest(target, request, response);  
+            }
+        };  
+   
+        returnUrl = "http://localhost:" + Integer.toString(PORT) + "/" + CONTEXT;  
+        server.setHandler(handler);  
+        server.start();  
+    }
+    
+    public static void handleHttpRequest(String target, HttpServletRequest request, HttpServletResponse response)  
+    {  
+        try  
+        {  
+            String pathInfo = request.getPathInfo();
+            String file = pathInfo.substring(pathInfo.indexOf("/" + CONTEXT) + CONTEXT.length() + 3);
+            file = "/org/jboss/internal/soa/esb/util/" + file;
+            InputStream in = org.jboss.soa.esb.util.ClassUtil.getResourceAsStream(file, XMLHelperUnitTest.class);
+            String xsd = StreamUtils.readStreamString(in, "UTF-8");
+            response.setContentType("text/html");  
+            response.getOutputStream().write(xsd.getBytes());
+            response.setStatus(HttpServletResponse.SC_OK);  
+            ((Request)request).setHandled(true);  
+        }  
+        catch(Exception ignore)  
+        {  
+        }  
+    }  
+    
+    @AfterClass
+    public static void shutdownJetty() 
+    {
+        try
+        {
+            server.stop();
+        } 
+        catch (Exception ignore) { }
+    }
+    
+    public static junit.framework.Test suite()
+    {
+        return new JUnit4TestAdapter(XMLHelperUnitTest.class);
+    }
+    
 }

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/request2.xsd
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/request2.xsd	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/request2.xsd	2009-03-18 11:57:14 UTC (rev 25706)
@@ -0,0 +1,18 @@
+<xs:schema version="1.0" 
+    targetNamespace="http://www.jboss.org/sayHi" 
+    xmlns:x1="http://www.jboss.org/sayHi" 
+    xmlns:cust="http://www.jboss.org/custom-request" 
+    xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+
+  <xs:import namespace="http://www.jboss.org/custom-request" schemaLocation="./types/custom-type.xsd"/>
+  
+  <xs:element name="sayHi" type="x1:sayHi"/>
+  
+  <xs:complexType name="sayHi">
+    <xs:sequence>
+      <xs:element name="arg0" type="xs:string" minOccurs="1"/>
+	  <xs:element ref="cust:customType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  
+</xs:schema>


Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/request2.xsd
___________________________________________________________________
Name: svn:mergeinfo
   + 

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/sample-request.xml
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/sample-request.xml	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/sample-request.xml	2009-03-18 11:57:14 UTC (rev 25706)
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<say:sayHi 
+    xmlns:say="http://www.jboss.org/sayHi" 
+    xmlns:cust="http://www.jboss.org/custom-request" 
+    xmlns:sub="http://www.jboss.org/custom-subtype" 
+    xmlns:t="http://www.jboss.org/type2" 
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+    
+    <say:arg0>HelloWorld</say:arg0>
+    
+    <cust:customType>
+           <cust:type>Some text</cust:type>
+           <sub:subType>
+               <sub:type>Some more text</sub:type>
+               <t:type2>
+                   <t:type>Even more text</t:type>
+               </t:type2>
+           </sub:subType>
+    </cust:customType>
+    
+</say:sayHi>
\ No newline at end of file

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/schemas/request.xsd
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/schemas/request.xsd	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/schemas/request.xsd	2009-03-18 11:57:14 UTC (rev 25706)
@@ -0,0 +1,18 @@
+<xs:schema version="1.0" 
+    targetNamespace="http://www.jboss.org/sayHi" 
+    xmlns:x1="http://www.jboss.org/sayHi" 
+    xmlns:cust="http://www.jboss.org/custom-request" 
+    xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+
+  <xs:import namespace="http://www.jboss.org/custom-request" schemaLocation="../types/custom-type.xsd"/>
+  
+  <xs:element name="sayHi" type="x1:sayHi"/>
+  
+  <xs:complexType name="sayHi">
+    <xs:sequence>
+      <xs:element name="arg0" type="xs:string" minOccurs="1"/>
+	  <xs:element ref="cust:customType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  
+</xs:schema>

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/types/custom-type.xsd
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/types/custom-type.xsd	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/types/custom-type.xsd	2009-03-18 11:57:14 UTC (rev 25706)
@@ -0,0 +1,18 @@
+<xs:schema version="1.0" 
+    targetNamespace="http://www.jboss.org/custom-request" 
+    xmlns:cust="http://www.jboss.org/custom-request"  
+    xmlns:sub="http://www.jboss.org/custom-subtype"  
+    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+    elementFormDefault="qualified">
+
+  <xs:import namespace="http://www.jboss.org/custom-subtype" schemaLocation="./subtypes/custom-subtype-type.xsd"/>
+  
+  <xs:element name="customType" type="cust:CustomType"/>
+  
+  <xs:complexType name="CustomType">
+    <xs:sequence>
+      <xs:element name="type" type="xs:string" minOccurs="1"/>
+	  <xs:element ref="sub:subType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>
\ No newline at end of file

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/types/subtypes/custom-subtype-type.xsd
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/types/subtypes/custom-subtype-type.xsd	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/types/subtypes/custom-subtype-type.xsd	2009-03-18 11:57:14 UTC (rev 25706)
@@ -0,0 +1,18 @@
+<xs:schema version="1.0" 
+    targetNamespace="http://www.jboss.org/custom-subtype" 
+    xmlns:sub="http://www.jboss.org/custom-subtype" 
+    xmlns:t="http://www.jboss.org/type2" 
+    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+    elementFormDefault="qualified">
+    
+  <xs:import namespace="http://www.jboss.org/type2" schemaLocation="../type2-type.xsd"/>
+
+  <xs:element name="subType" type="sub:SubType"/>
+  
+  <xs:complexType name="SubType">
+    <xs:sequence>
+      <xs:element name="type" type="xs:string" minOccurs="0"/>
+	  <xs:element ref="t:type2" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/types/type2-type.xsd
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/types/type2-type.xsd	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/types/type2-type.xsd	2009-03-18 11:57:14 UTC (rev 25706)
@@ -0,0 +1,14 @@
+<xs:schema version="1.0" 
+    targetNamespace="http://www.jboss.org/type2" 
+    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+    xmlns:t="http://www.jboss.org/type2" 
+    elementFormDefault="qualified">
+
+  <xs:element name="type2" type="t:Type2"/>
+  
+  <xs:complexType name="Type2">
+    <xs:sequence>
+      <xs:element name="type" type="xs:string" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/ESBContractGeneratorUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/ESBContractGeneratorUnitTest.java	2009-03-18 09:02:17 UTC (rev 25705)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/ESBContractGeneratorUnitTest.java	2009-03-18 11:57:14 UTC (rev 25706)
@@ -23,7 +23,11 @@
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
+import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import javax.wsdl.Binding;
 import javax.wsdl.Definition;
@@ -40,8 +44,14 @@
 import org.jboss.soa.esb.listeners.config.Generator;
 import org.jboss.soa.esb.listeners.config.WebserviceInfo;
 import org.jboss.soa.esb.util.ClassUtil;
+import org.jboss.util.xml.DOMUtils;
+import org.milyn.xml.DomUtils;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
 import org.xml.sax.InputSource;
 
+import com.ibm.wsdl.extensions.schema.SchemaImpl;
+
 public class ESBContractGeneratorUnitTest extends TestCase {
     public void testRequestResponseFault() throws Exception {
         executeTest("jbossesb_config_06.xml") ;
@@ -67,12 +77,14 @@
         executeTest("jbossesb_config_08.110.xml") ;
     }
     
+    /*
     public void testDuplicateSchemas() throws Exception {
         Definition def = executeTest("jbossesb_duplicate_schemas.xml") ;
         Types types = def.getTypes();
         List schemas = types.getExtensibilityElements();
-        assertEquals(1, schemas.size());
+        //assertEquals(1, schemas.size());
     }
+    */
 
     @SuppressWarnings("unchecked")
     public void _testWSAExtensions110() throws Exception {

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployerUnitTest.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployerUnitTest.java	2009-03-18 11:57:14 UTC (rev 25706)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.config;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Map;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.jboss.deployment.DeploymentException;
+import org.junit.Test;
+
+/**
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class JBoss4ESBDeployerUnitTest
+{
+    @Test
+    public void getSchemasFromFileShouldReturnEmptyMap() throws DeploymentException
+    {
+        File file = new File(getClass().getResource("schemasDir/mock.xsd").getFile());
+        Map<String, String> schemas = JBoss4ESBDeployer.getSchemasFromDirectory(file);
+        assertTrue(schemas.isEmpty());
+    }
+    
+    @Test
+    public void getSchemas() throws DeploymentException
+    {
+        File directory = new File(getClass().getResource("schemasDir").getFile());
+        Map<String, String> schemas = JBoss4ESBDeployer.getSchemasFromDirectory(directory);
+        assertTrue(schemas.containsKey("mock.xsd"));
+    }
+    
+    @Test
+    public void getSchemasFromArchive() throws DeploymentException
+    {
+        URL resource = getClass().getResource("schemasDir.esb");
+        File archive = new File(resource.getFile());
+        Map<String, String> schemas = JBoss4ESBDeployer.getSchemasFromArchive(archive);
+        assertTrue(schemas.containsKey("mock.xsd"));
+    }
+    
+    @Test
+    public void getSchemasFromArchiveNullArchive() throws DeploymentException
+    {
+        Map<String, String> schemas = JBoss4ESBDeployer.getSchemasFromArchive(null);
+        assertTrue(schemas.isEmpty());
+    }
+    
+    public static junit.framework.Test suite()
+    {
+        return new JUnit4TestAdapter(JBoss4ESBDeployerUnitTest.class);
+    }
+
+}

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir/mock.xsd
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir/mock.xsd	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir/mock.xsd	2009-03-18 11:57:14 UTC (rev 25706)
@@ -0,0 +1,9 @@
+<xs:schema version="1.0" targetNamespace="http://www.jboss.org/custom" xmlns:x1="http://www.jboss.org/custom"  xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+  <xs:element name="customType" type="x1:type"/>
+  <xs:complexType name="type">
+    <xs:sequence>
+      <xs:element name="customType" type="xs:string" minOccurs="1"/>
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>
+

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir/request.xsd
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir/request.xsd	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir/request.xsd	2009-03-18 11:57:14 UTC (rev 25706)
@@ -0,0 +1,9 @@
+<xs:schema version="1.0" targetNamespace="http://www.jboss.org/custom" xmlns:x1="http://www.jboss.org/custome"  xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+  <xs:element name="customType" type="x1:type"/>
+  <xs:complexType name="type">
+    <xs:sequence>
+      <xs:element name="customType" type="xs:string" minOccurs="1"/>
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>
+

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir.esb
===================================================================
(Binary files differ)


Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir.esb
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/build.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/build.xml	2009-03-18 09:02:17 UTC (rev 25705)
+++ labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/build.xml	2009-03-18 11:57:14 UTC (rev 25706)
@@ -6,7 +6,7 @@
 	</description>
 	
 	<!-- additional deploys -->
-	<property name="additional.deploys" value="*.xsd"/>
+	<property name="additional.deploys" value="*.xsd types/**/*.xsd"/>
 
 	<!-- Import the base Ant build script... -->
 	<import file="../conf/base-build.xml"/>

Modified: labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/error-soap-message.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/error-soap-message.xml	2009-03-18 09:02:17 UTC (rev 25705)
+++ labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/error-soap-message.xml	2009-03-18 11:57:14 UTC (rev 25706)
@@ -1,9 +1,28 @@
-<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
-			xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
-			xmlns:xsd="http://www.w3.org/2001/XMLSchema"
-			xmlns:say="http://www.jboss.org/sayHi">
+<soap:Envelope
+            xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+            xmlns:say="http://www.jboss.org/sayHi"
+            xmlns:cust="http://www.jboss.org/custom-request"
+            xmlns:sub="http://www.jboss.org/custom-subtype"
+            xmlns:t="http://www.jboss.org/type2">
   <soap:Body>
-      <say:sayHi><say:arg0>Error</say:arg0></say:sayHi>
+
+	<say:sayHi>
+		<say:arg0>Error</say:arg0>
+
+		<cust:customType>
+           <cust:type>Some text</cust:type>
+           <sub:subType>
+               <sub:type>Some more text</sub:type>
+               <t:type2>
+                   <t:type>Even more text</t:type>
+               </t:type2>
+           </sub:subType>
+		</cust:customType>
+	</say:sayHi>
+
   </soap:Body>
 
-</soap:Envelope> 
+</soap:Envelope>
+

Modified: labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/jboss-esb.xml	2009-03-18 09:02:17 UTC (rev 25705)
+++ labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/jboss-esb.xml	2009-03-18 11:57:14 UTC (rev 25706)
@@ -25,7 +25,7 @@
                               maxThreads="1"
                 />
             </listeners>
-            <actions  inXsd="/request.xsd" outXsd="/response.xsd" faultXsd="/fault.xsd">
+            <actions  inXsd="/request.xsd" outXsd="/response.xsd" faultXsd="/fault.xsd" validate="true">
                    <action name="action" class="org.jboss.soa.esb.samples.quickstart.publishAsWebservice.ESBWSListenerAction" process="displayMessage"/>  
             </actions>
         </service>

Modified: labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/readme.txt
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/readme.txt	2009-03-18 09:02:17 UTC (rev 25705)
+++ labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/readme.txt	2009-03-18 11:57:14 UTC (rev 25706)
@@ -3,6 +3,9 @@
   The purpose of the publish_as_webservice quickstart sample is to demonstrate how to 
   publish a esb service as a web service. 
 
+  This quickstart also demonstrates how messages can be validate by JBossESB by configuring
+  a service for validation and how schemas imports are used.
+
 Running this quickstart:
 ========================
   Please refer to 'ant help-quickstarts' for prerequisites about the quickstarts
@@ -31,3 +34,24 @@
   2. sendesb ant target
 	 This target will call the SendEsbMessage twice. The first call will be with a valid message body content
 	 and the second will generate a FaultMessageException.
+
+What to look for in this quickstart
+===================================
+  1. Message validation
+	 Validation of request and response messages can be enabled by setting the 'validate' attribute to true.
+	 For example:
+	 <actions  inXsd="/request.xsd" outXsd="/response.xsd" faultXsd="/fault.xsd" validate="true">
+		...
+	 </actions>
+
+  2. Schema imports
+	 Schema import elements are used to add multiple schemas with different target namespaces to a document.
+
+	 a) Take a look the import element in request.xsd:
+	   <xs:import namespace="http://www.jboss.org/custom-request" schemaLocation="custom-request-type.xsd"/>
+	   This custom-request-type.xsd should in this case be packaged in the root of the .esb archive. 
+
+	 b) Another example can be found in response.xsd:
+	   <xs:import namespace="http://www.jboss.org/custom-response" schemaLocation="imports/custom-response-type.xsd"/>
+	   In this case the xsd has is located in a directory named 'imports' in the .esb archive.
+

Modified: labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/request.xsd
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/request.xsd	2009-03-18 09:02:17 UTC (rev 25705)
+++ labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/request.xsd	2009-03-18 11:57:14 UTC (rev 25706)
@@ -1,8 +1,19 @@
-<xs:schema version="1.0" targetNamespace="http://www.jboss.org/sayHi" xmlns:x1="http://www.jboss.org/sayHi"  xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+<xs:schema version="1.0" 
+    targetNamespace="http://www.jboss.org/sayHi" 
+    xmlns:x1="http://www.jboss.org/sayHi" 
+    xmlns:cust="http://www.jboss.org/custom-request" 
+    xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+
+  <xs:import namespace="http://www.jboss.org/custom-request" schemaLocation="./types/custom-request-type.xsd"/>
+  
   <xs:element name="sayHi" type="x1:sayHi"/>
+  
   <xs:complexType name="sayHi">
     <xs:sequence>
       <xs:element name="arg0" type="xs:string" minOccurs="1"/>
+	  <xs:element ref="cust:customType" minOccurs="0"/>
     </xs:sequence>
   </xs:complexType>
+  
 </xs:schema>
+

Modified: labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/response.xsd
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/response.xsd	2009-03-18 09:02:17 UTC (rev 25705)
+++ labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/response.xsd	2009-03-18 11:57:14 UTC (rev 25706)
@@ -1,8 +1,17 @@
-<xs:schema version="1.0" targetNamespace="http://www.jboss.org/sayHi" xmlns:x1="http://www.jboss.org/sayHi"  xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+<xs:schema version="1.0" 
+	targetNamespace="http://www.jboss.org/sayHi" 
+	xmlns:x1="http://www.jboss.org/sayHi"  
+	xmlns:cust="http://www.jboss.org/custom-response"
+	xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+	elementFormDefault="qualified">
+
+  <xs:import namespace="http://www.jboss.org/custom-response" schemaLocation="types/custom-response-type.xsd"/>
+
   <xs:element name="sayHiResponse" type="x1:sayHiResponse"/>
   <xs:complexType name="sayHiResponse">
     <xs:sequence>
       <xs:element name="arg0" type="xs:string" minOccurs="0"/>
+	  <xs:element name="importedElement" type="cust:customType" minOccurs="0"/>
     </xs:sequence>
   </xs:complexType>
 </xs:schema>

Modified: labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/soap-userpass-message.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/soap-userpass-message.xml	2009-03-18 09:02:17 UTC (rev 25705)
+++ labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/soap-userpass-message.xml	2009-03-18 11:57:14 UTC (rev 25706)
@@ -1,11 +1,29 @@
-<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
+<soap:Envelope 
+			xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
 			xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 			xmlns:xsd="http://www.w3.org/2001/XMLSchema"
-			xmlns:say="http://www.jboss.org/sayHi">
+			xmlns:say="http://www.jboss.org/sayHi" 
+			xmlns:cust="http://www.jboss.org/custom-request" 
+			xmlns:sub="http://www.jboss.org/custom-subtype" 
+			xmlns:t="http://www.jboss.org/type2">
   <soap:Body>
-      <say:sayHi>
-		<say:arg0>HelloWorld</say:arg0>
-	  </say:sayHi>"
+
+ <say:sayHi>
+
+	<say:arg0>HelloWorld</say:arg0>
+
+    <cust:customType>
+           <cust:type>Some text</cust:type>
+           <sub:subType>
+               <sub:type>Some more text</sub:type>
+               <t:type2>
+                   <t:type>Even more text</t:type>
+               </t:type2>
+           </sub:subType>
+    </cust:customType>
+
+ </say:sayHi>
+
   </soap:Body>
 
 </soap:Envelope> 

Added: labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/types/custom-request-type.xsd
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/types/custom-request-type.xsd	                        (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/types/custom-request-type.xsd	2009-03-18 11:57:14 UTC (rev 25706)
@@ -0,0 +1,18 @@
+<xs:schema version="1.0" 
+    targetNamespace="http://www.jboss.org/custom-request" 
+    xmlns:cust="http://www.jboss.org/custom-request"  
+    xmlns:sub="http://www.jboss.org/custom-subtype"  
+    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+    elementFormDefault="qualified">
+
+  <xs:import namespace="http://www.jboss.org/custom-subtype" schemaLocation="./subtypes/custom-subtype-type.xsd"/>
+  
+  <xs:element name="customType" type="cust:CustomType"/>
+  
+  <xs:complexType name="CustomType">
+    <xs:sequence>
+      <xs:element name="type" type="xs:string" minOccurs="1"/>
+	  <xs:element ref="sub:subType" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>

Added: labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/types/custom-response-type.xsd
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/types/custom-response-type.xsd	                        (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/types/custom-response-type.xsd	2009-03-18 11:57:14 UTC (rev 25706)
@@ -0,0 +1,8 @@
+<xs:schema version="1.0" targetNamespace="http://www.jboss.org/custom-response" xmlns:cust="http://www.jboss.org/custom-response"  xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+
+  <xs:complexType name="customType">
+    <xs:sequence>
+      <xs:element name="type" type="xs:string" minOccurs="1"/>
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>

Added: labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/types/subtypes/custom-subtype-type.xsd
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/types/subtypes/custom-subtype-type.xsd	                        (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/types/subtypes/custom-subtype-type.xsd	2009-03-18 11:57:14 UTC (rev 25706)
@@ -0,0 +1,19 @@
+<xs:schema version="1.0" 
+    targetNamespace="http://www.jboss.org/custom-subtype" 
+    xmlns:sub="http://www.jboss.org/custom-subtype" 
+    xmlns:t="http://www.jboss.org/type2" 
+    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+    elementFormDefault="qualified">
+    
+  <xs:import namespace="http://www.jboss.org/type2" schemaLocation="../type2-type.xsd"/>
+
+  <xs:element name="subType" type="sub:SubType"/>
+  
+  <xs:complexType name="SubType">
+    <xs:sequence>
+      <xs:element name="type" type="xs:string" minOccurs="0"/>
+	  <xs:element ref="t:type2" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>
+

Added: labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/types/type2-type.xsd
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/types/type2-type.xsd	                        (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/publish_as_webservice/types/type2-type.xsd	2009-03-18 11:57:14 UTC (rev 25706)
@@ -0,0 +1,15 @@
+<xs:schema version="1.0" 
+    targetNamespace="http://www.jboss.org/type2" 
+    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+    xmlns:t="http://www.jboss.org/type2" 
+    elementFormDefault="qualified">
+
+  <xs:element name="type2" type="t:Type2"/>
+  
+  <xs:complexType name="Type2">
+    <xs:sequence>
+      <xs:element name="type" type="xs:string" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>
+

Added: labs/jbossesb/trunk/testlib/jetty-6.1.15.jar
===================================================================
(Binary files differ)


Property changes on: labs/jbossesb/trunk/testlib/jetty-6.1.15.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossesb/trunk/testlib/jetty-util-6.1.15.jar
===================================================================
(Binary files differ)


Property changes on: labs/jbossesb/trunk/testlib/jetty-util-6.1.15.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream




More information about the jboss-svn-commits mailing list