Author: thomas.diesler(a)jboss.com
Date: 2007-06-20 07:49:18 -0400 (Wed, 20 Jun 2007)
New Revision: 3659
Modified:
branches/jbossws-2.0/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/ManagedServerConfig.java
branches/jbossws-2.0/integration/native/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/management/BasicServerConfig.java
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/management/ServerConfig.java
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/ContextServlet.java
branches/jbossws-2.0/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:
branches/jbossws-2.0/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/ManagedServerConfig.java
===================================================================
---
branches/jbossws-2.0/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/ManagedServerConfig.java 2007-06-20
11:48:32 UTC (rev 3658)
+++
branches/jbossws-2.0/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/ManagedServerConfig.java 2007-06-20
11:49:18 UTC (rev 3659)
@@ -44,9 +44,6 @@
public void create() throws Exception
{
- log.debug("WebServiceHost: " + getWebServiceHost());
- log.debug("WebServicePort: " + getWebServicePort());
- log.debug("WebServiceSecurePort: " + getWebServiceSecurePort());
MBeanServer server = getMBeanServer();
if (server != null)
{
Modified:
branches/jbossws-2.0/integration/native/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java
===================================================================
---
branches/jbossws-2.0/integration/native/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2007-06-20
11:48:32 UTC (rev 3658)
+++
branches/jbossws-2.0/integration/native/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2007-06-20
11:49:18 UTC (rev 3659)
@@ -95,7 +95,6 @@
* A request handler
*
* @author Thomas.Diesler(a)jboss.org
- * @author mageshbk(a)jboss.com
* @since 25-Apr-2007
*/
public class RequestHandlerImpl implements RequestHandler
@@ -503,10 +502,14 @@
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();
- String wsdlHost =
config.getDisplayHost(epMetaData.getEndpointAddress(),reqURL);
-
+ if (config.getWebServiceHost().equals(ServerConfig.UNDEFINED_HOSTNAME) ==
false)
+ {
+ wsdlHost = config.getWebServiceHost();
+ }
log.debug("WSDL request, using host: " + wsdlHost);
WSDLRequestHandler wsdlRequestHandler = new WSDLRequestHandler(epMetaData);
Modified:
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/management/BasicServerConfig.java
===================================================================
---
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/management/BasicServerConfig.java 2007-06-20
11:48:32 UTC (rev 3658)
+++
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/management/BasicServerConfig.java 2007-06-20
11:49:18 UTC (rev 3659)
@@ -25,9 +25,7 @@
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;
@@ -45,7 +43,6 @@
*
* @author Thomas.Diesler(a)jboss.org
* @author darran.lofthouse(a)jboss.com
- * @author mageshbk(a)jboss.com
* @since 08-May-2006
*/
public class BasicServerConfig implements ServerConfig
@@ -139,27 +136,31 @@
if (webServicePort <= 0)
webServicePort = getConnectorPort("HTTP/1.1", false);
- if (webServicePort <= 0)
+ int localPort = webServicePort;
+ if (localPort <= 0)
{
+ // Do not initialize webServicePort with the default, the connector port may
become available later
log.warn("Unable to calculate 'WebServicePort', using default
'8080'");
- webServicePort = 8080;
+ localPort = 8080;
}
- return webServicePort;
+ return localPort;
}
public int getWebServiceSecurePort()
{
if (webServiceSecurePort <= 0)
webServiceSecurePort = getConnectorPort("HTTP/1.1", true);
-
- if (webServiceSecurePort <= 0)
+
+ int localPort = webServiceSecurePort;
+ if (localPort <= 0)
{
+ // Do not initialize webServiceSecurePort with the default, the connector port
may become available later
log.warn("Unable to calculate 'WebServiceSecurePort', using default
'8443'");
- webServiceSecurePort = 8443;
+ localPort = 8443;
}
- return webServiceSecurePort;
+ return localPort;
}
private int getConnectorPort(final String protocol, final boolean secure)
@@ -218,63 +219,4 @@
}
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:
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/management/ServerConfig.java
===================================================================
---
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/management/ServerConfig.java 2007-06-20
11:48:32 UTC (rev 3658)
+++
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/management/ServerConfig.java 2007-06-20
11:49:18 UTC (rev 3659)
@@ -24,9 +24,7 @@
// $Id$
import java.io.File;
-import java.net.MalformedURLException;
import java.net.UnknownHostException;
-import java.net.URL;
import javax.management.ObjectName;
@@ -36,7 +34,6 @@
* Interface to container independent config
*
* @author Thomas.Diesler(a)jboss.org
- * @author mageshbk(a)jboss.com
* @since 08-May-2006
*/
public interface ServerConfig
@@ -69,8 +66,4 @@
boolean isModifySOAPAddress();
void setModifySOAPAddress(boolean flag);
-
- String getDisplayAddress(String endpointAddress, URL requestURL) throws
MalformedURLException;
-
- String getDisplayHost(String endpointAddress, URL requestURL) throws
MalformedURLException;
}
Modified:
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/ContextServlet.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/ContextServlet.java 2007-06-20
11:48:32 UTC (rev 3658)
+++
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/ContextServlet.java 2007-06-20
11:49:18 UTC (rev 3659)
@@ -41,14 +41,11 @@
import org.jboss.wsf.spi.management.EndpointMetrics;
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(a)jboss.org
- * @author mageshbk(a)jboss.com
* @since 21-Mar-2005
*/
public class ContextServlet extends HttpServlet
@@ -98,8 +95,6 @@
{
Endpoint ep = epRegistry.getEndpoint(oname);
ServerEndpointMetaData sepMetaData =
ep.getAttachment(ServerEndpointMetaData.class);
- ServerConfig config = ServerConfigFactory.getInstance().getServerConfig();
- String displayAddress =
config.getDisplayAddress(sepMetaData.getEndpointAddress(), requestURL);
writer.print("<tr>");
writer.print(" <td>Endpoint Name</td>");
@@ -107,7 +102,7 @@
writer.print("</tr>");
writer.print("<tr>");
writer.print(" <td>Endpoint Address</td>");
- writer.print(" <td><a href='" + displayAddress +
"?wsdl'>" + displayAddress + "?wsdl</a></td>");
+ writer.print(" <td><a href='" +
sepMetaData.getEndpointAddress() + "?wsdl'>" +
sepMetaData.getEndpointAddress() + "?wsdl</a></td>");
writer.print("</tr>");
writer.print("<tr>");
writer.print(" <td colspan=2>");
Modified:
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java 2007-06-20
11:48:32 UTC (rev 3658)
+++
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java 2007-06-20
11:49:18 UTC (rev 3659)
@@ -46,7 +46,6 @@
* For a discussion of this topic.
*
* @author Thomas.Diesler(a)jboss.org
- * @author mageshbk(a)jboss.com
* @since 23-Mar-2005
*/
public class WSDLRequestHandler
@@ -137,10 +136,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;
@@ -160,12 +159,25 @@
String orgLocation = locationAttr.getNodeValue();
URL locURL = new URL(orgLocation);
+ String locProtocol = locURL.getProtocol();
String locPath = locURL.getPath();
- String newLocation = wsdlHost + locPath;
- locationAttr.setNodeValue(newLocation);
+ 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 : "");
- log.trace("Mapping address from '" + orgLocation +
"' to '" + newLocation + "'");
+ completeHost = locProtocol + "://" + hostAndPort;
+ }
+
+ String newLocation = completeHost + locPath;
+ locationAttr.setNodeValue(newLocation);
+
+ log.trace("Mapping address from '" + orgLocation +
"' to '" + newLocation + "'");
+ }
}
}
else