cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r525112 - in /incubator/cxf/trunk: rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/ rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ systests/src/test/java/org/apache/cxf/systest/servlet/
Date Tue, 03 Apr 2007 09:37:31 GMT
Author: jliu
Date: Tue Apr  3 02:37:30 2007
New Revision: 525112

URL: http://svn.apache.org/viewvc?view=rev&rev=525112
Log:
Fix failed test of CXFServletTest.testGetImportedXSD(). Also CXF-483 (Make sure imported xsd
access works when there are multiple endpoints deployed in Servlet)

Modified:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointFactoryBean.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointFactoryBean.java?view=diff&rev=525112&r1=525111&r2=525112
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointFactoryBean.java
Tue Apr  3 02:37:30 2007
@@ -86,8 +86,9 @@
                 //if wsdl can't be found, we will try to init Endpoint without wsdl
                 URL wsdl = ClassLoaderUtils.getResource(wsdlLocation, this.getClass()); 
              
                 endpoint = new EndpointImpl(bus, implementor, binding, wsdl);
+            } else {
+                endpoint = new EndpointImpl(bus, implementor, binding);
             }
-            endpoint = new EndpointImpl(bus, implementor, binding);            
         } else {
             endpoint = new EndpointImpl(bus, implementor, serviceFactory);
         }

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java?view=diff&rev=525112&r1=525111&r2=525112
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
Tue Apr  3 02:37:30 2007
@@ -21,7 +21,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.net.URL;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -65,8 +64,7 @@
     private ServletTransportFactory transport;
     private ServletContext servletContext;
     private CXFServlet cxfServlet;
-    private URL wsdlLocation;
-
+ 
     public ServletController(ServletTransportFactory df, ServletContext servCont, CXFServlet
servlet) {
         this.transport = df;
         this.servletContext = servCont;
@@ -87,26 +85,34 @@
         }
         try {
             EndpointInfo ei = new EndpointInfo();
-            ei.setAddress("http://localhost" + request.getServletPath() + request.getPathInfo());
+            String address = "";
             
+            if (xsd) {
+                address = "http://localhost"
+                          + request.getServletPath()
+                          + request.getPathInfo()
+                              .substring(0, request.getPathInfo().lastIndexOf(xsdName) -
1);
+            } else {
+                address = "http://localhost" + request.getServletPath() + request.getPathInfo();
+            }
+            ei.setAddress(address);
+           
             ServletDestination d = (ServletDestination)transport.getDestination(ei);
 
             if (d.getMessageObserver() == null) {
-                if (xsd) {
-                    generateXSD(request, res, xsdName);
+                if (request.getRequestURI().endsWith("services")) {
+                    generateServiceList(request, res);
                 } else {
-                    if (request.getRequestURI().endsWith("services")) {
-                        generateServiceList(request, res);
-                    } else {
-                        LOG.warning("Can't find the the request for" 
-                                    + "http://localhost" + request.getServletPath() 
-                                    + request.getPathInfo() + " 's Observer ");
-                        generateNotFound(request, res);
-                    }    
+                    LOG.warning("Can't find the the request for" + "http://localhost"
+                                + request.getServletPath() + request.getPathInfo() + " 's
Observer ");
+                    generateNotFound(request, res);
                 }
+
+            } else if (xsd) {
+                generateXSD(request, res, d, xsdName);
             } else if (wsdl) {
                 generateWSDL(request, res, d);
-            } else {                
+            } else {
                 invokeDestination(request, res, d);
             }
         } catch (IOException e) {
@@ -114,10 +120,6 @@
         }
     }
     
-    public void setWsdlLocation(URL location) {
-        this.wsdlLocation = location;
-    }
-    
     private void generateServiceList(HttpServletRequest request, HttpServletResponse response)
         throws IOException {
         List<ServletDestination> destinations = transport.getDestinations();
@@ -140,15 +142,18 @@
         response.getWriter().write("</body></html>");
     }
 
-    private void generateXSD(HttpServletRequest request, HttpServletResponse response, String
xsdName) 
-        throws ServletException {
+    private void generateXSD(HttpServletRequest request, HttpServletResponse response, ServletDestination
d,
+                             String xsdName) throws ServletException {
         response.setHeader(HttpHeaderHelper.CONTENT_TYPE, "text/xml");
         try {
             OutputStream os = response.getOutputStream();
             ExtendedURIResolver resolver = new ExtendedURIResolver();
             Source source = null;
-            if (wsdlLocation != null) {
-                InputSource inputSource = resolver.resolve(xsdName, wsdlLocation.toString());
+
+            EndpointInfo ei = d.getEndpointInfo();
+            String wsdlBaseURI = ei.getService().getDescription().getBaseURI();
+            if (wsdlBaseURI != null) {
+                InputSource inputSource = resolver.resolve(xsdName, wsdlBaseURI);
                 source = new SAXSource(inputSource);
 
             } else {

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java?view=diff&rev=525112&r1=525111&r2=525112
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java
Tue Apr  3 02:37:30 2007
@@ -33,7 +33,6 @@
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.apache.cxf.service.invoker.BeanInvoker;
 import org.apache.hello_world_soap_http.GreeterImpl;
-import org.junit.Ignore;
 import org.junit.Test;
 
 
@@ -90,26 +89,22 @@
     @Test
     public void testGetServiceList() throws Exception {
         ServletUnitClient client = newClient();
-        setupJaxwsService();
         client.setExceptionsThrownOnErrorStatus(false);
 
         WebResponse res = client.getResponse("http://localhost/services");    
         
         WebLink[] links = res.getLinks();
-        //REVISIT: there are two services, one is created by cxf-servlet.xml
-        //we will remove the service created by setupJaxwsService() later.
-        assertEquals("There should get one link for service", links.length, 2);
-        assertEquals(links[0].getURLString(), "http://localhost/services/Greeter?wsdl");
      
+        assertEquals("There should get one link for service", links.length, 1);
+        assertEquals(links[0].getURLString(), "http://localhost/services/greeter?wsdl");
      
         assertEquals("text/html", res.getContentType());
     }
     
     @Test
     public void testGetWSDL() throws Exception {
         ServletUnitClient client = newClient();
-        setupJaxwsService();
         client.setExceptionsThrownOnErrorStatus(true);
         
-        WebRequest req = new GetMethodQueryWebRequest("http://localhost/services/Greeter?wsdl");
+        WebRequest req = new GetMethodQueryWebRequest("http://localhost/services/greeter?wsdl");
         
         WebResponse res = client.getResponse(req); 
         assertEquals(200, res.getResponseCode());
@@ -136,16 +131,14 @@
     }
     
     @Test
-    @Ignore
     public void testGetImportedXSD() throws Exception {
         ServletUnitClient client = newClient();
         client.setExceptionsThrownOnErrorStatus(true);
 
-        WebRequest req = new GetMethodQueryWebRequest("http://localhost/services/test_import.xsd");
+        WebRequest req = new GetMethodQueryWebRequest("http://localhost/services/greeter/test_import.xsd");
         
         WebResponse res = client.getResponse(req); 
         assertEquals(200, res.getResponseCode());
-        System.out.println(res.getText());
         //assertEquals("text/xml", res.getContentType());
         assertTrue("the xsd should contain the completType SimpleStruct",
                    res.getText().contains("<complexType name=\"SimpleStruct\">"));



Mime
View raw message