Index: src/org/apache/axis/transport/http/AxisServlet.java
===================================================================
RCS file: /home/cvspublic/xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java,v
retrieving revision 1.91
diff -c -3 -p -r1.91 AxisServlet.java
*** src/org/apache/axis/transport/http/AxisServlet.java	29 Mar 2002 00:01:26 -0000	1.91
--- src/org/apache/axis/transport/http/AxisServlet.java	3 Apr 2002 15:42:06 -0000
*************** import org.apache.axis.MessageContext;
*** 63,68 ****
--- 63,69 ----
  import org.apache.axis.EngineConfiguration;
  import org.apache.axis.description.ServiceDesc;
  import org.apache.axis.description.OperationDesc;
+ import org.apache.axis.description.ParameterDesc;
  import org.apache.axis.configuration.ServletEngineConfigurationFactory;
  import org.apache.axis.message.SOAPEnvelope;
  import org.apache.axis.message.SOAPFaultElement;
*************** import org.apache.commons.logging.Log;
*** 75,80 ****
--- 76,83 ----
  import org.apache.commons.logging.LogFactory;
  import org.w3c.dom.Document;
  
+ import javax.xml.rpc.namespace.QName;
+ 
  import javax.servlet.ServletConfig;
  import javax.servlet.ServletContext;
  import javax.servlet.ServletException;
*************** import java.util.ArrayList;
*** 97,102 ****
--- 100,106 ----
  /**
   *
   * @author Doug Davis (dug@us.ibm.com)
+  * @author Alan Gordie (alan_gordie@payformance.com)
   */
  public class AxisServlet extends HttpServlet
  {
*************** public class AxisServlet extends HttpSer
*** 232,257 ****
                                 jwsClassDir);
          msgContext.setProperty(Constants.MC_HOME_DIR, homeDir);
  
          String pathInfo = req.getPathInfo();
          if (pathInfo == null || pathInfo.equals("")) {
!             res.setContentType("text/html");
!             writer.println("<h2>And now... Some Services</h2>");
!             Iterator i = engine.getConfig().getDeployedServices();
!             writer.println("<ul>");
!             while (i.hasNext()) {
!                 ServiceDesc sd = (ServiceDesc)i.next();
!                 writer.println("<li>" + sd.getName());
!                 ArrayList operations = sd.getOperations();
!                 if (!operations.isEmpty()) {
!                     writer.println("<ul>");
!                     for (Iterator it = operations.iterator(); it.hasNext();) {
!                         OperationDesc desc = (OperationDesc) it.next();
!                         writer.println("<li>" + desc.getName());
!                     }
!                     writer.println("</ul>");
!                 }
!             }
!             writer.println("</ul>");
              return;
          }
  
--- 236,253 ----
                                 jwsClassDir);
          msgContext.setProperty(Constants.MC_HOME_DIR, homeDir);
  
+         /*
+          *  This next test routes all calls to /axis/servlet/AxisServlet 
+          *  containing only query strings into the serviceManager()
+          *  routine.  
+          *  Does anyone have any recommendations for the cleanest way to 
+          *  route calls to /axis/services/<ServiceName> with no params/no path into
+          *  this call as well?  If so, we can append the ?service=<ServiceName> on the 
+          *  way in, forcing the serviceManager() routine to build the page accordingly.
+          */
          String pathInfo = req.getPathInfo();
          if (pathInfo == null || pathInfo.equals("")) {
!             serviceManager(req,res);
              return;
          }
  
*************** public class AxisServlet extends HttpSer
*** 630,634 ****
--- 626,789 ----
              res.flushBuffer(); //Force it right now.
          }
          if(isDebug) log.debug("Response sent.");
