tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sl...@apache.org
Subject svn commit: r1304746 - in /tuscany/sca-java-2.x/trunk: modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/ testing/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/ testing/itest/ws/wsdl/src/test/java/org...
Date Sat, 24 Mar 2012 10:15:46 GMT
Author: slaws
Date: Sat Mar 24 10:15:46 2012
New Revision: 1304746

URL: http://svn.apache.org/viewvc?rev=1304746&view=rev
Log:
TUSCANY-4036 - Create unique names in WSDL when multiple components expose the same service
interface. Thanks for the patch Greg 

Modified:
    tuscany/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
    tuscany/sca-java-2.x/trunk/testing/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java
    tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLTestCase.java
    tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/BaseFramework.java
    tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DataTypesTestCase.java
    tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DynamicSDOTestCase.java
    tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/helloworld/WSDLGenTestCase.java

Modified: tuscany/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java?rev=1304746&r1=1304745&r2=1304746&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
Sat Mar 24 10:15:46 2012
@@ -134,6 +134,7 @@ public class WSDLServiceGenerator {
         //[nash] changes to the builder sequence avoid calling this for a CompositeService
         assert !(contract instanceof CompositeService);
 
+        boolean generatedWsdl = false;
         String contractName = contract.getName();
 
         List<Port> ports = new ArrayList<Port>();
@@ -243,6 +244,7 @@ public class WSDLServiceGenerator {
             def = newDef;
 
         } else {
+            generatedWsdl = true;
             // The WSDL definition was generated by Interface2WSDLGenerator.
             // Reuse it instead of creating a new definition here.
         }
@@ -252,7 +254,18 @@ public class WSDLServiceGenerator {
                 new WSDLDefinitionGenerator(wsBinding);
         WSDLInterface wi = (WSDLInterface)wsBinding.getBindingInterfaceContract().getInterface();
         PortType portType = wi.getPortType();
-        Service service = helper.createService(def, portType, contract.getName());
+        // If using the WSDL definition that was generated by Interface2WSDLGenerator,
+        // add the component name to the WSDL service name.  This is done so that the
+        // WSDL service name doesn't clash with other components that use the same contract.
+        // The runtime may have a need to keep the WSDL services separate, e.g. to support
+        // different policy attachments on each service.  It isn't necessary to add the
+        // component name when using user-supplied WSDL because in that case the above code
+        // created a new WSDL document in a namespace that is qualified by the component
name.  
+        String wsdlServiceName = contract.getName();
+        if (generatedWsdl) {
+            wsdlServiceName = component.getURI().replace('/','_') + '_' + wsdlServiceName;
+        }
+        Service service = helper.createService(def, portType, wsdlServiceName);
         if (wsBinding.getBinding() == null && ports.size() == 0) {
             Binding binding = helper.createBinding(def, portType);
             if (BindingWSDLGenerator.requiresSOAP12(wsBinding)) {

Modified: tuscany/sca-java-2.x/trunk/testing/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java?rev=1304746&r1=1304745&r2=1304746&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java
Sat Mar 24 10:15:46 2012
@@ -204,7 +204,7 @@ public class BuilderTestCase {
         Definition def = wsBinding.getGeneratedWSDLDocument();
         TestUtils.writeWSDL(def);
         
-        javax.wsdl.Service svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/",
"Service2")); 
+        javax.wsdl.Service svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/",
"ComponentB_Service2")); 
         Port port = svc.getPort("Service2SOAP11Port");
         Assert.assertEquals("/ComponentB/Service2",TestUtils.getPortAddress(port));
      

Modified: tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLTestCase.java?rev=1304746&r1=1304745&r2=1304746&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLTestCase.java
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLTestCase.java
Sat Mar 24 10:15:46 2012
@@ -93,7 +93,7 @@ public class QuestionMarkWSDLTestCase ex
         Definition definition = wsdlReader.readWSDL("http://localhost:8085/foo/bar?wsdl");
         assertNotNull(definition);
         Service service = definition.getService(new QName("http://axis2.ws.binding.sca.tuscany.apache.org/",
-                                                          "HelloWorld"));
+                                                          "HelloWorldService_HelloWorld"));
         Port port = service.getPort("ep1SOAP11Port");
 
         String endpoint = getEndpoint(port);

