Author: mageshbk(a)jboss.com
Date: 2007-05-22 04:29:09 -0400 (Tue, 22 May 2007)
New Revision: 3176
Modified:
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpoint.java
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java
branches/jbossws-2.0/jbossws-core/src/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/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpoint.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpoint.java 2007-05-22
08:06:27 UTC (rev 3175)
+++
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpoint.java 2007-05-22
08:29:09 UTC (rev 3176)
@@ -59,6 +59,7 @@
* This object registered with the ServiceEndpointManager service.
*
* @author Thomas.Diesler(a)jboss.org
+ * @author mageshbk(a)jboss.com
* @since 16-Jan-2005
*/
public class ServiceEndpoint
@@ -135,18 +136,13 @@
ServiceEndpointInfo sepInfo = getServiceEndpointInfo();
EndpointMetaData epMetaData = sepInfo.getServerEndpointMetaData();
- //String wsdlHost = reqURL.getHost();
- String wsdlHost = reqURL.getProtocol() + "://" + reqURL.getHost() +
":" + reqURL.getPort();
-
ServiceEndpointManagerFactory factory =
ServiceEndpointManagerFactory.getInstance();
ServiceEndpointManager epManager = factory.getServiceEndpointManager();
- if (epManager.getWebServiceHost().equals(ServiceEndpointManager.UNDEFINED_HOSTNAME)
== false)
- {
- wsdlHost = epManager.getWebServiceHost();
- }
- if (log.isDebugEnabled())
- log.debug("WSDL request, using host: " + wsdlHost);
+ String wsdlHost = epManager.getDisplayHost(sepInfo, reqURL);
+
+ if(log.isDebugEnabled()) log.debug("WSDL request, using host: " +
wsdlHost);
+
WSDLRequestHandler wsdlRequestHandler = new WSDLRequestHandler(epMetaData);
Document document = wsdlRequestHandler.getDocumentForPath(reqURL, wsdlHost,
resPath);
Modified:
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java 2007-05-22
08:06:27 UTC (rev 3175)
+++
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java 2007-05-22
08:29:09 UTC (rev 3176)
@@ -79,6 +79,7 @@
* A service that manages JBossWS endpoints.
*
* @author Thomas.Diesler(a)jboss.org
+ * @author mageshbk(a)jboss.com
* @since 15-Jan-2005
*/
public class ServiceEndpointManager implements ServiceEndpointManagerMBean
@@ -343,15 +344,68 @@
{
String endpointAddress = seInfo.getServerEndpointMetaData().getEndpointAddress();
URL displayURL = new URL(endpointAddress);
- String endPointPath = displayURL.getPath();
- if (this.getWebServiceHost().equals(ServiceEndpointManager.UNDEFINED_HOSTNAME) ==
true)
+ String displayHost = getDisplayHost(seInfo, requestURL);
+
+ String displayAddress = displayHost + displayURL.getPath();
+ if (log.isDebugEnabled())
{
- displayURL = requestURL;
+ log.trace("Mapping WSDL soap:address from '" + endpointAddress +
"' to '" + displayAddress + "'");
}
- String displayAddress = displayURL.getProtocol() + "://" +
displayURL.getHost() + ":" + displayURL.getPort() + endPointPath;
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(ServiceEndpointInfo seInfo, URL requestURL) throws
MalformedURLException
+ {
+ String endpointAddress = seInfo.getServerEndpointMetaData().getEndpointAddress();
+ URL displayURL = new URL(endpointAddress);
+ String protocol = displayURL.getProtocol();
+ String host = displayURL.getHost();
+ int port = displayURL.getPort();
+ String uriScheme = requestURL.getProtocol();
+ if
("CONFIDENTIAL".equals(seInfo.getServerEndpointMetaData().getTransportGuarantee()))
+ {
+ //If service is defined to be confidential then always it is https
+ uriScheme = "https";
+ }
+ if (alwaysModifySOAPAddress ||
host.equals(ServiceEndpointManager.UNDEFINED_HOSTNAME) == true)
+ {
+ //Modify the address
+ if (this.getWebServiceHost().equals(ServiceEndpointManager.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;
+ }
+
/** Get the endpoint metrics
*/
public ServiceEndpointMetrics getServiceEndpointMetrics(ObjectName sepID)
Modified:
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/server/WSDLRequestHandler.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/server/WSDLRequestHandler.java 2007-05-22
08:06:27 UTC (rev 3175)
+++
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/server/WSDLRequestHandler.java 2007-05-22
08:29:09 UTC (rev 3176)
@@ -46,6 +46,7 @@
* For a discussion of this topic.
*
* @author Thomas.Diesler(a)jboss.org
+ * @author mageshbk(a)jboss.com
* @since 23-Mar-2005
*/
public class WSDLRequestHandler
@@ -134,10 +135,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;
@@ -157,25 +158,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
Show replies by date