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 /sca-java-2.x/trunk/modules/binding-ws | |
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 '')
-rw-r--r-- | sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java | 15 |
1 files changed, 14 insertions, 1 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)) { |