[jboss-svn-commits] JBL Code SVN: r25582 - in labs/jbossesb/branches/JBESB_4_4_GA_FP/product: rosetta/src/org/jboss/soa/esb/listeners/config and 6 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Mar 11 02:45:38 EDT 2009


Author: beve
Date: 2009-03-11 02:45:37 -0400 (Wed, 11 Mar 2009)
New Revision: 25582

Added:
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/internal/soa/esb/util/SchemaResolver.java
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/SchemaResolverUnitTest.java
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/custom-type.xsd
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/request.xsd
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/sample-request.xml
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployerUnitTest.java
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir.esb
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir/
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir/mock.xsd
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir/request.xsd
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/custom-request-type.xsd
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/imports/
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/imports/custom-response-type.xsd
Modified:
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/internal/soa/esb/util/StreamUtils.java
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/internal/soa/esb/util/XMLHelper.java
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/XMLHelperUnitTest.java
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/build.xml
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/error-soap-message.xml
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/jboss-esb.xml
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/readme.txt
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/request.xsd
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/response.xsd
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/soap-userpass-message.xml
Log:
Work for https://jira.jboss.org/jira/browse/JBESB-2217 "Implement support for schema import in EBWS WSDL generation/action pipeline validation."


Added: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/internal/soa/esb/util/SchemaResolver.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/internal/soa/esb/util/SchemaResolver.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/internal/soa/esb/util/SchemaResolver.java	2009-03-11 06:45:37 UTC (rev 25582)
@@ -0,0 +1,289 @@
+/*
+ * 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 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;
+
+    /**
+     * Constructs an instance with an encoding of UTF-8.
+     */
+    public SchemaResolver()
+    {
+        this("UTF-8");
+    }
+
+    /**
+     * Constructs an instance with the specified encoding.
+     * 
+     * @param encoding The encoding to use when reading resources. Must not be null;
+     */
+    public SchemaResolver(final String encoding)
+    {
+        AssertArgument.isNotNullAndNotEmpty(encoding, "encoding");
+        this.encoding = encoding;
+    }
+    
+    /**
+     * 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, final String systemId, final String baseURI)
+    {
+        if (log.isDebugEnabled())
+        {
+            log.debug(String.format("type='%s', namespaceURI='%s', publicId='%s', systemId='%s', baseURI='%s'", type, namespaceURI, publicId, systemId, baseURI));
+        }
+        
+        return new LSInputImpl(publicId, systemId, baseURI);
+    }
+
+    /**
+     * Concrete {@link LSInput} implementation.
+     * <p/>
+     * 
+     * From {@link LSInput} javadoc:<br>
+     * The LSParser will use the LSInput object to determine how to read data.
+     * The LSParser will look at the different inputs specified in the LSInput
+     * in the following order to know which one to read from, the first one that
+     * is not null and not an empty string will be used: </p>
+     * 
+     * The following will be returned by this LSInput implmentation:
+     * <lu> 
+     * <li><i>getCharacterStream</i> Reader for the schema located on the local file system or on the classpath. Or null in the resource cannot be located.</li> 
+     * <li><i>getByteStream</i> null</li> 
+     * <li><i>getStringData</i> null</li> 
+     * <li><i>getSystemId</i> Will return the systemId which can be used by the LSParser to resolve the resource</li>
+     * <li><i>getPublicId</i> null</li>
+     */
+    private class LSInputImpl implements LSInput
+    {
+        private final String publicId;
+        private final String systemId;
+        private final String baseURI;
+
+        public LSInputImpl(final String publicId, final String systemId, final String baseURI)
+        {
+            this.publicId = publicId;
+            this.systemId = systemId;
+            this.baseURI = baseURI;
+        }
+        
+        /**
+         * Will try to locate the resouce identified by systemId by first trying
+         * to locate it on the local filesystem, and failing to find it there it
+         * will try the classpath.
+         * 
+         * @return Reader Either a reader that is able to read the resource
+         *         identified by systemId or null if the resource could not be
+         *         located.
+         */
+        public Reader getCharacterStream()
+        {
+            if (systemId == null)
+            {
+                return null;
+            }
+
+            InputStream in = null;
+            try
+            {
+                // Try to locate the resource from the local filesystem.
+                in = getFileInputStream(systemId);
+            } 
+            catch (final FileNotFoundException e)
+            {
+                // Try to locate the resouce from the classpath
+                in = ClassUtil.getResourceAsStream(systemId, getClass());
+                if (in == null)
+                {
+                    // Try the root of the classpath by prefixing the systemId with "/".
+                    // This would be the case for example if a schema import was specified
+                    // as relative without a slash.
+                    in = ClassUtil.getResourceAsStream("/" + systemId, getClass());
+                }
+            }
+
+            if (in != null)
+            {
+                try
+                {
+                    return new StringReader(StreamUtils.readStreamString(in, encoding));
+                } 
+                catch (final UnsupportedEncodingException e)
+                {
+                    log.error(e.getMessage(), e);
+                }
+            }
+
+            // getSystemId will return the systemId and try to resolve the URI.
+            return null;
+        }
+
+        /**
+         * @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;
+        }
+
+        /**
+         * @throws UnsupportedOperationException
+         */
+        public void setBaseURI(String baseURI)
+        {
+            throw new UnsupportedOperationException("setBaseURI is not supported");
+        }
+
+        /**
+         * @throws UnsupportedOperationException
+         */
+        public void setByteStream(InputStream byteStream)
+        {
+            throw new UnsupportedOperationException("setBaseStream is not supported");
+        }
+
+        /**
+         * @throws UnsupportedOperationException
+         */
+        public void setCertifiedText(boolean certifiedText)
+        {
+            throw new UnsupportedOperationException("setCertifiedText is not supported");
+        }
+
+        /**
+         * @throws UnsupportedOperationException
+         */
+        public void setCharacterStream(Reader characterStream)
+        {
+            throw new UnsupportedOperationException("setCharacterStream is not supported");
+        }
+
+        /**
+         * @throws UnsupportedOperationException
+         */
+        public void setEncoding(String encoding)
+        {
+            throw new UnsupportedOperationException("setEncoding is not supported");
+        }
+
+        /**
+         * @throws UnsupportedOperationException
+         */
+        public void setPublicId(String publicId)
+        {
+            throw new UnsupportedOperationException("setPublicId is not supported");
+        }
+
+        /**
+         * @throws UnsupportedOperationException
+         */
+        public void setStringData(String stringData)
+        {
+            throw new UnsupportedOperationException("setStringData is not supported");
+        }
+
+        /**
+         * @throws UnsupportedOperationException
+         */
+        public void setSystemId(String systemId)
+        {
+            throw new UnsupportedOperationException("setSystemId is not supported");
+        }
+    }
+
+    private InputStream getFileInputStream(final String systemId) throws FileNotFoundException
+    {
+        File file = new File(systemId);
+        if (file.exists() && !file.isDirectory())
+        {
+            return new FileInputStream(file);
+        }
+
+        throw new FileNotFoundException("Could not locate '" + systemId + "' on local filesystem");
+    }
+}

