From d40b0336415c3b79b9e8a5d0e198ca974b640129 Mon Sep 17 00:00:00 2001 From: slaws Date: Sat, 24 Mar 2012 10:15:46 +0000 Subject: 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 --- .../sca/binding/ws/wsdlgen/WSDLServiceGenerator.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'sca-java-2.x/trunk/modules/binding-ws-wsdlgen') 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 ports = new ArrayList(); @@ -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)) { -- cgit v1.2.3