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

svn commit: r557916 - in /incubator/tuscany/java/sca/modules: binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/axis2/itests/ binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/ interface-wsdl-xml/src/main/java/...

Author: svkrish
Date: Fri Jul 20 01:04:40 2007
New Revision: 557916

URL: http://svn.apache.org/viewvc?view=rev&rev=557916
Log:
fixes for JIRA https://issues.apache.org/jira/browse/TUSCANY-1426

Added:
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/axis2/itests/HelloWorldWSDLMergedTestCase.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om-binding.wsdl
      - copied, changed from r557505, incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om.wsdl
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om-merged.composite
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om-porttype.wsdl
Modified:
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/axis2/itests/HelloWorldOMTestCase.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om.composite
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLTestCase.java

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/axis2/itests/HelloWorldOMTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/axis2/itests/HelloWorldOMTestCase.java?view=diff&rev=557916&r1=557915&r2=557916
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/axis2/itests/HelloWorldOMTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/axis2/itests/HelloWorldOMTestCase.java Fri Jul 20 01:04:40 2007
@@ -33,7 +33,7 @@
     private SCADomain domain;
     private HelloWorldOM helloWorld;
 
-    public void testCalculator() throws Exception {
+    public void testHelloWorld() throws Exception {
         OMFactory fac = OMAbstractFactory.getOMFactory();
         OMElement requestOM = fac.createOMElement("getGreetings", "http://helloworld-om", "helloworld");
         OMElement parmE = fac.createOMElement("name", "http://helloworld-om", "helloworld");

Added: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/axis2/itests/HelloWorldWSDLMergedTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/axis2/itests/HelloWorldWSDLMergedTestCase.java?view=auto&rev=557916
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/axis2/itests/HelloWorldWSDLMergedTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/axis2/itests/HelloWorldWSDLMergedTestCase.java Fri Jul 20 01:04:40 2007
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.binding.axis2.itests;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMText;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+public class HelloWorldWSDLMergedTestCase extends TestCase {
+
+    private SCADomain domain;
+    private HelloWorldOM helloWorld;
+
+    public void testHelloWorld() throws Exception {
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMElement requestOM = fac.createOMElement("getGreetings", "http://helloworld-om", "helloworld");
+        OMElement parmE = fac.createOMElement("name", "http://helloworld-om", "helloworld");
+        requestOM.addChild(parmE);
+        parmE.addChild(fac.createOMText("petra"));
+        OMElement responseOM = helloWorld.getGreetings(requestOM);
+        OMElement child = (OMElement)responseOM.getFirstElement();
+        Assert.assertEquals("Hello petra", ((OMText)child.getFirstOMChild()).getText());
+    }
+
+    protected void setUp() throws Exception {
+        domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/axis2/itests/helloworld-om-merged.composite");
+        helloWorld = domain.getService(HelloWorldOM.class, "HelloWorldWSDLMergedComponent");
+    }
+    
+    protected void tearDown() throws Exception {
+        domain.close();
+    }
+
+}

Copied: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om-binding.wsdl (from r557505, incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om.wsdl)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om-binding.wsdl?view=diff&rev=557916&p1=incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om.wsdl&r1=557505&p2=incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om-binding.wsdl&r2=557916
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om.wsdl (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om-binding.wsdl Fri Jul 20 01:04:40 2007
@@ -17,44 +17,11 @@
  * specific language governing permissions and limitations
  * under the License.    
 -->
-<wsdl:definitions targetNamespace="http://helloworld-om" xmlns:tns="http://helloworld-om" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
-	name="helloworld-om">
+<wsdl:definitions targetNamespace="http://helloworld-om-merged" xmlns:tns="http://helloworld-om-merged" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	name="helloworld-om-bindings">
 
-    <wsdl:types>
-        <schema elementFormDefault="qualified" targetNamespace="http://helloworld-om" xmlns="http://www.w3.org/2001/XMLSchema">
-
-            <element name="getGreetings">
-                <complexType>
-                    <sequence>
-                        <element name="name" type="xsd:string"/>
-                    </sequence>
-                </complexType>
-            </element>
-
-            <element name="getGreetingsResponse">
-                <complexType>
-                    <sequence>
-                        <element name="getGreetingsReturn" type="xsd:string"/>
-                    </sequence>
-                </complexType>
-            </element>
-        </schema>
-    </wsdl:types>
-
-    <wsdl:message name="getGreetingsRequest">
-        <wsdl:part element="tns:getGreetings" name="parameters"/>
-    </wsdl:message>
-
-    <wsdl:message name="getGreetingsResponse">
-        <wsdl:part element="tns:getGreetingsResponse" name="parameters"/>
-    </wsdl:message>
-
-    <wsdl:portType name="HelloWorld">
-        <wsdl:operation name="getGreetings">
-            <wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest"/>
-            <wsdl:output message="tns:getGreetingsResponse" name="getGreetingsResponse"/>
-        </wsdl:operation>
-    </wsdl:portType>
+    <wsdl:import namespace="http://helloworld-om-merged"
+		location="helloworld-om-porttype.wsdl"/>  
 
     <wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorld">
         <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

Added: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om-merged.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om-merged.composite?view=auto&rev=557916
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om-merged.composite (added)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om-merged.composite Fri Jul 20 01:04:40 2007
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+
+           name="HelloWorldOM-Merged">
+
+    <service name="helloWorld" promote="HelloWorldMergedService">
+        <interface.wsdl interface="http://helloworld-om-merged#wsdl.interface(HelloWorld)" />
+        <binding.ws uri="http://localhost:8085/HelloWorldService/helloWorld"/>
+    </service>
+
+    <component name="HelloWorldMergedService">
+		<implementation.java class="org.apache.tuscany.sca.binding.axis2.itests.HelloWorldOMService"/>
+    </component>
+
+    <component name="HelloWorldWSDLMergedComponent">
+		<implementation.java class="org.apache.tuscany.sca.binding.axis2.itests.HelloWorldOMComponent"/>
+    </component>
+ 
+    <reference name="mergedHelloWorldWS" promote="HelloWorldWSDLMergedComponent/helloWorldWS">
+        <interface.wsdl interface="http://helloworld-om-merged#wsdl.interface(HelloWorld)" />
+        <binding.ws wsdlElement="http://helloworld-om-merged#wsdl.port(HelloWorldService/HelloWorldSoapPort)"
+                    uri="http://localhost:8085/HelloWorldService/helloWorld" />
+    </reference>
+
+</composite>

Added: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om-porttype.wsdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om-porttype.wsdl?view=auto&rev=557916
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om-porttype.wsdl (added)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om-porttype.wsdl Fri Jul 20 01:04:40 2007
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+-->
+<wsdl:definitions targetNamespace="http://helloworld-om-merged" xmlns:tns="http://helloworld-om-merged" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	name="helloworld-om-porttype">
+
+    <wsdl:types>
+        <schema elementFormDefault="qualified" targetNamespace="http://helloworld-om-merged" xmlns="http://www.w3.org/2001/XMLSchema">
+
+            <element name="getGreetings">
+                <complexType>
+                    <sequence>
+                        <element name="name" type="xsd:string"/>
+                    </sequence>
+                </complexType>
+            </element>
+
+            <element name="getGreetingsResponse">
+                <complexType>
+                    <sequence>
+                        <element name="getGreetingsReturn" type="xsd:string"/>
+                    </sequence>
+                </complexType>
+            </element>
+        </schema>
+    </wsdl:types>
+
+    <wsdl:message name="getGreetingsRequest">
+        <wsdl:part element="tns:getGreetings" name="parameters"/>
+    </wsdl:message>
+
+    <wsdl:message name="getGreetingsResponse">
+        <wsdl:part element="tns:getGreetingsResponse" name="parameters"/>
+    </wsdl:message>
+
+    <wsdl:portType name="HelloWorld">
+        <wsdl:operation name="getGreetings">
+            <wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest"/>
+            <wsdl:output message="tns:getGreetingsResponse" name="getGreetingsResponse"/>
+        </wsdl:operation>
+    </wsdl:portType>
+  
+</wsdl:definitions>

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om.composite?view=diff&rev=557916&r1=557915&r2=557916
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om.composite (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/axis2/itests/helloworld-om.composite Fri Jul 20 01:04:40 2007
@@ -25,16 +25,16 @@
         <interface.wsdl interface="http://helloworld-om#wsdl.interface(HelloWorld)" />
         <binding.ws uri="http://localhost:8085/HelloWorldService/helloWorld"/>
     </service>
-
+    
     <component name="HelloWorldService">
 		<implementation.java class="org.apache.tuscany.sca.binding.axis2.itests.HelloWorldOMService"/>
     </component>
-
+    
     <component name="HelloWorldComponent">
 		<implementation.java class="org.apache.tuscany.sca.binding.axis2.itests.HelloWorldOMComponent"/>
         <reference name="helloWorldWS" />
     </component>
-
+    
     <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS">
         <interface.wsdl interface="http://helloworld-om#wsdl.interface(HelloWorld)" />
         <binding.ws wsdlElement="http://helloworld-om#wsdl.port(HelloWorldService/HelloWorldSoapPort)"

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/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/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java?view=diff&rev=557916&r1=557915&r2=557916
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java Fri Jul 20 01:04:40 2007
@@ -23,14 +23,21 @@
 import java.io.InputStream;
 import java.net.URI;
 import java.net.URL;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Vector;
 
 import javax.wsdl.Definition;
+import javax.wsdl.Import;
 import javax.wsdl.Types;
 import javax.wsdl.WSDLException;
 import javax.wsdl.extensions.ExtensionRegistry;
 import javax.wsdl.extensions.schema.Schema;
 import javax.wsdl.xml.WSDLLocator;
 import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
 
 import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
 import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
@@ -54,6 +61,8 @@
     private javax.wsdl.factory.WSDLFactory wsdlFactory;
     private ExtensionRegistry wsdlExtensionRegistry;
     private WSDLFactory factory;
+    
+    private Map<String, WSDLDefinition> loadedDefinitions = new Hashtable<String, WSDLDefinition>();
 
     /**
      * Implementation of a WSDL locator.
@@ -128,6 +137,42 @@
         wsdlExtensionRegistry = this.wsdlFactory.newPopulatedExtensionRegistry();
     }
     
+    private void readInlineSchemas(Definition definition, WSDLDefinition wsdlDefinition) {
+        Types types = definition.getTypes();
+        if (types != null) {
+            wsdlDefinition.getInlinedSchemas().setSchemaResolver(new URIResolverImpl());
+            for (Object ext : types.getExtensibilityElements()) {
+                if (ext instanceof Schema) {
+                    Element element = ((Schema)ext).getElement();
+
+                    // TODO: fix to make includes in imported
+                    //       schema work. The XmlSchema library was crashing
+                    //       because the base uri was not set. This doesn't
+                    //       affect imports. Need to check that this
+                    //       is the right approach for XSDs included by a
+                    //       XSD which is itself imported inline in a WSDL
+                    XmlSchemaCollection schemaCollection = wsdlDefinition.getInlinedSchemas();            
+                    schemaCollection.setBaseUri(((Schema)ext).getDocumentBaseURI());
+
+                    wsdlDefinition.getInlinedSchemas().read(element, element.getBaseURI());
+                }
+            }
+        }
+    }
+    
+    @SuppressWarnings("unchecked")
+    private void mergeDefinition(Definition existingDefn, Definition definition) {
+        if (existingDefn != null ) {
+            //merge into existing defn
+            existingDefn.getImports().putAll(definition.getImports());
+            existingDefn.getMessages().putAll(definition.getMessages());
+            existingDefn.getPortTypes().putAll(definition.getPortTypes());
+            existingDefn.getBindings().putAll(definition.getBindings());
+            existingDefn.getServices().putAll(definition.getServices());
+        } 
+    }
+    
+    @SuppressWarnings("unchecked")
     public WSDLDefinition read(URL contributionURL, URI artifactURI, URL artifactURL) throws ContributionReadException {
         try {
 
@@ -140,30 +185,29 @@
             WSDLLocatorImpl locator = new WSDLLocatorImpl(artifactURL, is);
             Definition definition = reader.readWSDL(locator);
             
-            WSDLDefinition wsdlDefinition = factory.createWSDLDefinition();
-            wsdlDefinition.setDefinition(definition);
-            
-            // get base uri for any relative schema includes
-
+            WSDLDefinition wsdlDefinition = loadedDefinitions.get(definition.getTargetNamespace());
+            if ( wsdlDefinition != null ) {
+                mergeDefinition(wsdlDefinition.getDefinition(), definition);
+            } else {
+                wsdlDefinition = factory.createWSDLDefinition();
+                wsdlDefinition.setDefinition(definition);
+                loadedDefinitions.put(definition.getTargetNamespace(), wsdlDefinition);
+            }
             
-            // Read inline schemas 
-            Types types = definition.getTypes();
-            if (types != null) {
-                wsdlDefinition.getInlinedSchemas().setSchemaResolver(new URIResolverImpl());
-                for (Object ext : types.getExtensibilityElements()) {
-                    if (ext instanceof Schema) {
-                        Element element = ((Schema)ext).getElement();
-
-                        // TODO: fix to make includes in imported
-                        //       schema work. The XmlSchema library was crashing
-                        //       because the base uri was not set. This doesn't
-                        //       affect imports. Need to check that this
-                        //       is the right approach for XSDs included by a
-                        //       XSD which is itself imported inline in a WSDL
-                        XmlSchemaCollection schemaCollection = wsdlDefinition.getInlinedSchemas();            
-                        schemaCollection.setBaseUri(((Schema)ext).getDocumentBaseURI());
-
-                        wsdlDefinition.getInlinedSchemas().read(element, element.getBaseURI());
+            //Read inline schemas 
+            readInlineSchemas(definition, wsdlDefinition);
+             
+            //read the inline schemas for wsdl imports
+            if ( definition.getImports().size() > 0 ) {
+                Iterator<Vector<Import>> importsIterator = definition.getImports().values().iterator();
+                Vector<Import> imports = null;
+                Import anImport = null;
+                while (importsIterator.hasNext()) {
+                    imports = importsIterator.next();
+                    for ( int count = 0 ; count < imports.size() ; ++count ) {
+                        anImport = imports.elementAt(count);
+//                      Read inline schemas 
+                        readInlineSchemas(anImport.getDefinition(), wsdlDefinition);
                     }
                 }
             }

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLTestCase.java?view=diff&rev=557916&r1=557915&r2=557916
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLTestCase.java Fri Jul 20 01:04:40 2007
@@ -22,6 +22,7 @@
 import java.net.URI;
 import java.net.URL;
 
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLInputFactory;
 
 import junit.framework.TestCase;
@@ -62,6 +63,39 @@
         assertNotNull(definition);
         assertNotNull(definition.getDefinition());
         assertEquals(definition.getNamespace(), "http://www.example.org");
+    }
+    
+    public void testReadWSDLImports() throws Exception {
+        QName aBinding = new QName("http://helloworld", "HelloWorldSoapBinding");
+        QName aPortType = new QName("http://helloworld", "HelloWorld");
+        
+        URL url = getClass().getResource("test1.wsdl");
+        WSDLDefinition test1Defn = documentProcessor.read(null, new URI("test1.wsdl"), url, WSDLDefinition.class);
+        assertNotNull(test1Defn);
+        //binding is a part of test1.wsdl
+        assertNotNull(test1Defn.getDefinition().getBinding(aBinding));
+        //porttype is part of test2.wsdl
+        assertNotNull(test1Defn.getDefinition().getPortType(aPortType));
+    }
+    
+    public void testReadSameNamespaceWSDLDocument() throws Exception {
+        QName aBinding = new QName("http://helloworld", "HelloWorldSoapBinding");
+        QName aPortType = new QName("http://helloworld", "HelloWorld");
+        
+        URL url = getClass().getResource("test2.wsdl");
+        WSDLDefinition test2Defn = documentProcessor.read(null, new URI("test2.wsdl"), url, WSDLDefinition.class);
+        assertNotNull(test2Defn);
+        //bindigs are a part of test1.wsdl so should not be found
+        assertNull(test2Defn.getDefinition().getBinding(aBinding));
+        assertNotNull(test2Defn.getDefinition().getPortType(aPortType));
+        
+        url = getClass().getResource("test1.wsdl");
+        WSDLDefinition test1Defn = documentProcessor.read(null, new URI("test1.wsdl"), url, WSDLDefinition.class);
+        assertNotNull(test1Defn);
+        assertTrue(test1Defn == test2Defn);
+        //now test2Defn should have the binding as it must be merged with what was read in test1.wsdl
+        //since they belong to the same namespace
+        assertNotNull(test2Defn.getDefinition().getBinding(aBinding));
     }
 
 }



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