diff options
Diffstat (limited to '')
6 files changed, 51 insertions, 18 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLDefinitionGenerator.java b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLDefinitionGenerator.java index 56fd02a611..4ade60d55b 100644 --- a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLDefinitionGenerator.java +++ b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLDefinitionGenerator.java @@ -51,6 +51,7 @@ import javax.wsdl.factory.WSDLFactory; import javax.wsdl.xml.WSDLReader; import javax.xml.namespace.QName; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; import org.w3c.dom.Element; /** @@ -81,10 +82,16 @@ public class WSDLDefinitionGenerator { private QName soapBody; private QName soapFault; private QName soapOperation; - - public WSDLDefinitionGenerator(boolean requiresSOAP12) { + private String wsBindingName; + + public WSDLDefinitionGenerator(WebServiceBinding wsBinding) { + this(BindingWSDLGenerator.requiresSOAP12(wsBinding)); + wsBindingName = wsBinding.getName(); + } + + public WSDLDefinitionGenerator(boolean isSOAP12) { super(); - this.requiresSOAP12 = requiresSOAP12; + this.requiresSOAP12 = isSOAP12; soapAddress = requiresSOAP12 ? SOAP12_ADDRESS : SOAP_ADDRESS; soapBinding = requiresSOAP12 ? SOAP12_BINDING : SOAP_BINDING; soapBody = requiresSOAP12 ? SOAP12_BODY : SOAP_BODY; @@ -127,6 +134,14 @@ public class WSDLDefinitionGenerator { } protected void configureBinding(Definition definition, Binding binding, PortType portType) throws WSDLException { + if ( wsBindingName != null ) { + QName name = new QName(definition.getTargetNamespace(), wsBindingName + getSOAPVersionString() + BINDING_SUFFIX); + if ( definition.getBinding(name) == null ) { + binding.setQName(name); + return; + } + } + QName portTypeName = portType.getQName(); if (portTypeName != null) { // Choose <porttype>Binding if available. If this name is in use, insert @@ -235,11 +250,10 @@ public class WSDLDefinitionGenerator { } } - public Service createService(Definition definition, PortType portType) { + public Service createService(Definition definition, PortType portType, String serviceName) { try { Service service = definition.createService(); - configureService(definition, service, portType); - // createPort(definition, binding, service); + configureService(definition, service, portType, serviceName); definition.addService(service); return service; } catch (WSDLException e) { @@ -247,11 +261,10 @@ public class WSDLDefinitionGenerator { } } - public Service createService(Definition definition, Binding binding) { + public Service createService(Definition definition, Binding binding, String serviceName) { try { Service service = definition.createService(); - configureService(definition, service, binding.getPortType()); - // createPort(definition, binding, service); + configureService(definition, service, binding.getPortType(), serviceName); definition.addService(service); return service; } catch (WSDLException e) { @@ -259,7 +272,17 @@ public class WSDLDefinitionGenerator { } } - protected void configureService(Definition definition, Service service, PortType portType) throws WSDLException { + protected void configureService(Definition definition, Service service, PortType portType, String serviceName) throws WSDLException { + // TODO -- this is the recommended mapping in the ws binding spec, but for some reason it is causing ?wsdl to not be available + // in binding-ws-runtime-jaxws-ri WSDLPortTestCase.testQuestionMarkWSDL(). +// if ( serviceName != null ) { +// QName name = new QName(definition.getTargetNamespace(), serviceName); +// if ( definition.getService(name) == null ) { +// service.setQName(name); +// return; +// } +// } + QName portTypeName = portType.getQName(); if (portTypeName != null) { // Choose <porttype>Service if available. If this name is in use, insert @@ -297,9 +320,19 @@ public class WSDLDefinitionGenerator { } protected void configurePort(Port port, Binding binding) throws WSDLException { - if (binding.getPortType() != null && binding.getPortType().getQName() != null) { + if ( wsBindingName != null ) { + port.setName(wsBindingName + getSOAPVersionString() + PORT_SUFFIX); + } else if (binding.getPortType() != null && binding.getPortType().getQName() != null) { port.setName(binding.getPortType().getQName().getLocalPart() + PORT_SUFFIX); } } + + private String getSOAPVersionString() { + if ( requiresSOAP12 ) { + return "SOAP12"; + } else { + return "SOAP11"; + } + } } 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 3bc784401a..c6f1db4a3e 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 @@ -249,10 +249,10 @@ public class WSDLServiceGenerator { // add a service and ports to the generated definition WSDLDefinitionGenerator helper = - new WSDLDefinitionGenerator(BindingWSDLGenerator.requiresSOAP12(wsBinding)); + new WSDLDefinitionGenerator(wsBinding); WSDLInterface wi = (WSDLInterface)wsBinding.getBindingInterfaceContract().getInterface(); PortType portType = wi.getPortType(); - Service service = helper.createService(def, portType); + Service service = helper.createService(def, portType, contract.getName()); 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 e2fda0e0ec..8ff52e9393 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 @@ -205,7 +205,7 @@ public class BuilderTestCase { TestUtils.writeWSDL(def); javax.wsdl.Service svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service")); - Port port = svc.getPort("Service3Port"); + 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/QuestionMarkWSDLImportTestCase.java b/sca-java-2.x/trunk/testing/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLImportTestCase.java index 76ea53681f..707932425f 100644 --- a/sca-java-2.x/trunk/testing/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLImportTestCase.java +++ b/sca-java-2.x/trunk/testing/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLImportTestCase.java @@ -67,7 +67,7 @@ public class QuestionMarkWSDLImportTestCase extends TestCase { Definition definition = wsdlReader.readWSDL("http://localhost:8086/AccountService?wsdl"); assertNotNull(definition); Service service = definition.getService(new QName("http://account2/AccountService/Account", "AccountService")); - Port port = service.getPort("AccountPort"); + Port port = service.getPort("AccountSOAP11Port"); String endpoint = getEndpoint(port); // String ip = HttpUtils.getIpAddress(); diff --git a/sca-java-2.x/trunk/testing/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLIncludeTestCase.java b/sca-java-2.x/trunk/testing/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLIncludeTestCase.java index 54a40afc63..5b5076ae14 100644 --- a/sca-java-2.x/trunk/testing/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLIncludeTestCase.java +++ b/sca-java-2.x/trunk/testing/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLIncludeTestCase.java @@ -67,7 +67,7 @@ public class QuestionMarkWSDLIncludeTestCase extends TestCase { Definition definition = wsdlReader.readWSDL("http://localhost:8085/AccountService?wsdl"); assertNotNull(definition); Service service = definition.getService(new QName("http://accounts/AccountService/Account", "AccountService")); - Port port = service.getPort("AccountPort"); + Port port = service.getPort("AccountSOAP11Port"); String endpoint = getEndpoint(port); assertEquals("http://localhost:8085/AccountService", endpoint); 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 0148460b5c..c216c23765 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 @@ -68,7 +68,7 @@ public class QuestionMarkWSDLTestCase extends TestCase { assertNotNull(definition); Service service = definition.getService(new QName("http://helloworld/HelloWorldService/HelloWorld", "HelloWorldService")); - Port port = service.getPort("HelloWorldPort"); + Port port = service.getPort("ep2SOAP11Port"); String endpoint = getEndpoint(port); assertEquals("http://localhost:8085/services/HelloWorldWebService2", endpoint); @@ -94,7 +94,7 @@ public class QuestionMarkWSDLTestCase extends TestCase { assertNotNull(definition); Service service = definition.getService(new QName("http://axis2.ws.binding.sca.tuscany.apache.org/", "HelloWorldService")); - Port port = service.getPort("HelloWorldPort"); + Port port = service.getPort("ep1SOAP11Port"); String endpoint = getEndpoint(port); // TODO - used to get the real host here but WSDL seems to have localhost in it atm? |