You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/04/11 23:10:08 UTC

svn commit: r527674 - in /incubator/tuscany/java/sca/modules: interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/ interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/ interface-wsdl-xml/src/test/java/...

Author: jsdelfino
Date: Wed Apr 11 14:10:07 2007
New Revision: 527674

URL: http://svn.apache.org/viewvc?view=rev&rev=527674
Log:
Integrated resolution of XSD elements and XSD types with the WSDL interface introspector. Removed the old XMLSchemaRegistry.

Removed:
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultXMLSchemaRegistry.java
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/XMLSchemaRegistry.java
Modified:
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLDocumentProcessor.java
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospectorTestCase.java
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperationTestCase.java
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java
    incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/interfacedef/wsdl/WSDLDefinition.java
    incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/interfacedef/wsdl/impl/WSDLDefinitionImpl.java

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java?view=diff&rev=527674&r1=527673&r2=527674
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java Wed Apr 11 14:10:07 2007
@@ -28,39 +28,33 @@
 import org.apache.tuscany.interfacedef.Operation;
 import org.apache.tuscany.interfacedef.wsdl.WSDLInterface;
 import org.apache.tuscany.interfacedef.wsdl.impl.WSDLInterfaceImpl;
+import org.apache.tuscany.services.spi.contribution.ArtifactResolver;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
 
 /**
  * Introspector for creating WSDLInterface definitions from WSDL PortTypes.
  */
 public class DefaultWSDLInterfaceIntrospector implements WSDLInterfaceIntrospector {
     
-    private XMLSchemaRegistry schemaRegistry;
-
-    public DefaultWSDLInterfaceIntrospector(XMLSchemaRegistry schemaRegistry) {
+    public DefaultWSDLInterfaceIntrospector() {
         super();
-        this.schemaRegistry = schemaRegistry;
     }
 
     // FIXME: Do we want to deal with document-literal wrapped style based on the JAX-WS spec?
-    protected List<Operation> introspectOperations(PortType portType) throws InvalidInterfaceException {
+    protected List<Operation> introspectOperations(PortType portType, XmlSchemaCollection inlineSchemas, ArtifactResolver resolver) throws InvalidInterfaceException {
         List<Operation> operations = new ArrayList<Operation>();
-        for (Object op : portType.getOperations()) {
-            javax.wsdl.Operation wsdlOp = (javax.wsdl.Operation)op;
-            operations.add(introspectOperation(wsdlOp));
+        for (Object o : portType.getOperations()) {
+            javax.wsdl.Operation wsdlOp = (javax.wsdl.Operation)o;
+            WSDLOperation op = new WSDLOperation(wsdlOp, inlineSchemas, null, resolver);
+            operations.add(op.getOperation());
         }
         return operations;
     }
 
-    protected Operation introspectOperation(javax.wsdl.Operation wsdlOp) throws InvalidInterfaceException {
-
-        WSDLOperation op = new WSDLOperation(wsdlOp, null, schemaRegistry);
-        return op.getOperation();
-    }
-
-    public WSDLInterface introspect(PortType portType) throws InvalidInterfaceException {
+    public WSDLInterface introspect(PortType portType, XmlSchemaCollection inlineSchemas, ArtifactResolver resolver) throws InvalidInterfaceException {
         WSDLInterface wsdlInterface = new WSDLInterfaceImpl();
         wsdlInterface.setPortType(portType);
-        wsdlInterface.getOperations().addAll(introspectOperations(portType));
+        wsdlInterface.getOperations().addAll(introspectOperations(portType, inlineSchemas, resolver));
         // FIXME: set to Non-conversational for now
         wsdlInterface.setConversational(false);
         return wsdlInterface;

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java?view=diff&rev=527674&r1=527673&r2=527674
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java Wed Apr 11 14:10:07 2007
@@ -22,6 +22,8 @@
 
 import org.apache.tuscany.interfacedef.InvalidInterfaceException;
 import org.apache.tuscany.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.services.spi.contribution.ArtifactResolver;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
 
 /**
  * Introspector for creating WSDLInterface definitions from WSDL PortTypes.
@@ -36,6 +38,6 @@
      * @param type the portType to inspect
      * @return a WSDLInterface corresponding to the WSDL portType
      */
-    WSDLInterface introspect(PortType portType) throws InvalidInterfaceException;
+    WSDLInterface introspect(PortType portType, XmlSchemaCollection inlineSchemas, ArtifactResolver resolver) throws InvalidInterfaceException;
 
 }

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java?view=diff&rev=527674&r1=527673&r2=527674
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java Wed Apr 11 14:10:07 2007
@@ -41,6 +41,10 @@
 import org.apache.tuscany.interfacedef.util.TypeInfo;
 import org.apache.tuscany.interfacedef.util.WrapperInfo;
 import org.apache.tuscany.interfacedef.util.XMLType;
+import org.apache.tuscany.interfacedef.wsdl.XSDefinition;
+import org.apache.tuscany.interfacedef.wsdl.impl.XSDefinitionImpl;
+import org.apache.tuscany.services.spi.contribution.ArtifactResolver;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
 import org.apache.ws.commons.schema.XmlSchemaComplexType;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaObject;
@@ -56,7 +60,8 @@
  * @version $Rev$ $Date$
  */
 public class WSDLOperation {
-    protected XMLSchemaRegistry schemaRegistry;
+    protected ArtifactResolver resolver;
+    protected XmlSchemaCollection inlineSchemas;
     protected javax.wsdl.Operation operation;
     protected Operation operationModel;
     protected DataType<List<DataType>> inputType;
@@ -69,11 +74,12 @@
      * @param dataBinding The default databinding
      * @param schemaRegistry The XML Schema registry
      */
-    public WSDLOperation(javax.wsdl.Operation operation, String dataBinding, XMLSchemaRegistry schemaRegistry) {
+    public WSDLOperation(javax.wsdl.Operation operation, XmlSchemaCollection inlineSchemas, String dataBinding, ArtifactResolver resolver) {
         super();
         this.operation = operation;
+        this.inlineSchemas = inlineSchemas;
+        this.resolver = resolver;
         this.dataBinding = dataBinding;
-        this.schemaRegistry = schemaRegistry;
         this.wrapper = new Wrapper();
     }
 
@@ -196,7 +202,35 @@
         }
         return operationModel;
     }
-
+    
+    private XmlSchemaElement getElement(QName elementName) {
+        XmlSchemaElement element = inlineSchemas.getElementByQName(elementName);
+        if (element == null) {
+            XSDefinition definition = new XSDefinitionImpl();
+            definition.setUnresolved(true);
+            definition.setNamespace(elementName.getNamespaceURI());
+            definition = resolver.resolve(XSDefinition.class, definition);
+            if (definition.getSchema() != null) {
+                element = definition.getSchema().getElementByName(elementName);
+            }
+        }
+        return element;
+    }
+    
+    private XmlSchemaType getType(QName typeName) {
+        XmlSchemaType type = inlineSchemas.getTypeByQName(typeName);
+        if (type == null) {
+            XSDefinition definition = new XSDefinitionImpl();
+            definition.setNamespace(typeName.getNamespaceURI());
+            definition.setUnresolved(true);
+            definition = resolver.resolve(XSDefinition.class, definition);
+            if (definition.getSchema() != null) {
+                type = definition.getSchema().getTypeByName(typeName);
+            }
+        }
+        return type;
+    }
+    
     /**
      * Metadata for a WSDL part
      */
@@ -211,7 +245,7 @@
             this.part = part;
             QName elementName = part.getElementName();
             if (elementName != null) {
-                element = schemaRegistry.getElement(elementName);
+                element = WSDLOperation.this.getElement(elementName);
                 if (element == null) {
                     throw new InvalidWSDLException("Element cannot be resolved: " + elementName.toString());
                 }
@@ -222,7 +256,7 @@
                 element.setQName(new QName(null, part.getName()));
                 QName typeName = part.getTypeName();
                 if (typeName != null) {
-                    XmlSchemaType type = schemaRegistry.getType(typeName);
+                    XmlSchemaType type = WSDLOperation.this.getType(typeName);
                     if (type == null) {
                         throw new InvalidWSDLException("Type cannot be resolved: " + typeName.toString());
                     }
@@ -368,7 +402,7 @@
                 if (!operation.getName().equals(elementName.getLocalPart())) {
                     return null;
                 }
-                inputWrapperElement = schemaRegistry.getElement(elementName);
+                inputWrapperElement = getElement(elementName);
                 if (inputWrapperElement == null) {
                     throw new InvalidWSDLException("The element is not declared in a XML schema: " + elementName
                         .toString());
@@ -403,7 +437,7 @@
                 if (elementName == null) {
                     throw new InvalidWSDLException("The element is not declared in the XML schema: " + part.getName());
                 }
-                outputWrapperElement = schemaRegistry.getElement(elementName);
+                outputWrapperElement = WSDLOperation.this.getElement(elementName);
                 if (outputWrapperElement == null) {
                     return null;
                 }

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLDocumentProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLDocumentProcessor.java?view=diff&rev=527674&r1=527673&r2=527674
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLDocumentProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLDocumentProcessor.java Wed Apr 11 14:10:07 2007
@@ -41,8 +41,6 @@
 import org.apache.tuscany.services.spi.contribution.ContributionWireException;
 import org.apache.tuscany.services.spi.contribution.ContributionWriteException;
 import org.apache.tuscany.services.spi.contribution.URLArtifactProcessor;
-import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
 import org.apache.ws.commons.schema.resolver.URIResolver;
 import org.w3c.dom.Element;
 import org.xml.sax.InputSource;
@@ -153,13 +151,11 @@
             // Read inline schemas 
             Types types = definition.getTypes();
             if (types != null) {
-                XmlSchemaCollection collection = new XmlSchemaCollection();
-                collection.setSchemaResolver(new URIResolverImpl());
+                wsdlDefinition.getInlinedSchemas().setSchemaResolver(new URIResolverImpl());
                 for (Object ext : types.getExtensibilityElements()) {
                     if (ext instanceof Schema) {
                         Element element = ((Schema)ext).getElement();
-                        XmlSchema s = collection.read(element, element.getBaseURI());
-                        wsdlDefinition.getInlinedSchemas().add(s);
+                        wsdlDefinition.getInlinedSchemas().read(element, element.getBaseURI());
                     }
                 }
             }

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java?view=diff&rev=527674&r1=527673&r2=527674
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java Wed Apr 11 14:10:07 2007
@@ -35,7 +35,6 @@
 import org.apache.tuscany.interfacedef.wsdl.WSDLInterfaceContract;
 import org.apache.tuscany.interfacedef.wsdl.impl.DefaultWSDLFactory;
 import org.apache.tuscany.interfacedef.wsdl.introspect.DefaultWSDLInterfaceIntrospector;
-import org.apache.tuscany.interfacedef.wsdl.introspect.DefaultXMLSchemaRegistry;
 import org.apache.tuscany.interfacedef.wsdl.introspect.WSDLInterfaceIntrospector;
 import org.apache.tuscany.services.spi.contribution.ArtifactResolver;
 import org.apache.tuscany.services.spi.contribution.ContributionReadException;
@@ -55,7 +54,7 @@
     }
     
     public WSDLInterfaceProcessor() {
-        this(new DefaultWSDLFactory(), new DefaultWSDLInterfaceIntrospector(new DefaultXMLSchemaRegistry()));
+        this(new DefaultWSDLFactory(), new DefaultWSDLInterfaceIntrospector());
     }
 
     /**
@@ -169,7 +168,7 @@
                         // Introspect the WSDL portType and add the resulting
                         // WSDLInterface to the resolver
                         try {
-                            wsdlInterface = wsdlIntrospector.introspect(portType);
+                            wsdlInterface = wsdlIntrospector.introspect(portType, wsdlDefinition.getInlinedSchemas(), resolver);
                         } catch (InvalidInterfaceException e) {
                             throw new ContributionResolveException(e);
                         }

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospectorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospectorTestCase.java?view=diff&rev=527674&r1=527673&r2=527674
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospectorTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospectorTestCase.java Wed Apr 11 14:10:07 2007
@@ -21,9 +21,7 @@
 
 import java.net.URL;
 import java.util.List;
-import java.util.Map;
 
-import javax.wsdl.Definition;
 import javax.wsdl.PortType;
 import javax.xml.namespace.QName;
 
@@ -34,8 +32,11 @@
 import org.apache.tuscany.interfacedef.InvalidInterfaceException;
 import org.apache.tuscany.interfacedef.Operation;
 import org.apache.tuscany.interfacedef.util.XMLType;
+import org.apache.tuscany.interfacedef.wsdl.WSDLDefinition;
 import org.apache.tuscany.interfacedef.wsdl.WSDLInterface;
 import org.apache.tuscany.interfacedef.wsdl.xml.WSDLDocumentProcessor;
+import org.apache.tuscany.services.spi.contribution.ArtifactResolver;
+import org.apache.tuscany.services.spi.contribution.DefaultArtifactResolver;
 
 /**
  * Test case for InterfaceWSDLIntrospectorImpl
@@ -44,8 +45,9 @@
     private static final QName PORTTYPE_NAME = new QName("http://example.com/stockquote.wsdl", "StockQuotePortType");
 
     private WSDLDocumentProcessor registry;
-    private XMLSchemaRegistry schemaRegistry;
     private PortType portType;
+    private ArtifactResolver resolver;
+    private WSDLDefinition definition;
 
     /**
      * @see junit.framework.TestCase#setUp()
@@ -53,16 +55,15 @@
     protected void setUp() throws Exception {
         super.setUp();
         registry = new WSDLDocumentProcessor();
-        schemaRegistry = new DefaultXMLSchemaRegistry();
+        resolver = new DefaultArtifactResolver();
         URL url = getClass().getResource("../xml/stockquote.wsdl");
-        Definition definition = registry.read(url).getDefinition();
-        schemaRegistry.loadSchemas(definition);
-        portType = definition.getPortType(PORTTYPE_NAME);
+        definition = registry.read(url);
+        portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
     }
 
     public final void testIntrospectPortType() throws InvalidInterfaceException {
-        DefaultWSDLInterfaceIntrospector introspector = new DefaultWSDLInterfaceIntrospector(schemaRegistry);
-        WSDLInterface contract = introspector.introspect(portType);
+        DefaultWSDLInterfaceIntrospector introspector = new DefaultWSDLInterfaceIntrospector();
+        WSDLInterface contract = introspector.introspect(portType, definition.getInlinedSchemas(), resolver);
         Assert.assertEquals(contract.getName().getLocalPart(), "StockQuotePortType");
         List<Operation> operations = contract.getOperations();
         Assert.assertEquals(1, operations.size());

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperationTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperationTestCase.java?view=diff&rev=527674&r1=527673&r2=527674
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperationTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperationTestCase.java Wed Apr 11 14:10:07 2007
@@ -22,7 +22,6 @@
 import java.net.URL;
 import java.util.List;
 
-import javax.wsdl.Definition;
 import javax.wsdl.Operation;
 import javax.wsdl.PortType;
 import javax.xml.namespace.QName;
@@ -32,7 +31,10 @@
 
 import org.apache.tuscany.interfacedef.DataType;
 import org.apache.tuscany.interfacedef.util.XMLType;
+import org.apache.tuscany.interfacedef.wsdl.WSDLDefinition;
 import org.apache.tuscany.interfacedef.wsdl.xml.WSDLDocumentProcessor;
+import org.apache.tuscany.services.spi.contribution.ArtifactResolver;
+import org.apache.tuscany.services.spi.contribution.DefaultArtifactResolver;
 
 /**
  * Test case for WSDLOperation
@@ -42,7 +44,7 @@
         new QName("http://example.com/stockquote.wsdl", "StockQuotePortType");
 
     private WSDLDocumentProcessor processor;
-    private XMLSchemaRegistry schemaRegistry;
+    private ArtifactResolver resolver;
 
     /**
      * @see junit.framework.TestCase#setUp()
@@ -50,17 +52,16 @@
     protected void setUp() throws Exception {
         super.setUp();
         processor = new WSDLDocumentProcessor();
-        this.schemaRegistry = new DefaultXMLSchemaRegistry();
+        resolver = new DefaultArtifactResolver();
     }
 
     public final void testWrappedOperation() throws Exception {
         URL url = getClass().getResource("../xml/stockquote.wsdl");
-        Definition definition = processor.read(url).getDefinition();
-        schemaRegistry.loadSchemas(definition);
-        PortType portType = definition.getPortType(PORTTYPE_NAME);
+        WSDLDefinition definition = processor.read(url);
+        PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
         Operation operation = portType.getOperation("getLastTradePrice", null, null);
 
-        WSDLOperation op = new WSDLOperation(operation, "org.w3c.dom.Node", schemaRegistry);
+        WSDLOperation op = new WSDLOperation(operation, definition.getInlinedSchemas(), "org.w3c.dom.Node", resolver);
 
         DataType<List<DataType>> inputType = op.getInputType();
         Assert.assertEquals(1, inputType.getLogical().size());
@@ -84,29 +85,27 @@
 
     public final void testUnwrappedOperation() throws Exception {
         URL url = getClass().getResource("../xml/unwrapped-stockquote.wsdl");
-        Definition definition = processor.read(url).getDefinition();
-        schemaRegistry.loadSchemas(definition);
-        PortType portType = definition.getPortType(PORTTYPE_NAME);
+        WSDLDefinition definition = processor.read(url);
+        PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
 
         Operation operation = portType.getOperation("getLastTradePrice1", null, null);
-        WSDLOperation op = new WSDLOperation(operation, "org.w3c.dom.Node", schemaRegistry);
+        WSDLOperation op = new WSDLOperation(operation, definition.getInlinedSchemas(), "org.w3c.dom.Node", resolver);
         Assert.assertFalse(op.isWrapperStyle());
         Assert.assertEquals(1, op.getInputType().getLogical().size());
 
         operation = portType.getOperation("getLastTradePrice2", null, null);
-        op = new WSDLOperation(operation, "org.w3c.dom.Node", schemaRegistry);
+        op = new WSDLOperation(operation, definition.getInlinedSchemas(), "org.w3c.dom.Node", resolver);
         Assert.assertFalse(op.isWrapperStyle());
         Assert.assertEquals(2, op.getInputType().getLogical().size());
     }
 
     public final void testInvalidWSDL() throws Exception {
         URL url = getClass().getResource("../xml/invalid-stockquote.wsdl");
-        Definition definition = processor.read(url).getDefinition();
-        schemaRegistry.loadSchemas(definition);
-        PortType portType = definition.getPortType(PORTTYPE_NAME);
+        WSDLDefinition definition = processor.read(url);
+        PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
 
         Operation operation = portType.getOperation("getLastTradePrice", null, null);
-        WSDLOperation op = new WSDLOperation(operation, "org.w3c.dom.Node", schemaRegistry);
+        WSDLOperation op = new WSDLOperation(operation, definition.getInlinedSchemas(), "org.w3c.dom.Node", resolver);
 
         try {
             op.isWrapperStyle();

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java?view=diff&rev=527674&r1=527673&r2=527674
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java Wed Apr 11 14:10:07 2007
@@ -21,7 +21,6 @@
 
 import java.net.URL;
 
-import javax.wsdl.Definition;
 import javax.wsdl.Operation;
 import javax.wsdl.PortType;
 import javax.xml.namespace.QName;
@@ -29,7 +28,10 @@
 import junit.framework.Assert;
 import junit.framework.TestCase;
 
+import org.apache.tuscany.interfacedef.wsdl.WSDLDefinition;
 import org.apache.tuscany.interfacedef.wsdl.xml.WSDLDocumentProcessor;
+import org.apache.tuscany.services.spi.contribution.ArtifactResolver;
+import org.apache.tuscany.services.spi.contribution.DefaultArtifactResolver;
 
 /**
  * Test case for WSDLOperation
@@ -38,7 +40,7 @@
     private static final QName PORTTYPE_NAME = new QName("http://example.com/stockquote.wsdl", "StockQuotePortType");
 
     private WSDLDocumentProcessor registry;
-    private XMLSchemaRegistry schemaRegistry;
+    private ArtifactResolver resolver;
 
     /**
      * @see junit.framework.TestCase#setUp()
@@ -46,16 +48,15 @@
     protected void setUp() throws Exception {
         super.setUp();
         registry = new WSDLDocumentProcessor();
-        this.schemaRegistry = new DefaultXMLSchemaRegistry();
+        resolver = new DefaultArtifactResolver();
     }
 
     public final void testWrappedOperation() throws Exception {
         URL url = getClass().getResource("../xml/stockquote.wsdl");
-        Definition definition = registry.read( url).getDefinition();
-        schemaRegistry.loadSchemas(definition);
-        PortType portType = definition.getPortType(PORTTYPE_NAME);
+        WSDLDefinition definition = registry.read( url);
+        PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
         Operation operation = portType.getOperation("getLastTradePrice", null, null);
-        WSDLOperation op = new WSDLOperation(operation, "org.w3c.dom.Node", schemaRegistry);
+        WSDLOperation op = new WSDLOperation(operation, definition.getInlinedSchemas(), "org.w3c.dom.Node", resolver);
         Assert.assertTrue(op.isWrapperStyle());
         Assert.assertEquals(1, op.getWrapper().getInputChildElements().size());
         Assert.assertEquals(1, op.getWrapper().getOutputChildElements().size());
@@ -63,14 +64,13 @@
 
     public final void testUnwrappedOperation() throws Exception {
         URL url = getClass().getResource("../xml/unwrapped-stockquote.wsdl");
-        Definition definition = registry.read( url).getDefinition();
-        schemaRegistry.loadSchemas(definition);
-        PortType portType = definition.getPortType(PORTTYPE_NAME);
+        WSDLDefinition definition = registry.read( url);
+        PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
         Operation operation = portType.getOperation("getLastTradePrice1", null, null);
-        WSDLOperation op = new WSDLOperation(operation, "org.w3c.dom.Node", schemaRegistry);
+        WSDLOperation op = new WSDLOperation(operation, definition.getInlinedSchemas(), "org.w3c.dom.Node", resolver);
         Assert.assertFalse(op.isWrapperStyle());
         operation = portType.getOperation("getLastTradePrice2", null, null);
-        op = new WSDLOperation(operation, "org.w3c.dom.Node", schemaRegistry);
+        op = new WSDLOperation(operation, definition.getInlinedSchemas(), "org.w3c.dom.Node", resolver);
         Assert.assertFalse(op.isWrapperStyle());
     }
 

Modified: incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/interfacedef/wsdl/WSDLDefinition.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/interfacedef/wsdl/WSDLDefinition.java?view=diff&rev=527674&r1=527673&r2=527674
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/interfacedef/wsdl/WSDLDefinition.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/interfacedef/wsdl/WSDLDefinition.java Wed Apr 11 14:10:07 2007
@@ -19,11 +19,9 @@
 
 package org.apache.tuscany.interfacedef.wsdl;
 
-import java.util.List;
-
 import javax.wsdl.Definition;
 
-import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
 
 /**
  * Represents a WSDL definition.
@@ -49,7 +47,7 @@
      * Returns a list of XML schemas inlined in this WSDL definition.
      * @return
      */
-    List<XmlSchema> getInlinedSchemas();
+    XmlSchemaCollection getInlinedSchemas();
     
     /**
      * Returns the namespace of this WSDL definition.

Modified: incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/interfacedef/wsdl/impl/WSDLDefinitionImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/interfacedef/wsdl/impl/WSDLDefinitionImpl.java?view=diff&rev=527674&r1=527673&r2=527674
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/interfacedef/wsdl/impl/WSDLDefinitionImpl.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/interfacedef/wsdl/impl/WSDLDefinitionImpl.java Wed Apr 11 14:10:07 2007
@@ -19,13 +19,10 @@
 
 package org.apache.tuscany.interfacedef.wsdl.impl;
 
-import java.util.ArrayList;
-import java.util.List;
-
 import javax.wsdl.Definition;
 
 import org.apache.tuscany.interfacedef.wsdl.WSDLDefinition;
-import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
 
 /**
  * Represents a WSDL definition.
@@ -36,7 +33,7 @@
     
     private Definition definition;
     private String namespace;
-    private List<XmlSchema> inlineSchemas = new ArrayList<XmlSchema>();
+    private XmlSchemaCollection inlineSchemas = new XmlSchemaCollection();
     private boolean unresolved;
 
     public Definition getDefinition() {
@@ -47,7 +44,7 @@
         this.definition = definition;
     }
     
-    public List<XmlSchema> getInlinedSchemas() {
+    public XmlSchemaCollection getInlinedSchemas() {
         return inlineSchemas;
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


WSDL and XSD resolution support in place, was: svn commit: r527674

Posted by Jean-Sebastien Delfino <js...@apache.org>.
With revision r527674, resolution of WSDL and XSD artifacts should now 
be working again. The test cases in interface-wsdl-xml all pass. XML 
schemas inlined in WSDL documents are currently visible only inside that 
WSDL document. We may want to revisit that later but I think that this 
is actually in line with usual WSDL practice. Also, the current code 
should be able to handle cases where people duplicate the same XSD 
definition in multiple WSDL documents, which is a pretty common usage 
pattern.

jsdelfino@apache.org wrote:
> Author: jsdelfino
> Date: Wed Apr 11 14:10:07 2007
> New Revision: 527674
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=527674
> Log:
> Integrated resolution of XSD elements and XSD types with the WSDL interface introspector. Removed the old XMLSchemaRegistry.
>
> Removed:
>     incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultXMLSchemaRegistry.java
>     incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/XMLSchemaRegistry.java
> Modified:
>     incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java
>     incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java
>     incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java
>     incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLDocumentProcessor.java
>     incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java
>     incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospectorTestCase.java
>     incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperationTestCase.java
>     incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java
>     incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/interfacedef/wsdl/WSDLDefinition.java
>     incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/interfacedef/wsdl/impl/WSDLDefinitionImpl.java
>
>   

-- 
Jean-Sebastien


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org