axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nand...@apache.org
Subject svn commit: r686828 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: dataretrieval/WSDLDataLocator.java description/AxisEndpoint.java description/AxisService2WSDL11.java util/WSDLSerializationUtil.java
Date Mon, 18 Aug 2008 17:37:26 GMT
Author: nandana
Date: Mon Aug 18 10:37:25 2008
New Revision: 686828

URL: http://svn.apache.org/viewvc?rev=686828&view=rev
Log:
AXIS2-3784 Fixing the issue
Using the ip of the request to generate EPRs rather than using the ip of the first network
interface found 

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/dataretrieval/WSDLDataLocator.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/WSDLSerializationUtil.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/dataretrieval/WSDLDataLocator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/dataretrieval/WSDLDataLocator.java?rev=686828&r1=686827&r2=686828&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/dataretrieval/WSDLDataLocator.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/dataretrieval/WSDLDataLocator.java
Mon Aug 18 10:37:25 2008
@@ -116,6 +116,7 @@
             if (msgContext != null) {
                 theService = msgContext.getAxisService();
                 serviceURL = msgContext.getTo().getAddress();
+                theService.setEndpointURL(serviceURL);
             } else {
                 throw new DataRetrievalException("MessageContext was not set!");
             }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java?rev=686828&r1=686827&r2=686828&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java
Mon Aug 18 10:37:25 2008
@@ -174,34 +174,45 @@
 	}
 
 	public String calculateEndpointURL() {
-		if (transportInDescName != null && parent != null) {
-			AxisConfiguration axisConfiguration = getAxisConfiguration();
-			if (axisConfiguration != null) {
-				try {
-					String serviceName = ((AxisService) parent).getName();
-					TransportInDescription in = axisConfiguration
-							.getTransportIn(transportInDescName);
-					TransportListener listener = in.getReceiver();
-					String ip = Utils.getIpAddress(axisConfiguration);
-					// we should pass [serviceName].[endpointName] instead of
-					// [endpointName]
-					String sDOTe = serviceName + "." + name;
-					EndpointReference[] eprsForService = listener
-							.getEPRsForService(sDOTe, ip);
-					// we consider only the first address return by the listener
-					if (eprsForService != null && eprsForService.length > 0) {
-						return eprsForService[0].getAddress();
-					}
-				} catch (SocketException e) {
-					logger.warn(e.getMessage(), e);
-				} catch (AxisFault e) {
-					logger.warn(e.getMessage(), e);
-				}
-			}
-		}
-
-		return null;
+	    return calculateEndpointURL(null);
 	}
+	
+        public String calculateEndpointURL(String hostIP) {
+            if (transportInDescName != null && parent != null) {
+                    AxisConfiguration axisConfiguration = getAxisConfiguration();
+                    if (axisConfiguration != null) {
+                            try {
+                                    String serviceName = ((AxisService) parent).getName();
+                                    TransportInDescription in = axisConfiguration
+                                                    .getTransportIn(transportInDescName);
+                                    TransportListener listener = in.getReceiver();
+                                    String ip;
+                                    
+                                    if (hostIP != null) {
+                                        ip = hostIP;
+                                    } else {    
+                                        ip = Utils.getIpAddress(axisConfiguration);
+                                    }
+                                    
+                                    // we should pass [serviceName].[endpointName] instead
of
+                                    // [endpointName]
+                                    String sDOTe = serviceName + "." + name;
+                                    EndpointReference[] eprsForService = listener
+                                                    .getEPRsForService(sDOTe, ip);
+                                    // we consider only the first address return by the listener
+                                    if (eprsForService != null && eprsForService.length
> 0) {
+                                            return eprsForService[0].getAddress();
+                                    }
+                            } catch (SocketException e) {
+                                    logger.warn(e.getMessage(), e);
+                            } catch (AxisFault e) {
+                                    logger.warn(e.getMessage(), e);
+                            }
+                    }
+            }
+
+            return null;
+        }	
 
 	public boolean isActive() {
 		if (transportInDescName != null && parent != null) {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java?rev=686828&r1=686827&r2=686828&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
Mon Aug 18 10:37:25 2008
@@ -93,8 +93,9 @@
 	private ExternalPolicySerializer serializer;
 
 	private HashMap messagesMap;
+	
 
-	public AxisService2WSDL11(AxisService service) throws Exception {
+        public AxisService2WSDL11(AxisService service) throws Exception {
 		this.axisService = service;
 		this.serviceName = service.getName();
 		init();
@@ -1293,10 +1294,20 @@
 		Parameter modifyAddressParam = axisService
 				.getParameter("modifyUserWSDLPortAddress");
 		if (modifyAddressParam != null) {
-			if (Boolean.parseBoolean((String) modifyAddressParam.getValue())) {
-				return axisEndpoint.calculateEndpointURL();
-			}
+			if (!Boolean.parseBoolean((String) modifyAddressParam.getValue())) {
+				return axisEndpoint.getEndpointURL();
+			} 
+		}
+		String hostIP = WSDLSerializationUtil.extractHostIP(axisService.getEndpointURL());
+		//TODO This is to prevent problems when JAVA2WSDL tool is used where there is no  
+		//Axis server running. calculateEndpointURL fails in this scenario, refer to 
+		// SimpleHTTPServer#getEPRsForService()
+		if (hostIP != null) {
+		    return axisEndpoint.calculateEndpointURL(hostIP);
+		} else {
+		    return axisEndpoint.getEndpointURL();
 		}
-		return axisEndpoint.getEndpointURL();
 	}
-}
+	
+	
+}
\ No newline at end of file

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/WSDLSerializationUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/WSDLSerializationUtil.java?rev=686828&r1=686827&r2=686828&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/WSDLSerializationUtil.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/WSDLSerializationUtil.java
Mon Aug 18 10:37:25 2008
@@ -568,5 +568,31 @@
 		} else {
 			return getAxisService(description.getParent());
 		}
-	}
+	}                              
+        
+	public static String extractHostIP(String serviceURL){
+            
+            String ip = null;
+            
+            if (serviceURL != null) {
+            
+                int ipindex = serviceURL.indexOf("//");
+                        
+                if (ipindex >= 0) {
+                    ip = serviceURL.substring(ipindex + 2, serviceURL.length());
+                    int seperatorIndex = ip.indexOf(":");
+                    int slashIndex = ip.indexOf("/");
+                        
+                    if (seperatorIndex >= 0) {
+                        ip = ip.substring(0, seperatorIndex);
+                    } else {
+                        ip = ip.substring(0, slashIndex);
+                    }                      
+                }
+            }
+               
+            return ip;      
+        }      
+
+	
 }



Mime
View raw message