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 na...@apache.org on 2010/02/03 20:35:07 UTC

svn commit: r906200 - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java test/org/apache/axis2/jaxws/endpoint/BasicEndpointTests.java

Author: nagy
Date: Wed Feb  3 19:35:06 2010
New Revision: 906200

URL: http://svn.apache.org/viewvc?rev=906200&view=rev
Log:
Fix for AXIS2-4247 (error when publishing a service with Endpoint.publish() and then trying to build the EndpointReference.
Submitted by Katherine Sanders.


Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/endpoint/BasicEndpointTests.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java?rev=906200&r1=906199&r2=906200&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java Wed Feb  3 19:35:06 2010
@@ -167,6 +167,7 @@
      */
     public void publish(String s) {
         int port = -1;
+        String address = s;
         try {
             URI uri = new URI(s);
             port = uri.getPort();
@@ -175,9 +176,12 @@
         // Default to 8080
         if(port == -1){
             port = 8080;
+            address = s + ":" + port;
         }
         ConfigurationContext ctx = endpointDesc.getServiceDescription().getAxisConfigContext();
-
+        if (endpointDesc.getEndpointAddress() == null)
+            endpointDesc.setEndpointAddress(address);
+        
         try {
             // For some reason the AxisService has not been added to the ConfigurationContext
             // at this point, so we need to do it for the service to be available.
@@ -240,9 +244,17 @@
         String address = endpointDesc.getEndpointAddress();
         QName serviceName = endpointDesc.getServiceQName();
         QName portName = endpointDesc.getPortQName();
+
+        String wsdlLocation = null;
+        if (metadata != null) {
+            Source wsdlSource = metadata.get(0);
+            if (wsdlSource != null) {   
+                wsdlLocation = wsdlSource.getSystemId();
+            }
+        }
         
         org.apache.axis2.addressing.EndpointReference axis2EPR =
-        	EndpointReferenceUtils.createAxis2EndpointReference(address, serviceName, portName, null, addressingNamespace);
+        	EndpointReferenceUtils.createAxis2EndpointReference(address, serviceName, portName, wsdlLocation, addressingNamespace);
         
         try {
             EndpointReferenceUtils.addReferenceParameters(axis2EPR, referenceParameters);

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/endpoint/BasicEndpointTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/endpoint/BasicEndpointTests.java?rev=906200&r1=906199&r2=906200&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/endpoint/BasicEndpointTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/endpoint/BasicEndpointTests.java Wed Feb  3 19:35:06 2010
@@ -19,13 +19,22 @@
 
 package org.apache.axis2.jaxws.endpoint;
 
-import junit.framework.TestCase;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.jws.WebService;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
 import javax.xml.ws.Binding;
 import javax.xml.ws.Endpoint;
+import javax.xml.ws.EndpointReference;
 import javax.xml.ws.soap.SOAPBinding;
 
+import junit.framework.TestCase;
+
+import org.w3c.dom.Element;
+
 public class BasicEndpointTests extends TestCase {
 
     public void testCreateSimpleEndpoint() {
@@ -60,6 +69,47 @@
                 SOAPBinding.class.isAssignableFrom(bnd.getClass()));
         ep.stop();
     }
+    
+    public void testGetEndpointReference() throws Exception {
+        SampleEndpoint sample = new SampleEndpoint();
+
+        Endpoint ep = Endpoint.publish("test" , sample);
+        assertNotNull("The returned Endpoint instance was null", ep);
+        assertTrue("The endpoint was not published successfully", ep.isPublished());
+        
+        Element [] refParams = new Element[0];
+        EndpointReference epr = ep.getEndpointReference(refParams);
+        
+        assertNotNull("The returned EndpointReference instance was null", epr);
+        
+        ep.stop();
+    }
+    
+    public void testMetadata() throws Exception {
+        SampleEndpoint sample = new SampleEndpoint();
+        
+        Endpoint ep = Endpoint.create(sample);
+        assertTrue("The returned Endpoint instance was null", ep != null);
+        
+        ep.publish("test");
+        assertTrue("The endpoint was not published successfully", ep.isPublished());
+        
+        URL wsdl = new URL("http://test.wsdl.com/Test.wsdl");
+        String wsdlLocation = wsdl.toExternalForm();
+        List<Source> metadata = new ArrayList<Source>();
+        Source source = new StreamSource(wsdl.openStream());  
+        source.setSystemId(wsdlLocation);  
+        metadata.add(source);
+        ep.setMetadata(metadata);
+        
+        metadata = ep.getMetadata();
+        assertNotNull(metadata);
+        source = metadata.get(0);
+        assertNotNull(source);
+        assertEquals(source.getSystemId(), wsdlLocation);
+        
+        ep.stop();
+    }
 
     public void testCreateAndPublishOnAlternatePort() throws Exception {
         Endpoint ep = Endpoint.create(new SampleEndpoint());