Modified: tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/BaseFramework.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/BaseFramework.java?rev=1304746&r1=1304745&r2=1304746&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/BaseFramework.java
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/BaseFramework.java
Sat Mar 24 10:15:46 2012
@@ -209,7 +209,7 @@ public class BaseFramework {
         return (Element)childNodes.item(0);
     }
 
-    private static void readWSDL(String serviceName) throws Exception {
+    private static void readWSDL(String componentName, String serviceName) throws Exception
{
         WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
         wsdlReader.setFeature("javax.wsdl.verbose",false);
         wsdlReader.setFeature("javax.wsdl.importDocuments",true);
@@ -218,7 +218,7 @@ public class BaseFramework {
         assertNotNull(definition);
 
         // find portType
-        Service service = definition.getService(new QName("http://datatypes/", serviceName));
+        Service service = definition.getService(new QName("http://datatypes/", componentName+'_'+serviceName));
         Port port = service.getPort(serviceName + "SOAP11Port");
         Binding binding = port.getBinding();
         portType = binding.getPortType();
@@ -251,13 +251,13 @@ public class BaseFramework {
         }
     }
 
-    protected static void start(String serviceName) throws Exception {
+    protected static void start(String componentName, String serviceName) throws Exception
{
         WSDLServiceGenerator.printWSDL = printWSDL;
         node = TuscanyRuntime.newInstance().createNode("default");
         node.installContribution("datatypescontrib", "target/classes", null, null);
         node.startComposite("datatypescontrib", "DataTypes.composite");
         printWSDL = false;  // print WSDL once only
-        readWSDL(serviceName);
+        readWSDL(componentName, serviceName);
     }
 
     protected static void stop() throws Exception {

Modified: tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DataTypesTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DataTypesTestCase.java?rev=1304746&r1=1304745&r2=1304746&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DataTypesTestCase.java
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DataTypesTestCase.java
Sat Mar 24 10:15:46 2012
@@ -176,7 +176,7 @@ public class DataTypesTestCase extends B
 
     @BeforeClass
     public static void setUpBeforeClass() throws Exception {
-        BaseFramework.start("DataTypes");
+        BaseFramework.start("DataTypes", "DataTypes");
     }
 
     @AfterClass

Modified: tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DynamicSDOTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DynamicSDOTestCase.java?rev=1304746&r1=1304745&r2=1304746&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DynamicSDOTestCase.java
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DynamicSDOTestCase.java
Sat Mar 24 10:15:46 2012
@@ -71,7 +71,7 @@ public class DynamicSDOTestCase extends 
 
     @BeforeClass
     public static void setUpBeforeClass() throws Exception {
-        BaseFramework.start("GetDataServiceWithoutException");
+        BaseFramework.start("DynamicSDO", "GetDataServiceWithoutException");
     }
 
     @AfterClass

Modified: tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/helloworld/WSDLGenTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/helloworld/WSDLGenTestCase.java?rev=1304746&r1=1304745&r2=1304746&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/helloworld/WSDLGenTestCase.java
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/helloworld/WSDLGenTestCase.java
Sat Mar 24 10:15:46 2012
@@ -136,7 +136,7 @@ public class WSDLGenTestCase{
         // talk to the service using JAXWS with WSDL generated from this service used Tuscany's
?wsdl
         // the idea here is to demonstrate that the service is providing a JAXWS compliant

         // WSDL
-        QName serviceName = new QName("http://helloworld/", "HelloWorldService");
+        QName serviceName = new QName("http://helloworld/", "HelloWorldServiceComponent_HelloWorldService");
         QName portName = new QName("http://helloworld/", "HelloWorldServiceSOAP11Port");
         URL wsdlLocation = new URL("http://localhost:8085/HelloWorldServiceComponent?wsdl");
         Service webService = Service.create( wsdlLocation, serviceName );



Mime
View raw message