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 di...@apache.org on 2005/12/31 06:21:29 UTC
svn commit: r360248 - in
/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http:
./ server/
Author: dims
Date: Fri Dec 30 21:21:24 2005
New Revision: 360248
URL: http://svn.apache.org/viewcvs?rev=360248&view=rev
Log:
- Fix typo in constant / method name
- Remove some unused files
- Add "?wsdl" support in SimpleHTTPServer
- Generate links to "?wsdl" in the main page
- Setup redirect for favico
- Redirect any uri that does not start with "/axis2/services/" to redirect there (ONLY in SimpleHTTPServer, NOT AxisServlet)
Removed:
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/server/ProxyRequestHandler.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/server/SimpleConnManager.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/server/SimpleProxy.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/server/TransparentProxyRequestHandler.java
Modified:
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportReceiver.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPWorker.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/ListingAgent.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/http/server/SimpleHttpServerConnection.java
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportReceiver.java?rev=360248&r1=360247&r2=360248&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportReceiver.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportReceiver.java Fri Dec 30 21:21:24 2005
@@ -341,7 +341,7 @@
operations = axisService.getOperations();
operationsList = operations.values();
- temp += "<h3>" + axisService.getName() + "</h3>";
+ temp += "<h3><a href=\""+ axisService.getName() + "?wsdl\">"+ axisService.getName() + "</a></h3>";
if (operationsList.size() > 0) {
temp += "Available operations <ul>";
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPWorker.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPWorker.java?rev=360248&r1=360247&r2=360248&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPWorker.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPWorker.java Fri Dec 30 21:21:24 2005
@@ -25,6 +25,7 @@
import org.apache.axis2.context.SessionContext;
import org.apache.axis2.description.Parameter;
import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.description.AxisService;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.engine.AxisEngine;
import org.apache.axis2.i18n.Messages;
@@ -118,7 +119,36 @@
}
if (HTTPConstants.HEADER_GET.equals(request.getRequestLine().getMethod())) {
-
+ String uri = request.getRequestLine().getUri();
+ log.debug("HTTP GET:" + uri);
+ if(uri.equals("/favicon.ico")) {
+ response.setStatusLine(request.getRequestLine().getHttpVersion(), 301, "Redirect");
+ response.addHeader(new Header("Location", "http://ws.apache.org/favicon.ico"));
+ conn.writeResponse(response);
+ return true;
+ }
+ if(!uri.startsWith("/axis2/services/")) {
+ response.setStatusLine(request.getRequestLine().getHttpVersion(), 301, "Redirect");
+ response.addHeader(new Header("Location", "/axis2/services/"));
+ conn.writeResponse(response);
+ return true;
+ }
+
+ if(uri.endsWith("?wsdl")){
+ String serviceName = uri.substring(uri.lastIndexOf("/") + 1, uri.length()-5);
+ HashMap services = configurationContext.getAxisConfiguration().getServices();
+ AxisService service = (AxisService) services.get(serviceName);
+ if(service != null){
+ response.addHeader(new Header("Content-Type", "text/xml"));
+ String url = conn.getURL(uri.substring(1,uri.length()-5));
+ service.printWSDL(baos,url);
+ byte[] buf = baos.toByteArray();
+ response.setBody(new ByteArrayInputStream(buf));
+ conn.writeResponse(response);
+ return true;
+ }
+ }
+
// It is GET handle the Get request
boolean processed = HTTPTransportUtils.processHTTPGetRequest(
msgContext, inStream, baos, request.getContentType(),
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/ListingAgent.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/ListingAgent.java?rev=360248&r1=360247&r2=360248&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/ListingAgent.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/ListingAgent.java Fri Dec 30 21:21:24 2005
@@ -47,7 +47,7 @@
*/
private static final String LIST_MULTIPLE_SERVICE_JSP_NAME = "listServices.jsp";
private static final String LIST_SERVICE_GROUP_JSP = "ListServiceGroup.jsp";
- private static final String LIST_SRVICES_JSP_NAME = "listService.jsp";
+ private static final String LIST_SERVICES_JSP_NAME = "listService.jsp";
private static final String SELECT_SERVICE_JSP_NAME = "SelectService.jsp";
private static final String REMOVE_SERVICE_JSP_NAME = "RemoveService.jsp";
@@ -106,7 +106,7 @@
}
}
- private void chageParameters(HttpServletRequest req, HttpServletResponse res)
+ private void changeParameters(HttpServletRequest req, HttpServletResponse res)
throws IOException {
if (req.getParameter("editServicepara") != null) {
String serviceName = req.getParameter("axisService");
@@ -371,7 +371,7 @@
return;
} else if ((filePart != null) && filePart.endsWith(Constants.EDIR_SERVICE_PARA)) {
- chageParameters(httpServletRequest, httpServletResponse);
+ changeParameters(httpServletRequest, httpServletResponse);
return;
} else if ((filePart != null) && filePart.endsWith(Constants.LIST_SERVICE_GROUPS)) {
@@ -407,7 +407,7 @@
req.getSession().setAttribute(Constants.SERVICE_MAP, services);
req.getSession().setAttribute(Constants.ERROR_SERVICE_MAP,
configContext.getAxisConfiguration().getFaultyServices());
- res.sendRedirect(LIST_SRVICES_JSP_NAME);
+ res.sendRedirect(LIST_SERVICES_JSP_NAME);
}
private void listContexts(HttpServletRequest req, HttpServletResponse res) throws IOException {
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=360248&r1=360247&r2=360248&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 Fri Dec 30 21:21:24 2005
@@ -25,6 +25,7 @@
import org.apache.axis2.description.TransportInDescription;
import org.apache.axis2.transport.TransportListener;
import org.apache.axis2.transport.http.server.SimpleHttpServer;
+import org.apache.axis2.transport.http.server.SimpleHttpServerConnection;
import org.apache.axis2.util.threadpool.ThreadFactory;
import org.apache.axis2.util.OptionsParser;
import org.apache.commons.logging.Log;
@@ -32,10 +33,7 @@
import java.io.File;
import java.io.IOException;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
import java.net.SocketException;
-import java.util.Enumeration;
/**
* This is a simple implementation of an HTTP server for processing
@@ -59,7 +57,7 @@
SimpleHttpServer embedded = null;
int port = -1;
private ThreadFactory threadPool = null;
-
+
public static int DEFAULT_PORT = 8080;
/**
@@ -200,7 +198,7 @@
System.out.println("[SimpleHTTPServer] Shutting down");
}
}
-
+
public static void printUsage() {
System.out.println("Usage: SimpleHTTPServer [options] <repository>");
System.out.println(" Opts: -? this message");
@@ -208,7 +206,7 @@
System.out.println(" -p port to listen on (default is 8080)");
System.exit(1);
}
-
+
/**
* Start this server as a NON-daemon.
@@ -245,46 +243,6 @@
}
/**
- * 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.
- * <p/>
- * 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);
- }
- }
-
- /**
* replyToEPR
*
* @param serviceName
@@ -292,7 +250,12 @@
* @see org.apache.axis2.transport.TransportListener#getReplyToEPR(String)
*/
public EndpointReference getReplyToEPR(String serviceName) throws AxisFault {
- String hostAddress = getIpAddress();
+ String hostAddress = null;
+ try {
+ hostAddress = SimpleHttpServerConnection.getIpAddress();
+ } catch (SocketException e) {
+ throw AxisFault.makeFault(e);
+ }
return new EndpointReference("http://" + hostAddress + ":" + (embedded.getLocalPort())
+ "/axis2/services/" + serviceName);
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/server/SimpleHttpServerConnection.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/server/SimpleHttpServerConnection.java?rev=360248&r1=360247&r2=360248&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/server/SimpleHttpServerConnection.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/server/SimpleHttpServerConnection.java Fri Dec 30 21:21:24 2005
@@ -34,6 +34,7 @@
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpParser;
import org.apache.commons.httpclient.StatusLine;
+import org.apache.axis2.AxisFault;
import java.io.IOException;
import java.io.InputStream;
@@ -41,7 +42,10 @@
import java.io.UnsupportedEncodingException;
import java.net.Socket;
import java.net.SocketException;
+import java.net.NetworkInterface;
+import java.net.InetAddress;
import java.util.Iterator;
+import java.util.Enumeration;
/**
* A connection to the SimpleHttpServer.
@@ -278,5 +282,46 @@
public void setSocketTimeout(int timeout) throws SocketException {
this.socket.setSoTimeout(timeout);
+ }
+
+ public String getURL(String suffix) throws Exception {
+ String hostAddress = getIpAddress();
+ return "http://" + hostAddress + ":" + socket.getLocalPort() + "/" + suffix;
+ }
+
+ /**
+ * 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.
+ * <p/>
+ * TODO:
+ * - Improve this logic to genaralize it a bit more
+ * - Obtain the ip to be used here from the Call API
+ *
+ * @return
+ * @throws SocketException
+ */
+ public static String getIpAddress() throws SocketException {
+ 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;
}
}