[jbossws-commits] JBossWS SVN: r3508 - in trunk: integration/spi/src/main/java/org/jboss/wsf/spi/management and 1 other directories.
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Fri Jun 8 11:44:29 EDT 2007
Author: mageshbk at jboss.com
Date: 2007-06-08 11:44:29 -0400 (Fri, 08 Jun 2007)
New Revision: 3508
Modified:
trunk/integration/native/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java
trunk/integration/spi/src/main/java/org/jboss/wsf/spi/management/BasicServerConfig.java
trunk/integration/spi/src/main/java/org/jboss/wsf/spi/management/ServerConfig.java
trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/ContextServlet.java
trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java
Log:
[JBWS-1609] Address in WSDL - Port value is -1 when server is requested with default port 80
Modified: trunk/integration/native/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java
===================================================================
--- trunk/integration/native/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2007-06-08 15:10:27 UTC (rev 3507)
+++ trunk/integration/native/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2007-06-08 15:44:29 UTC (rev 3508)
@@ -94,6 +94,7 @@
* A request handler
*
* @author Thomas.Diesler at jboss.org
+ * @author mageshbk at jboss.com
* @since 25-Apr-2007
*/
public class RequestHandlerImpl implements RequestHandler
@@ -489,14 +490,10 @@
String resPath = (String)req.getParameter("resource");
URL reqURL = new URL(req.getRequestURL().toString());
- String wsdlHost = reqURL.getProtocol() + "://" + reqURL.getHost() + ":" + reqURL.getPort();
-
ServerConfigFactory factory = ServerConfigFactory.getInstance();
ServerConfig config = factory.getServerConfig();
- if (config.getWebServiceHost().equals(ServerConfig.UNDEFINED_HOSTNAME) == false)
- {
- wsdlHost = config.getWebServiceHost();
- }
+ String wsdlHost = config.getDisplayHost(epMetaData.getEndpointAddress(),reqURL);
+
log.debug("WSDL request, using host: " + wsdlHost);
WSDLRequestHandler wsdlRequestHandler = new WSDLRequestHandler(epMetaData);
Modified: trunk/integration/spi/src/main/java/org/jboss/wsf/spi/management/BasicServerConfig.java
===================================================================
--- trunk/integration/spi/src/main/java/org/jboss/wsf/spi/management/BasicServerConfig.java 2007-06-08 15:10:27 UTC (rev 3507)
+++ trunk/integration/spi/src/main/java/org/jboss/wsf/spi/management/BasicServerConfig.java 2007-06-08 15:44:29 UTC (rev 3508)
@@ -25,7 +25,9 @@
import java.io.File;
import java.net.InetAddress;
+import java.net.MalformedURLException;
import java.net.UnknownHostException;
+import java.net.URL;
import java.util.Iterator;
import java.util.Set;
@@ -43,6 +45,7 @@
*
* @author Thomas.Diesler at jboss.org
* @author darran.lofthouse at jboss.com
+ * @author mageshbk at jboss.com
* @since 08-May-2006
*/
public class BasicServerConfig implements ServerConfig
@@ -215,4 +218,63 @@
}
return server;
}
+
+ public String getDisplayAddress(String endpointAddress, URL requestURL) throws MalformedURLException
+ {
+ URL displayURL = new URL(endpointAddress);
+ String displayHost = getDisplayHost(endpointAddress, requestURL);
+
+ String displayAddress = displayHost + displayURL.getPath();
+ if (log.isDebugEnabled())
+ {
+ log.trace("Mapping WSDL soap:address from '" + endpointAddress + "' to '" + displayAddress + "'");
+ }
+ return displayAddress;
+ }
+
+ /*
+ * Formats the Service endpoint host according to the beans.xml definition and
+ * the requested url and returns the URL as string
+ *
+ */
+ public String getDisplayHost(String endpointAddress, URL requestURL) throws MalformedURLException
+ {
+ URL displayURL = new URL(endpointAddress);
+ String protocol = displayURL.getProtocol();
+ String host = displayURL.getHost();
+ int port = displayURL.getPort();
+ String uriScheme = requestURL.getProtocol();
+ if (this.modifySOAPAddress || host.equals(BasicServerConfig.UNDEFINED_HOSTNAME) == true)
+ {
+ //Modify the address
+ if (this.getWebServiceHost().equals(BasicServerConfig.UNDEFINED_HOSTNAME) == true)
+ {
+ //Use the incoming request's address
+ protocol = uriScheme;
+ host = requestURL.getHost();
+ port = requestURL.getPort();
+ }
+ else
+ {
+ //Use the address given in jboss-beans.xml
+ protocol = uriScheme;
+ host = this.getWebServiceHost();
+ if (protocol.equals("https"))
+ {
+ port = this.getWebServiceSecurePort();
+ }
+ else
+ {
+ port = this.getWebServicePort();
+ }
+ }
+ }
+ String displayHost = protocol + "://" + host + (port > 0 ? ":" + port : "");
+
+ if (log.isDebugEnabled())
+ {
+ log.trace("Mapping WSDL host from '" + protocol + "://" + host + ":" + port + "' to '" + displayHost + "'");
+ }
+ return displayHost;
+ }
}
Modified: trunk/integration/spi/src/main/java/org/jboss/wsf/spi/management/ServerConfig.java
===================================================================
--- trunk/integration/spi/src/main/java/org/jboss/wsf/spi/management/ServerConfig.java 2007-06-08 15:10:27 UTC (rev 3507)
+++ trunk/integration/spi/src/main/java/org/jboss/wsf/spi/management/ServerConfig.java 2007-06-08 15:44:29 UTC (rev 3508)
@@ -24,7 +24,9 @@
// $Id$
import java.io.File;
+import java.net.MalformedURLException;
import java.net.UnknownHostException;
+import java.net.URL;
import javax.management.ObjectName;
@@ -34,6 +36,7 @@
* Interface to container independent config
*
* @author Thomas.Diesler at jboss.org
+ * @author mageshbk at jboss.com
* @since 08-May-2006
*/
public interface ServerConfig
@@ -66,4 +69,8 @@
boolean isModifySOAPAddress();
void setModifySOAPAddress(boolean flag);
+
+ String getDisplayAddress(String endpointAddress, URL requestURL) throws MalformedURLException;
+
+ String getDisplayHost(String endpointAddress, URL requestURL) throws MalformedURLException;
}
Modified: trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/ContextServlet.java
===================================================================
--- trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/ContextServlet.java 2007-06-08 15:10:27 UTC (rev 3507)
+++ trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/ContextServlet.java 2007-06-08 15:44:29 UTC (rev 3508)
@@ -40,11 +40,14 @@
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.management.EndpointRegistry;
import org.jboss.wsf.spi.management.EndpointRegistryFactory;
+import org.jboss.wsf.spi.management.ServerConfig;
+import org.jboss.wsf.spi.management.ServerConfigFactory;
/**
* The servlet that that is associated with context /jbossws
*
* @author Thomas.Diesler at jboss.org
+ * @author mageshbk at jboss.com
* @since 21-Mar-2005
*/
public class ContextServlet extends HttpServlet
@@ -94,6 +97,9 @@
{
Endpoint ep = epRegistry.getEndpoint(oname);
ServerEndpointMetaData sepMetaData = ep.getAttachment(ServerEndpointMetaData.class);
+ ServerConfigFactory factory = ServerConfigFactory.getInstance();
+ ServerConfig config = factory.getServerConfig();
+ String displayAddress = config.getDisplayAddress(sepMetaData.getEndpointAddress(),requestURL);
writer.print("<tr>");
writer.print(" <td>ServiceEndpointID</td>");
@@ -101,7 +107,7 @@
writer.print("</tr>");
writer.print("<tr>");
writer.print(" <td>ServiceEndpointAddress</td>");
- writer.print(" <td><a href='" + sepMetaData.getEndpointAddress() + "?wsdl'>" + sepMetaData.getEndpointAddress() + "?wsdl</a></td>");
+ writer.print(" <td><a href='" + displayAddress + "?wsdl'>" + displayAddress + "?wsdl</a></td>");
writer.print("</tr>");
writer.print("<tr>");
writer.print(" <td colspan=2>");
Modified: trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java
===================================================================
--- trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java 2007-06-08 15:10:27 UTC (rev 3507)
+++ trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java 2007-06-08 15:44:29 UTC (rev 3508)
@@ -46,6 +46,7 @@
* For a discussion of this topic.
*
* @author Thomas.Diesler at jboss.org
+ * @author mageshbk at jboss.com
* @since 23-Mar-2005
*/
public class WSDLRequestHandler
@@ -136,10 +137,10 @@
if (! (wsdlHost.startsWith("http://") || wsdlHost.startsWith("https://")) )
{
- String reqProtocol = reqURL.getProtocol();
- int reqPort = reqURL.getPort();
- String hostAndPort = wsdlHost + (reqPort > 0 ? ":" + reqPort : "");
- completeHost = reqProtocol + "://" + hostAndPort;
+ String reqProtocol = reqURL.getProtocol();
+ int reqPort = reqURL.getPort();
+ String hostAndPort = wsdlHost + (reqPort > 0 ? ":" + reqPort : "");
+ completeHost = reqProtocol + "://" + hostAndPort;
}
String newLocation = completeHost + reqPath + "?wsdl&resource=" + newResourcePath;
@@ -159,25 +160,12 @@
String orgLocation = locationAttr.getNodeValue();
URL locURL = new URL(orgLocation);
- String locProtocol = locURL.getProtocol();
String locPath = locURL.getPath();
- if (reqURL.getProtocol().equals(locProtocol) && reqURL.getPath().equals(locPath))
- {
- String completeHost = wsdlHost;
- if (! (completeHost.startsWith("http://") || completeHost.startsWith("https://")) )
- {
- int locPort = locURL.getPort();
- String hostAndPort = wsdlHost + (locPort > 0 ? ":" + locPort : "");
+ String newLocation = wsdlHost + locPath;
+ locationAttr.setNodeValue(newLocation);
- completeHost = locProtocol + "://" + hostAndPort;
- }
-
- String newLocation = completeHost + locPath;
- locationAttr.setNodeValue(newLocation);
-
- log.trace("Mapping address from '" + orgLocation + "' to '" + newLocation + "'");
- }
+ log.trace("Mapping address from '" + orgLocation + "' to '" + newLocation + "'");
}
}
else
More information about the jbossws-commits
mailing list