Author: thomas.diesler(a)jboss.com
Date: 2007-06-26 06:43:09 -0400 (Tue, 26 Jun 2007)
New Revision: 3724
Modified:
branches/jbossws-2.0/integration/native/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java
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/metadata/builder/MetaDataBuilder.java
Log:
[JBWS-1609] Address in WSDL - Port value is -1
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-26
07:55:31 UTC (rev 3723)
+++
branches/jbossws-2.0/integration/native/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2007-06-26
10:43:09 UTC (rev 3724)
@@ -505,14 +505,15 @@
String resPath = (String)req.getParameter("resource");
URL reqURL = new URL(req.getRequestURL().toString());
- String wsdlHost = reqURL.getProtocol() + "://" + reqURL.getHost() +
":" + reqURL.getPort();
+ String wsdlHost = reqURL.getProtocol() + "://" + reqURL.getHost();
+ if (reqURL.getPort() != -1)
+ wsdlHost += ":" + reqURL.getPort();
ServerConfigFactory factory = ServerConfigFactory.getInstance();
ServerConfig config = factory.getServerConfig();
- if (config.getWebServiceHost().equals(ServerConfig.UNDEFINED_HOSTNAME) ==
false)
- {
+ if (!ServerConfig.UNDEFINED_HOSTNAME.equals(config.getWebServiceHost()))
wsdlHost = config.getWebServiceHost();
- }
+
log.debug("WSDL request, using host: " + wsdlHost);
WSDLRequestHandler wsdlRequestHandler = new WSDLRequestHandler(epMetaData);
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-26
07:55:31 UTC (rev 3723)
+++
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java 2007-06-26
10:43:09 UTC (rev 3724)
@@ -30,6 +30,7 @@
import org.jboss.logging.Logger;
import org.jboss.ws.metadata.umdm.EndpointMetaData;
+import org.jboss.wsf.spi.management.ServerConfig;
import org.jboss.wsf.spi.utils.DOMUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -71,12 +72,12 @@
public Document getDocumentForPath(URL reqURL, String wsdlHost, String resPath) throws
IOException
{
Document wsdlDoc;
-
+
// The WSDLFilePublisher should set the location to an URL
URL wsdlLocation = epMetaData.getServiceMetaData().getWsdlLocation();
if (wsdlLocation == null)
throw new IllegalStateException("Cannot obtain wsdl location");
-
+
// get the root wsdl
if (resPath == null)
{
@@ -134,17 +135,17 @@
String reqPath = reqURL.getPath();
String completeHost = wsdlHost;
- if (! (wsdlHost.startsWith("http://") ||
wsdlHost.startsWith("https://")) )
+ 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;
locationAttr.setNodeValue(newLocation);
-
+
log.trace("Mapping import from '" + orgLocation +
"' to '" + newLocation + "'");
}
}
@@ -157,23 +158,26 @@
if (locationAttr != null)
{
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))
+ URL orgURL = new URL(orgLocation);
+ String orgProtocol = orgURL.getProtocol();
+ String orgHost = orgURL.getHost();
+ int orgPort = orgURL.getPort();
+ String orgPath = orgURL.getPath();
+
+ if (ServerConfig.UNDEFINED_HOSTNAME.equals(orgHost))
{
- String completeHost = wsdlHost;
- if (! (completeHost.startsWith("http://") ||
completeHost.startsWith("https://")) )
- {
- int locPort = locURL.getPort();
- String hostAndPort = wsdlHost + (locPort > 0 ? ":" +
locPort : "");
-
- completeHost = locProtocol + "://" + hostAndPort;
- }
-
- String newLocation = completeHost + locPath;
+ URL newURL = new URL(wsdlHost);
+ String newHost = newURL.getHost();
+ int newPort = newURL.getPort();
+
+ String newLocation = orgProtocol + "://" + newHost;
+ if (orgPort != -1)
+ newLocation += ":" + orgPort;
+ else if (newPort != -1)
+ newLocation += ":" + newPort;
+
+ newLocation += orgPath;
locationAttr.setNodeValue(newLocation);
log.trace("Mapping address from '" + orgLocation +
"' to '" + newLocation + "'");
Modified:
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java 2007-06-26
07:55:31 UTC (rev 3723)
+++
branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java 2007-06-26
10:43:09 UTC (rev 3724)
@@ -303,8 +303,7 @@
if (alwaysModify || uriScheme == null ||
orgAddress.indexOf("REPLACE_WITH_ACTUAL_URL") >= 0)
{
- if (log.isDebugEnabled())
- log.debug("Replace service endpoint address '" +
orgAddress + "' with '" + serviceEndpointURL + "'");
+ log.debug("Replace service endpoint address '" +
orgAddress + "' with '" + serviceEndpointURL + "'");
wsdlEndpoint.setAddress(serviceEndpointURL);
sepMetaData.setEndpointAddress(serviceEndpointURL);
@@ -314,8 +313,7 @@
}
else
{
- if (log.isDebugEnabled())
- log.debug("Don't replace service endpoint address
'" + orgAddress + "'");
+ log.debug("Don't replace service endpoint address '"
+ orgAddress + "'");
try
{
sepMetaData.setEndpointAddress(new
URL(orgAddress).toExternalForm());
Show replies by date