Modified: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/internal/soa/esb/util/StreamUtils.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/internal/soa/esb/util/StreamUtils.java	2009-03-11 06:27:56 UTC (rev 25581)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/internal/soa/esb/util/StreamUtils.java	2009-03-11 06:45:37 UTC (rev 25582)
@@ -112,6 +112,10 @@
      * @throws ConfigurationException Failed to load the resource.
      */
     public static InputStream getResource(String resource) throws ConfigurationException {
+        return getResource(resource, StreamUtils.class);
+    }
+    
+    public static InputStream getResource(final String resource, final Class<?> caller) throws ConfigurationException {
         try {
             // Try it as a File resource...
             File file = new File(resource);
@@ -121,7 +125,7 @@
             }
 
             // Try it as a classpath resource ...
-            InputStream stream = ClassUtil.getResourceAsStream(resource, StreamUtils.class);
+            InputStream stream = ClassUtil.getResourceAsStream(resource, caller);
             if(stream != null) {
                 return stream;
             }

Modified: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/internal/soa/esb/util/XMLHelper.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/internal/soa/esb/util/XMLHelper.java	2009-03-11 06:27:56 UTC (rev 25581)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/internal/soa/esb/util/XMLHelper.java	2009-03-11 06:45:37 UTC (rev 25582)
@@ -43,6 +43,7 @@
 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;
 
 /**
@@ -177,6 +178,25 @@
     }
     
     /**
+     * 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
+     */
+    public static Schema getSchema(final String resource, final LSResourceResolver resolver) throws SAXException
+    {
+        // SchemaFactory is not thread safe which is why I'm creating a new instance here.
+        final SchemaFactory schemaFactory = SchemaFactory.newInstance( "http://www.w3.org/2001/XMLSchema" );
+        schemaFactory.setResourceResolver(resolver);
+        
+        final InputStream resourceIS = ClassUtil.getResourceAsStream(resource, XMLHelper.class) ;
+        return schemaFactory.newSchema(new StreamSource(resourceIS)) ;
+    }
+    
+    /**
      * Get the schema for the specified resources.
      * @param resources The schema resources to parse.
      * @return The resource schema for validation. 
@@ -210,7 +230,7 @@
             return true ;
         }
         catch (final IOException ioe) {} // fall through
-        catch (final SAXException saxe) {} // fall through
+        catch (final SAXException saxe)  {} // fall through
         
         return false ;
     }

Modified: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java	2009-03-11 06:27:56 UTC (rev 25581)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java	2009-03-11 06:45:37 UTC (rev 25582)
@@ -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;
@@ -62,10 +72,11 @@
 import org.jboss.mx.util.MBeanProxyExt;
 import org.jboss.mx.util.ObjectNameConverter;
 import org.jboss.soa.esb.Service;
+import org.jboss.soa.esb.lifecycle.LifecycleResourceManager;
 import org.jboss.soa.esb.listeners.config.model.ModelAdapter;
 import org.jboss.soa.esb.listeners.config.model.ModelParser;
-import org.jboss.soa.esb.lifecycle.LifecycleResourceManager;
 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,22 @@
                    
                    for(WebserviceInfo webserviceInfo: endpointServices)
                    {
+                       final Service service = webserviceInfo.getService() ;
+                       
+                       // Copy any additional 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())
+                       {
+                           log.debug("Adding schema " + wsdlDir + schemaEntry.getKey());
+                           addFile(zos, wsdlDir + schemaEntry.getKey(), schemaEntry.getValue()) ;
+                       }
+                       
                        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 +573,14 @@
                    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 +736,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") && !fileName.equals("request.xsd") && !fileName.equals("response.xsd") && !fileName.equals("fault.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/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java	2009-03-11 06:27:56 UTC (rev 25581)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java	2009-03-11 06:45:37 UTC (rev 25582)
@@ -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;
@@ -188,10 +189,11 @@
 		final boolean validate = config.getBooleanAttribute(ListenerTagNames.VALIDATE_ATTRIBUTE_TAG, false) ;
 		if (validate)
 		{
+    		final SchemaResolver schemaResolver = new SchemaResolver();
 			final String inXsd = config.getAttribute(ListenerTagNames.IN_XSD_ATTRIBUTE_TAG) ;
 			try
 			{
-				requestSchema = (inXsd == null ? null : XMLHelper.getSchema(inXsd)) ;
+				requestSchema = (inXsd == null ? null : XMLHelper.getSchema(inXsd, schemaResolver)) ;
 			}
 			catch (final SAXException saxe)
 			{
@@ -200,7 +202,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, schemaResolver)) ;
 			}
 			catch (final SAXException saxe)
 			{

Added: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/SchemaResolverUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/SchemaResolverUnitTest.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/SchemaResolverUnitTest.java	2009-03-11 06:45:37 UTC (rev 25582)
@@ -0,0 +1,92 @@
+/*
+ * 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 junit.framework.JUnit4TestAdapter;
+
+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 = new SchemaResolver();
+    
+    @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 testSchemaOnClasspathRelative()
+    {
+        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 testSchemaOnClasspathNullSystemId()
+    {
+        final String type = "http://www.w3.org/2001/XMLSchema";
+        
+        LSInput lsInput = schemaResolver.resolveResource(type, "http://www.jboss.org/custom", null, null, null);
+        Reader characterStream = lsInput.getCharacterStream();
+        assertNull(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/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/XMLHelperUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/XMLHelperUnitTest.java	2009-03-11 06:27:56 UTC (rev 25581)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/XMLHelperUnitTest.java	2009-03-11 06:45:37 UTC (rev 25582)
@@ -22,14 +22,18 @@
 
 import java.io.InputStream;
 import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
 import java.util.Properties;
 
 import javax.xml.stream.XMLStreamReader;
+import javax.xml.validation.Schema;
 
+import junit.framework.TestCase;
+
+import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.testutils.StringUtils;
+import org.xml.sax.SAXException;
 
-import junit.framework.TestCase;
-
 /**
  * Tests associated with the XML helper class.
  * 
@@ -64,4 +68,14 @@
         final boolean match = StringUtils.compareXMLContent(expectedContents, contents) ;
         assertTrue("System property replacement", match) ;
     }
+    
+    public void testValidateSchemaWithImport() throws ConfigurationException, UnsupportedEncodingException, SAXException
+    {
+        final Schema schema = XMLHelper.getSchema("request.xsd", new SchemaResolver());
+        
+        
+        final String xml = StreamUtils.readStreamString(getClass().getResourceAsStream("sample-request.xml"), "UTF-8");
+        assertTrue(XMLHelper.validate(schema, xml));
+    }
+    
 }

Added: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/custom-type.xsd
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/custom-type.xsd	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/custom-type.xsd	2009-03-11 06:45:37 UTC (rev 25582)
@@ -0,0 +1,12 @@
+<xs:schema version="1.0" 
+    targetNamespace="http://www.jboss.org/custom" 
+    xmlns:cust="http://www.jboss.org/custom"  
+    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+    elementFormDefault="qualified">
+
+  <xs:element name="custom-type" type="cust:customType"/>
+
+  <xs:complexType name="customType">
+      <xs:attribute name="type" type="xs:string" form="qualified"/>
+  </xs:complexType>
+</xs:schema>
\ No newline at end of file

Added: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/request.xsd
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/request.xsd	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/request.xsd	2009-03-11 06:45:37 UTC (rev 25582)
@@ -0,0 +1,17 @@
+<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" 
+    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+    elementFormDefault="qualified">
+
+  <xs:import namespace="http://www.jboss.org/custom" schemaLocation="org/jboss/internal/soa/esb/util/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:custom-type"/>
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>

Added: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/sample-request.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/sample-request.xml	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/sample-request.xml	2009-03-11 06:45:37 UTC (rev 25582)
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<say:sayHi xmlns:say="http://www.jboss.org/sayHi" xmlns:cust="http://www.jboss.org/custom" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+    <say:arg0>HelloWorld</say:arg0>
+    <cust:custom-type cust:type="Dummy String"/>
+</say:sayHi>
\ No newline at end of file

Added: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployerUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployerUnitTest.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployerUnitTest.java	2009-03-11 06:45:37 UTC (rev 25582)
@@ -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/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir/mock.xsd
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir/mock.xsd	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir/mock.xsd	2009-03-11 06:45:37 UTC (rev 25582)
@@ -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/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir/request.xsd
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir/request.xsd	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir/request.xsd	2009-03-11 06:45:37 UTC (rev 25582)
@@ -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/branches/JBESB_4_4_GA_FP/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/schemasDir.esb
===================================================================
(Binary files differ)


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

Modified: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/build.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/build.xml	2009-03-11 06:27:56 UTC (rev 25581)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/build.xml	2009-03-11 06:45:37 UTC (rev 25582)
@@ -6,7 +6,7 @@
 	</description>
 	
 	<!-- additional deploys -->
-	<property name="additional.deploys" value="*.xsd"/>
+	<property name="additional.deploys" value="*.xsd imports/*.xsd"/>
 
 	<!-- Import the base Ant build script... -->
 	<import file="../conf/base-build.xml"/>

Added: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/custom-request-type.xsd
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/custom-request-type.xsd	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/custom-request-type.xsd	2009-03-11 06:45:37 UTC (rev 25582)
@@ -0,0 +1,8 @@
+<xs:schema version="1.0" targetNamespace="http://www.jboss.org/custom-request" xmlns:cust="http://www.jboss.org/custom-request"  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>

Modified: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/error-soap-message.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/error-soap-message.xml	2009-03-11 06:27:56 UTC (rev 25581)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/error-soap-message.xml	2009-03-11 06:45:37 UTC (rev 25582)
@@ -1,9 +1,16 @@
 <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">
+
   <soap:Body>
-      <say:sayHi><say:arg0>Error</say:arg0></say:sayHi>
+      <say:sayHi>
+		<say:arg0>Error</say:arg0>
+		<say:importedElement>
+            <cust:type>Dummy string</cust:type>
+        </say:importedElement>
+	  </say:sayHi>
   </soap:Body>
 
 </soap:Envelope> 

Added: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/imports/custom-response-type.xsd
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/imports/custom-response-type.xsd	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/imports/custom-response-type.xsd	2009-03-11 06:45:37 UTC (rev 25582)
@@ -0,0 +1,8 @@
+<xs:schema version="1.0" targetNamespace="http://www.jboss.org/custom-response" xmlns:cust="http://www.jboss.org/custom"  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>

Modified: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/jboss-esb.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/jboss-esb.xml	2009-03-11 06:27:56 UTC (rev 25581)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/jboss-esb.xml	2009-03-11 06:45:37 UTC (rev 25582)
@@ -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/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/readme.txt
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/readme.txt	2009-03-11 06:27:56 UTC (rev 25581)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/readme.txt	2009-03-11 06:45:37 UTC (rev 25582)
@@ -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 of 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/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/request.xsd
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/request.xsd	2009-03-11 06:27:56 UTC (rev 25581)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/request.xsd	2009-03-11 06:45:37 UTC (rev 25582)
@@ -1,8 +1,16 @@
-<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="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 name="importedElement" type="cust:customType" minOccurs="1"/>
     </xs:sequence>
   </xs:complexType>
 </xs:schema>

Modified: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/response.xsd
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/response.xsd	2009-03-11 06:27:56 UTC (rev 25581)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/response.xsd	2009-03-11 06:45:37 UTC (rev 25582)
@@ -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="imports/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/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/soap-userpass-message.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/soap-userpass-message.xml	2009-03-11 06:27:56 UTC (rev 25581)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/samples/quickstarts/publish_as_webservice/soap-userpass-message.xml	2009-03-11 06:45:37 UTC (rev 25582)
@@ -1,10 +1,14 @@
 <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">
   <soap:Body>
       <say:sayHi>
 		<say:arg0>HelloWorld</say:arg0>
+		<say:importedElement>
+			<cust:type>Dummy string</cust:type>
+    	</say:importedElement>
 	  </say:sayHi>"
   </soap:Body>
 




More information about the jboss-svn-commits mailing list