You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2007/10/17 22:36:19 UTC

svn commit: r585676 - in /incubator/cxf/branches/2.0.x-fixes: ./ rt/core/src/main/java/org/apache/cxf/transport/http/ rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/ systests/src/test/java/org/apache/cxf/systest/factory_patt...

Author: dkulp
Date: Wed Oct 17 13:36:19 2007
New Revision: 585676

URL: http://svn.apache.org/viewvc?rev=585676&view=rev
Log:
Merged revisions 585445 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/cxf/trunk

........
  r585445 | ulhasbhole | 2007-10-17 06:57:01 -0400 (Wed, 17 Oct 2007) | 1 line
  
  * Fix for JIRA CXF-1113 related to WSDLPublish and Default Servant.
........

Modified:
    incubator/cxf/branches/2.0.x-fixes/   (props changed)
    incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
    incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexHttpAddressClientServerTest.java

Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java?rev=585676&r1=585675&r2=585676&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java Wed Oct 17 13:36:19 2007
@@ -358,7 +358,7 @@
             baseURI = url.getPath();
             int idx = baseURI.lastIndexOf('/');
             if (idx != -1) {
-                baseURI = baseURI.substring(0, idx + 1);
+                baseURI = baseURI.substring(0, idx);
             }
         }        
         return baseURI;

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java?rev=585676&r1=585675&r2=585676&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java Wed Oct 17 13:36:19 2007
@@ -173,13 +173,21 @@
         }
     }
 
-    private synchronized void updateEndpointAddress(String addr) {
+    private String removeTrailingSeparator(String addr) {
+        if (addr.lastIndexOf('/') == addr.length() - 1) {
+            return addr.substring(0, addr.length() - 1);
+        } else {
+            return addr;
+        }
+    }
+    private synchronized String updateEndpointAddress(String addr) {
         // only update the EndpointAddress if the base path is equal
         // make sure we don't broke the get operation?parament query 
-        String address = endpointInfo.getAddress();
-        if (getBasePath(address).equals(getStem(getBasePath(addr)))) {
+        String address = removeTrailingSeparator(endpointInfo.getAddress());
+        if (getBasePath(address).equals(removeTrailingSeparator(getStem(getBasePath(addr))))) {
             endpointInfo.setAddress(addr);
         }
+        return address;
     }
    
     protected void doService(HttpServletRequest req, HttpServletResponse resp) throws IOException {
@@ -194,8 +202,9 @@
         }
         QueryHandlerRegistry queryHandlerRegistry = bus.getExtension(QueryHandlerRegistry.class);
         
-        if (null != req.getQueryString() && queryHandlerRegistry != null) {        
-            String requestURL = req.getRequestURL() + "?" + req.getQueryString();
+        if (null != req.getQueryString() && queryHandlerRegistry != null) {   
+            String reqAddr = req.getRequestURL().toString();
+            String requestURL =  reqAddr + "?" + req.getQueryString();
             String pathInfo = req.getPathInfo();                     
             for (QueryHandler qh : queryHandlerRegistry.getHandlers()) {
                 boolean recognized =
@@ -206,17 +215,21 @@
                                                                        contextMatchOnExact())
                     : qh.isRecognizedQuery(requestURL, pathInfo, endpointInfo);
                 if (recognized) {
-                    //replace the endpointInfo address with request url only for get wsdl           
-                    updateEndpointAddress(req.getRequestURL().toString());   
-                    resp.setContentType(qh.getResponseContentType(requestURL, pathInfo));
-                    try {
-                        qh.writeResponse(requestURL, pathInfo, endpointInfo, resp.getOutputStream());
-                    } catch (Exception ex) {
-                        LOG.log(Level.WARNING, "writeResponse failed: ", ex);
+                    //replace the endpointInfo address with request url only for get wsdl   
+                    synchronized (endpointInfo) {
+                        String oldAddress = updateEndpointAddress(reqAddr);   
+                        resp.setContentType(qh.getResponseContentType(requestURL, pathInfo));
+                        try {
+                            qh.writeResponse(requestURL, pathInfo, endpointInfo, resp.getOutputStream());
+                        } catch (Exception ex) {
+                            LOG.log(Level.WARNING, "writeResponse failed: ", ex);
+                        }
+                        endpointInfo.setAddress(oldAddress);
+                        resp.getOutputStream().flush();                     
+                        baseRequest.setHandled(true);
+                        return;    
                     }
-                    resp.getOutputStream().flush();                     
-                    baseRequest.setHandled(true);
-                    return;
+                    
                 }
             }
         }

Modified: incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexHttpAddressClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexHttpAddressClientServerTest.java?rev=585676&r1=585675&r2=585676&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexHttpAddressClientServerTest.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexHttpAddressClientServerTest.java Wed Oct 17 13:36:19 2007
@@ -20,9 +20,12 @@
 package org.apache.cxf.systest.factory_pattern;
 
 
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Proxy;
 import java.net.URL;
+import java.net.URLConnection;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -75,7 +78,7 @@
         Map<String, String> props = new HashMap<String, String>();    
         props.put("cxf.config.file", "org/apache/cxf/systest/factory_pattern/cxf.xml");
         assertTrue("server did not launch correctly",
-                   launchServer(Server.class, props, null));
+                   launchServer(Server.class, props, null, false));
     }
 
     
@@ -124,5 +127,44 @@
         firstChar = new URL(NumberFactoryImpl.NUMBER_SERVANT_ADDRESS_ROOT 
                                 + "103?wsdl").openStream().read();
         assertTrue("firstChar :" + String.valueOf(firstChar), firstChar == '<');
+    }
+    
+    @Test
+    public void testSoapAddressLocation() throws Exception {
+        
+        assertTrue("Should have received the soap:address location " 
+                   + NumberFactoryImpl.NUMBER_SERVANT_ADDRESS_ROOT, 
+                   checkSoapAddressLocation(NumberFactoryImpl.NUMBER_SERVANT_ADDRESS_ROOT));
+        assertTrue("Should have received the soap:address location " 
+                   + NumberFactoryImpl.NUMBER_SERVANT_ADDRESS_ROOT + "20", 
+                   checkSoapAddressLocation(NumberFactoryImpl.NUMBER_SERVANT_ADDRESS_ROOT + "20"));
+        assertTrue("Should have received the soap:address location " 
+                   + NumberFactoryImpl.NUMBER_SERVANT_ADDRESS_ROOT + "22", 
+                   checkSoapAddressLocation(NumberFactoryImpl.NUMBER_SERVANT_ADDRESS_ROOT + "22"));
+        assertTrue("Should have received the soap:address location " 
+                   + NumberFactoryImpl.NUMBER_SERVANT_ADDRESS_ROOT + "20", 
+                   checkSoapAddressLocation(NumberFactoryImpl.NUMBER_SERVANT_ADDRESS_ROOT + "20"));
+        assertTrue("Should have received the soap:address location " 
+                   + NumberFactoryImpl.NUMBER_SERVANT_ADDRESS_ROOT, 
+                   checkSoapAddressLocation(NumberFactoryImpl.NUMBER_SERVANT_ADDRESS_ROOT));
+    }
+    
+    private boolean checkSoapAddressLocation(String address) 
+        throws Exception {
+        URL url = new URL(address + "?wsdl");
+        
+        URLConnection urlConn = url.openConnection();
+        BufferedReader br = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
+        
+        while (br.ready()) {
+            String str = br.readLine();
+//            System.out.println(str);
+            if (str.contains("soap:address") 
+                && str.contains("location=" + "\"" + address + "\"")) {
+                System.out.println(str);
+                return  true;
+            }
+        }
+        return false;
     }
 }