diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2012-03-24 10:15:46 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2012-03-24 10:15:46 +0000 |
commit | d40b0336415c3b79b9e8a5d0e198ca974b640129 (patch) | |
tree | 6369045a402b7618ee98325c6e6a9ece92333a06 | |
parent | 1d6c6a11afe388c62247c09a08836c7d126605a3 (diff) |
TUSCANY-4036 - Create unique names in WSDL when multiple components expose the same service interface. Thanks for the patch Greg
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1304746 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
7 files changed, 23 insertions, 10 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java index e131ea83b0..8839bb9679 100644 --- a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java +++ b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java @@ -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)) { diff --git a/sca-java-2.x/trunk/testing/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java b/sca-java-2.x/trunk/testing/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java index b0c9f7728a..e499e06948 100644 --- a/sca-java-2.x/trunk/testing/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java +++ b/sca-java-2.x/trunk/testing/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java @@ -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)); diff --git a/sca-java-2.x/trunk/testing/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLTestCase.java b/sca-java-2.x/trunk/testing/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLTestCase.java index 635c49b8ab..dbe172f792 100644 --- a/sca-java-2.x/trunk/testing/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLTestCase.java +++ b/sca-java-2.x/trunk/testing/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLTestCase.java @@ -93,7 +93,7 @@ public class QuestionMarkWSDLTestCase extends TestCase { 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); diff --git a/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/BaseFramework.java b/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/BaseFramework.java index 579d01c08b..4cae4595a4 100644 --- a/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/BaseFramework.java +++ b/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/BaseFramework.java @@ -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 {
diff --git a/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DataTypesTestCase.java b/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DataTypesTestCase.java index 48e8b635fe..1e83fe3435 100644 --- a/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DataTypesTestCase.java +++ b/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DataTypesTestCase.java @@ -176,7 +176,7 @@ public class DataTypesTestCase extends BaseFramework { @BeforeClass
public static void setUpBeforeClass() throws Exception {
- BaseFramework.start("DataTypes");
+ BaseFramework.start("DataTypes", "DataTypes");
}
@AfterClass
diff --git a/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DynamicSDOTestCase.java b/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DynamicSDOTestCase.java index 64fb9fb0e1..94d7765466 100644 --- a/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DynamicSDOTestCase.java +++ b/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DynamicSDOTestCase.java @@ -71,7 +71,7 @@ public class DynamicSDOTestCase extends BaseFramework { @BeforeClass
public static void setUpBeforeClass() throws Exception {
- BaseFramework.start("GetDataServiceWithoutException");
+ BaseFramework.start("DynamicSDO", "GetDataServiceWithoutException");
}
@AfterClass
diff --git a/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/helloworld/WSDLGenTestCase.java b/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/helloworld/WSDLGenTestCase.java index 7fabf4cc92..6954a8a7ac 100644 --- a/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/helloworld/WSDLGenTestCase.java +++ b/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/helloworld/WSDLGenTestCase.java @@ -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 );
|