You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ba...@apache.org on 2006/12/08 20:51:19 UTC

svn commit: r484714 - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/jaxws/description/impl/ test/org/apache/axis2/jaxws/client/ test/org/apache/axis2/jaxws/description/

Author: barrettj
Date: Fri Dec  8 11:51:18 2006
New Revision: 484714

URL: http://svn.apache.org/viewvc?view=rev&rev=484714
Log:
Change behavior of service.createDispatch(...) to require port be defined either in WSDL or dynamically via getPort or addPort if no WSDL provided.

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/client/PropertyValueTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/GetDescFromBindingProvider.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/ServiceTests.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java?view=diff&rev=484714&r1=484713&r2=484714
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java Fri Dec  8 11:51:18 2006
@@ -283,7 +283,7 @@
                 // REVIEW: Is this a valid check?
                 throw ExceptionFactory.makeWebServiceException("ServiceDescription.updateEndpointDescription: Can not specify an SEI when creating a Dispatch. PortQN: " + portQName);
             }
-            else if (isPortDeclared) {
+            else if (getWSDLWrapper() != null && isPortDeclared) {
                 // EndpointDescription doesn't exist and this is a declared Port, so create one
                 // Use the SEI Class and its annotations to finish creating the Description hierachy.  Note that EndpointInterface, Operations, Parameters, etc.
                 // are not created for Dipsatch-based ports, but might be updated later if a getPort is done against the same declared port.

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/client/PropertyValueTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/client/PropertyValueTests.java?view=diff&rev=484714&r1=484713&r2=484714
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/client/PropertyValueTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/client/PropertyValueTests.java Fri Dec  8 11:51:18 2006
@@ -40,7 +40,9 @@
     
     public void testSetInvalidClientProperties() throws Exception {
         Service svc = Service.create(new QName("http://test", "TestService"));
-        Dispatch dispatch = svc.createDispatch(new QName("http://test", "TestPort"), String.class, Mode.PAYLOAD);
+        QName portQName = new QName("http://test", "TestPort");
+        svc.addPort(portQName, null, null);
+        Dispatch dispatch = svc.createDispatch(portQName, String.class, Mode.PAYLOAD);
         
         Map<String, Object> map = dispatch.getRequestContext();
         

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/GetDescFromBindingProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/GetDescFromBindingProvider.java?view=diff&rev=484714&r1=484713&r2=484714
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/GetDescFromBindingProvider.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/GetDescFromBindingProvider.java Fri Dec  8 11:51:18 2006
@@ -143,10 +143,10 @@
         assertNotNull(service);
         
         QName validPortQName = new QName(namespaceURI, "EchoPort");
-        Dispatch<String> dispatch = service.createDispatch(validPortQName, String.class, null);
-        assertNotNull(dispatch);
+        EchoPort echoPort = service.getPort(validPortQName, EchoPort.class);
+        assertNotNull(echoPort);
         
-        BindingProvider bindingProvider = (BindingProvider) dispatch;
+        BindingProvider bindingProvider = (BindingProvider)Proxy.getInvocationHandler(echoPort);
         ServiceDelegate serviceDelegate = bindingProvider.getServiceDelegate();
         assertNotNull(serviceDelegate);
         EndpointDescription endpointDesc = bindingProvider.getEndpointDescription();
@@ -165,6 +165,7 @@
         assertNotNull(service);
         
         QName validPortQName = new QName(namespaceURI, "EchoPort");
+        EchoPort echoPort = service.getPort(validPortQName, EchoPort.class);
         Dispatch<String> dispatch = service.createDispatch(validPortQName, String.class, null);
         assertNotNull(dispatch);
         

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/ServiceTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/ServiceTests.java?view=diff&rev=484714&r1=484713&r2=484714
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/ServiceTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/ServiceTests.java Fri Dec  8 11:51:18 2006
@@ -25,6 +25,7 @@
 import java.util.Map;
 
 import javax.xml.namespace.QName;
+import javax.xml.ws.Dispatch;
 import javax.xml.ws.Service;
 import javax.xml.ws.WebServiceException;
 import org.apache.axis2.jaxws.spi.ServiceDelegate;
@@ -243,6 +244,83 @@
         assertEquals(4, service1PortsList.size());
         Iterator<QName> service1PortIterator = service1.getPorts();
         assertQNameIteratorSameAsList(service1PortIterator, service1PortsList);
+    }
+    
+    public void testCreateDispatchWSDL() {
+        URL wsdlURL = DescriptionTestUtils.getWSDLURL("WSDLMultiTests.wsdl");
+
+        QName service1QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_1);
+        Service service1 = Service.create(wsdlURL, service1QN);
+        assertNotNull(service1);
+        // Create Dispatch should work on a WSDL declared port prior to a getPort
+        // and again after the call to getPort
+        QName validPortQName = new QName(VALID_SERVICE_NAMESPACE, VALID_PORT_S1P1);
+        Dispatch<String> dispatch = service1.createDispatch(validPortQName, String.class, null);
+        assertNotNull(dispatch);
+        AddNumbersPortType addNumbersPortS1P1 = service1.getPort(validPortQName, AddNumbersPortType.class);
+        assertNotNull(addNumbersPortS1P1);
+        
+        // Create Dispatch should NOT work on a dynamic port that has not been added yet
+        // but should work after it has been added
+        QName addedPort = new QName(VALID_SERVICE_NAMESPACE, "addedPortS1P1");
+        try {
+            Dispatch<String> dispatch2 = service1.createDispatch(addedPort, String.class, null);
+            fail("Create Dispatch on non-existant port should have thrown an exception");
+        }
+        catch (WebServiceException ex) {
+            // Expected path
+        }
+        catch (Exception ex) {
+            fail("Unexpected exception thrown " + ex.toString());
+        }
+        service1.addPort(addedPort, null, null);
+        Dispatch<String> dispatch2 = service1.createDispatch(addedPort, String.class, null);
+        assertNotNull(dispatch2);
+
+    }
+    
+    public void testCreateDispatchNoWSDL() {
+        
+        // Note that this test is intentionally using the same names as the WSDL test, even though no WSDL is
+        // provided.  This is to verify that using the same names in the abscense of WSDL doesn't cause any
+        // issues.
+        
+        QName service1QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_1);
+        Service service1 = Service.create(service1QN);
+        assertNotNull(service1);
+        // Create Dispatch should NOT work on a dynamic port prior to a getPort
+        // but should work after the getPort causes the port to be added.
+        QName validPortQName = new QName(VALID_SERVICE_NAMESPACE, VALID_PORT_S1P1);
+        try {
+            Dispatch<String> dispatch = service1.createDispatch(validPortQName, String.class, null);
+            fail("Create Dispatch on non-existant port should have thrown and exception");
+        }
+        catch (WebServiceException ex) {
+            // Expected path
+        }
+        catch (Exception ex) {
+            fail("Unexpected exception thrown " + ex.toString());
+        }
+        AddNumbersPortType addNumbersPortS1P1 = service1.getPort(validPortQName, AddNumbersPortType.class);
+        Dispatch<String> dispatch = service1.createDispatch(validPortQName, String.class, null);
+        assertNotNull(dispatch);
+
+        // Create Dispatch should NOT work on a dynamic port that has not been added yet
+        // but should work after it has been added
+        QName addedPort = new QName(VALID_SERVICE_NAMESPACE, "addedPortS1P1");
+        try {
+            Dispatch<String> dispatch2 = service1.createDispatch(addedPort, String.class, null);
+            fail("Create Dispatch on non-existant port should have thrown an exception");
+        }
+        catch (WebServiceException ex) {
+            // Expected path
+        }
+        catch (Exception ex) {
+            fail("Unexpected exception thrown " + ex.toString());
+        }
+        service1.addPort(addedPort, null, null);
+        Dispatch<String> dispatch2 = service1.createDispatch(addedPort, String.class, null);
+        assertNotNull(dispatch2);
     }
     
     private void assertQNameIteratorSameAsList(Iterator<QName> iterator, List<QName> list) {



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org