Author: asoldano
Date: 2014-04-24 09:59:17 -0400 (Thu, 24 Apr 2014)
New Revision: 18585
Modified:
stack/cxf/branches/asoldano/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java
Log:
Restoring proper wsdl soap:address rewrite
Modified:
stack/cxf/branches/asoldano/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java
===================================================================
---
stack/cxf/branches/asoldano/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java 2014-04-23
15:14:21 UTC (rev 18584)
+++
stack/cxf/branches/asoldano/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java 2014-04-24
13:59:17 UTC (rev 18585)
@@ -27,6 +27,7 @@
import java.io.Writer;
import java.net.MalformedURLException;
import java.net.URL;
+import java.security.AccessController;
import java.util.Collection;
import java.util.regex.Pattern;
@@ -39,16 +40,21 @@
import org.apache.cxf.Bus;
import org.apache.cxf.BusException;
+import org.apache.cxf.frontend.WSDLGetUtils;
+import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.transport.DestinationFactory;
import org.apache.cxf.transport.DestinationFactoryManager;
import org.apache.cxf.transport.http.AbstractHTTPDestination;
import org.apache.cxf.transport.http.DestinationRegistry;
import org.apache.cxf.transport.http.HTTPTransportFactory;
import org.jboss.util.NotImplementedException;
+import org.jboss.ws.common.management.AbstractServerConfig;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.invocation.InvocationContext;
import org.jboss.wsf.spi.invocation.RequestHandler;
import org.jboss.wsf.spi.management.EndpointMetrics;
+import org.jboss.wsf.spi.management.ServerConfig;
+import org.jboss.wsf.stack.cxf.addressRewrite.SoapAddressRewriteHelper;
import org.jboss.wsf.stack.cxf.configuration.BusHolder;
/**
@@ -75,18 +81,17 @@
public void handleHttpRequest(Endpoint ep, HttpServletRequest req, HttpServletResponse
res, ServletContext context) throws ServletException, IOException
{
- if ("GET".equals(req.getMethod()))
+ final boolean isGet = "GET".equals(req.getMethod());
+ final boolean isGetWithQueryString = isGet && hasQueryString(req);
+ if (isGet && !isGetWithQueryString)
{
- final String queryString = req.getQueryString();
- if ((null == queryString) || (queryString.length() == 0)) {
- //reject HTTP GET without query string (only support messages sent w/ POST)
- res.setStatus(405);
- res.setContentType("text/plain");
- Writer out = res.getWriter();
- out.write("HTTP GET not supported");
- out.close();
- return;
- }
+ //reject HTTP GET without query string (only support messages sent w/ POST)
+ res.setStatus(405);
+ res.setContentType("text/plain");
+ Writer out = res.getWriter();
+ out.write("HTTP GET not supported");
+ out.close();
+ return;
}
Long beginTime = initRequestMetrics(ep);
@@ -96,6 +101,12 @@
try
{
ServletConfig cfg =
(ServletConfig)context.getAttribute(ServletConfig.class.getName());
+ if (isGetWithQueryString) {
+ final EndpointInfo endpointInfo = dest.getEndpointInfo();
+ final boolean autoRewrite =
SoapAddressRewriteHelper.isAutoRewriteOn(getServerConfig());
+ endpointInfo.setProperty(WSDLGetUtils.AUTO_REWRITE_ADDRESS, autoRewrite);
+ endpointInfo.setProperty(WSDLGetUtils.AUTO_REWRITE_ADDRESS_ALL,
autoRewrite);
+ }
dest.invoke(cfg, context, req, response);
}
catch (IOException e)
@@ -111,6 +122,12 @@
processFaultMetrics(ep, beginTime);
}
}
+
+ private boolean hasQueryString(HttpServletRequest req)
+ {
+ final String queryString = req.getQueryString();
+ return ((null != queryString) && (queryString.length() > 0));
+ }
public void handleRequest(Endpoint endpoint, InputStream inStream, OutputStream
outStream, InvocationContext context)
{
@@ -183,7 +200,16 @@
throw Messages.MESSAGES.cannotObtainDestinationFactoryForHttpTransport(e);
}
return null;
- }
+ }
+
+ private static ServerConfig getServerConfig()
+ {
+ if (System.getSecurityManager() == null)
+ {
+ return AbstractServerConfig.getServerIntegrationServerConfig();
+ }
+ return
AccessController.doPrivileged(AbstractServerConfig.GET_SERVER_INTEGRATION_SERVER_CONFIG);
+ }
private long initRequestMetrics(Endpoint endpoint)
{
Show replies by date