Hi,
See one comment inline.
Thanks
Jeff
[EMAIL PROTECTED] wrote:
Author: ulhasbhole
Date: Wed Oct 17 03:57:01 2007
New Revision: 585445
URL: http://svn.apache.org/viewvc?rev=585445&view=rev
Log:
* Fix for JIRA CXF-1113 related to WSDLPublish and Default Servant.
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexHttpAddressClientServerTest.java
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java?rev=585445&r1=585444&r2=585445&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
(original)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
Wed Oct 17 03:57:01 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/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java?rev=585445&r1=585444&r2=585445&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
(original)
+++
incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
Wed Oct 17 03:57:01 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;
+ }
+ }
I am not sure should the "addr" always be not null and not an empty
string, but in the jca inbound case, the addr is an *Empty String*, and
then I will get the below exception:
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
So I add a null check here * if (addr != null && !"".equals(addr) &&
addr.lastIndexOf("/" == addr.length() - 1) * as a work around... Do we
need a null check here?
+ 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/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexHttpAddressClientServerTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexHttpAddressClientServerTest.java?rev=585445&r1=585444&r2=585445&view=diff
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexHttpAddressClientServerTest.java
(original)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexHttpAddressClientServerTest.java
Wed Oct 17 03:57:01 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;
}
}