+     }
+     
+     /*
+      * this is the main entry point for the mini-state machine that lets the user drill 
+      * through all deployed services, their respective operations and, for each operation, 
+      * the parameter list and return type.
+      * TODO - decouple the HTML from the logic
+      *      - factor this code into a separate class
+      *      - add support for generating WSIL (need a "published" attribute at the ServiceDesc level..also in WSDD)
+      *      - add support for deploying/undeploying services
+      *      - add support for managing allowedMethods
+      *      - display sample SOAP XML for request/response for each operation
+      *      - HOLY GRAIL (operation invocation!)
+      */
+     public void serviceManager(HttpServletRequest req, HttpServletResponse res)
+         throws ServletException, IOException 
+     {
+         if(isDebug) 
+             log.debug("In serviceManager");
+         
+         PrintWriter writer = res.getWriter();        
+         
+         res.setContentType("text/html");   
+         
+         emitHeader(writer);
+     
+         /*
+          *  ok, we'll definitely need to abstract these html chunks at some point
+          *  but, for now, this will work for getting basic functionality for people
+          *  to tinker with - AlanG
+          */
+         writer.println("<table border='1' cellpadding='5' cellspacing='0'>");
+         writer.println("<tr bgcolor='#CCCCCC'><th>Deployed Services</th><th>Operations</th><th>Operation Details</th><tr>");
+         writer.println("<tr><td valign='top' halign='left'>");
+         emitServiceList(writer, engine);
+         writer.println("</td>");
+         writer.println("<td valign='top' halign='left'>");    
+         emitOperationList(writer, req.getParameter("service"));
+         writer.println("</td>");        
+         writer.println("<td valign='top' halign='left'>");    
+         emitOperationDetails(writer, req.getParameter("service"), req.getParameter("operation"));
+         writer.println("</td>");
+         writer.println("</tr></table>");
+         return;
+     }   
+     
+     /*
+      * TODO - need to move all static strings into the resource table
+      */
+     public void emitHeader(PrintWriter writer)
+     {       
+         writer.println("<h3>Apache Axis - Service Manager</h3>");
+     }    
+         
+     /*
+      * WORK IN PROGRESS
+      * emits the parameter list and return type definitions for given operation on the given service
+      */
+     public void emitOperationDetails(PrintWriter writer, String serviceParam, String operationParam)
+     {
+         if(operationParam == null)
+         {
+             writer.println("Select an Operation...");
+             return;
+         }
+         
+         try {
+             org.apache.axis.handlers.soap.SOAPService service = engine.getService(serviceParam);
+             ServiceDesc sd = service.getServiceDescription();
+             OperationDesc op = sd.getOperationByName(operationParam);
+             writer.println("<b>Parameters:</b><br>");
+             ArrayList params = op.getParameters();
+             writer.println("<ul>");
+             if(params != null && !params.isEmpty())
+             {
+                 for (Iterator it = params.iterator(); it.hasNext();) 
+                 {
+                     ParameterDesc pd = (ParameterDesc)it.next();
+                     writer.println("<li>");
+                     writer.println(pd.getName() + " - <i>" + pd.getModeAsString(pd.getMode()) + "<br>Type QName:<a href='" + pd.getTypeQName() + "'>" + pd.getTypeQName().getLocalPart() + "</a>" + "</i>");
+                     writer.println("</li>");
+                 }
+             }
+             writer.println("</ul>");
+             
+             writer.println("<b>Return Value:</b><br>");
+             QName ret = op.getReturnType();
+             writer.println("Type QName:" + ret.getLocalPart());
+            
+         } catch (org.apache.axis.AxisFault af)
+         {
+             writer.println(af.dumpToString());
+             
+         } catch (Exception ex)
+         {
+             writer.println(ex.getMessage());
+         }   
+         return;
+     }
+     /*
+      * emit a list links to the operations of the specified ServiceDesc.
+      * serviceParam should contain the name of the service (i.e. "AdminService")
+      * to generate the operation list for
+      *  TODO - user-friendly service description would be nice here
+      */
+     public void emitOperationList(PrintWriter writer, String serviceParam)
+     {
+         if(serviceParam == null)
+         {
+             writer.println("Select a Service...");
+             return;
+         }
+         
+         try {
+             org.apache.axis.handlers.soap.SOAPService service = engine.getService(serviceParam);
+             ServiceDesc sd = service.getServiceDescription();
+             if(sd != null)
+             {
+                 ArrayList operations = sd.getOperations();
+                 if (!operations.isEmpty()) {
+                     writer.println("<ul>");
+                     for (Iterator it = operations.iterator(); it.hasNext();) {
+                         OperationDesc desc = (OperationDesc) it.next();
+                         writer.println("<li>");
+                         writer.println("<a href='AxisServlet?service=" + sd.getName() + "&operation=" + desc.getName() + "'>" + desc.getName() + "</a>");
+                         writer.println("</li>");
+                     }
+                     writer.println("</ul>");
+                 }                        
+             }
+             return;
+         } catch (org.apache.axis.AxisFault ex)
+         {
+             writer.println(ex.dumpToString());
+             return;
+         }   
+     }
+     /*
+      * emits a list of links for each ServiceDesc
+      * TODO - description of each method would be really cool here
+      */
+     public void emitServiceList(PrintWriter writer, AxisEngine engine)
+     {
+         try {
+             Iterator i = engine.getConfig().getDeployedServices();
+             
+             writer.println("<ul>");
+             while (i.hasNext()) {
+                 ServiceDesc sd = (ServiceDesc)i.next();                
+                 writer.println("<li>");
+                 writer.println("<a href='AxisServlet?service=" + sd.getName() + "'>" + sd.getName() + "</a>");                
+                 writer.println("</li>");
+             }
+             writer.println("</ul>");
+             return;            
+         } catch (Exception ex)
+         {
+             log.debug(ex.getMessage());
+         }
      }
  }
