You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ru...@apache.org on 2005/11/14 08:52:27 UTC
svn commit: r344072 - in
/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2: clientapi/
transport/ transport/http/ transport/mail/ transport/tcp/
Author: ruchithf
Date: Sun Nov 13 23:52:12 2005
New Revision: 344072
URL: http://svn.apache.org/viewcvs?rev=344072&view=rev
Log:
1.) Renamed TransportListener.replyToRPR() to TransportListener.getReplyToEPR()
2.) Improved the setting of the local IP address to fix the non-anonymous request response scenario, where we need the ip of the network interface to be set in the value of wsa:ReplyTo
Modified:
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/clientapi/ListenerManager.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/TransportListener.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/SimpleMailListener.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/tcp/TCPServer.java
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/clientapi/ListenerManager.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/clientapi/ListenerManager.java?rev=344072&r1=344071&r2=344072&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/clientapi/ListenerManager.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/clientapi/ListenerManager.java Sun Nov 13 23:52:12 2005
@@ -95,7 +95,7 @@
TransportListnerState tsState = (TransportListnerState) listeners.get(
transport);
if (tsState != null) {
- return tsState.listener.replyToEPR(serviceName);
+ return tsState.listener.getReplyToEPR(serviceName);
} else {
throw new AxisFault(Messages.getMessage("replyNeedStarting",transport));
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/TransportListener.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/TransportListener.java?rev=344072&r1=344071&r2=344072&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/TransportListener.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/TransportListener.java Sun Nov 13 23:52:12 2005
@@ -35,6 +35,6 @@
public abstract void stop() throws AxisFault;
- public abstract EndpointReference replyToEPR(String serviceName) throws AxisFault;
+ public abstract EndpointReference getReplyToEPR(String serviceName) throws AxisFault;
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java?rev=344072&r1=344071&r2=344072&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java Sun Nov 13 23:52:12 2005
@@ -32,7 +32,10 @@
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
import java.net.UnknownHostException;
+import java.util.Enumeration;
/**
* This is a simple implementation of an HTTP server for processing
@@ -231,20 +234,52 @@
* @param serviceName
* @return an EndpointReference
*
- * @see org.apache.axis2.transport.TransportListener#replyToEPR(java.lang.String)
+ * @see org.apache.axis2.transport.TransportListener#getReplyToEPR(java.lang.String)
*/
- public EndpointReference replyToEPR(String serviceName) throws AxisFault {
- String hostAddress = null;
- try {
- hostAddress = InetAddress.getLocalHost().getHostAddress();
- } catch (UnknownHostException e) {
- throw new AxisFault(e);
- }
+ public EndpointReference getReplyToEPR(String serviceName) throws AxisFault {
+ String hostAddress = getIpAddress();
+
return new EndpointReference("http://"+ hostAddress + ":" + (embedded.getLocalPort()) +
"/axis2/services/" +
serviceName);
}
+ /**
+ * Returns the ip address to be used for the replyto epr
+ * CAUTION:
+ * This will simply go though the list of available network
+ * interfaces and will return the final address of the final interface
+ * available in the list. This workes fine for the simple cases where
+ * 1.) there's only the loopback interface, where the ip is 127.0.0.1
+ * 2.) there's an additional interface availbale which is used to
+ * access an external network and has only one ip assigned to it.
+ *
+ * TODO:
+ * - Improve this logic to genaralize it a bit more
+ * - Obtain the ip to be used here from the Call API
+ * @return
+ * @throws AxisFault
+ */
+ private String getIpAddress() throws AxisFault {
+ try {
+ Enumeration e = NetworkInterface.getNetworkInterfaces();
+
+ String address = null;
+ while (e.hasMoreElements()) {
+ NetworkInterface netface = (NetworkInterface) e.nextElement();
+ Enumeration addresses = netface.getInetAddresses();
+ while (addresses.hasMoreElements()) {
+ InetAddress ip = (InetAddress) addresses.nextElement();
+ //the last available ip address will be returned
+ address = ip.getHostAddress();
+ }
+ }
+ return address;
+ } catch (SocketException e) {
+ throw new AxisFault(e);
+ }
+ }
+
/**
* init method in TransportListener
*
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/SimpleMailListener.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/SimpleMailListener.java?rev=344072&r1=344071&r2=344072&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/SimpleMailListener.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/SimpleMailListener.java Sun Nov 13 23:52:12 2005
@@ -311,7 +311,7 @@
/* (non-Javadoc)
* @see org.apache.axis2.transport.TransportListener#replyToEPR(java.lang.String)
*/
- public EndpointReference replyToEPR(String serviceName) throws AxisFault {
+ public EndpointReference getReplyToEPR(String serviceName) throws AxisFault {
// TODO Auto-generated method stub
return new EndpointReference(replyTo + "/services/" + serviceName);
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/tcp/TCPServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/tcp/TCPServer.java?rev=344072&r1=344071&r2=344072&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/tcp/TCPServer.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/tcp/TCPServer.java Sun Nov 13 23:52:12 2005
@@ -102,7 +102,7 @@
/* (non-Javadoc)
* @see org.apache.axis2.transport.TransportListener#replyToEPR(java.lang.String)
*/
- public EndpointReference replyToEPR(String serviceName) throws AxisFault {
+ public EndpointReference getReplyToEPR(String serviceName) throws AxisFault {
//todo this has to fix
return new EndpointReference("tcp://127.0.0.1:" + (serversocket.getLocalPort()) +
"/axis/services/" +