You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by de...@apache.org on 2005/02/14 04:07:35 UTC

svn commit: r153698 - in webservices/axis/trunk/java/dev/scratch/prototype2/src: conf/ html/ java/org/apache/axis/description/ java/org/apache/axis/engine/ java/org/apache/axis/phaseresolver/ java/org/apache/axis/transport/http/

Author: deepal
Date: Sun Feb 13 19:07:32 2005
New Revision: 153698

URL: http://svn.apache.org/viewcvs?view=rev&rev=153698
Log:
Modified AxisServlet to list all the available services and their opearions

Modified:
    webservices/axis/trunk/java/dev/scratch/prototype2/src/conf/web.xml
    webservices/axis/trunk/java/dev/scratch/prototype2/src/html/index.html
    webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisService.java
    webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/EngineRegistry.java
    webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/EngineRegistryImpl.java
    webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseHolder.java
    webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/AxisServlet.java

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/conf/web.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/conf/web.xml?view=diff&r1=153697&r2=153698
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/conf/web.xml (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/conf/web.xml Sun Feb 13 19:07:32 2005
@@ -25,6 +25,12 @@
 
   <servlet-mapping>
     <servlet-name>AxisServlet</servlet-name>
+    <url-pattern>/listServices</url-pattern>
+  </servlet-mapping>
+
+
+  <servlet-mapping>
+    <servlet-name>AxisServlet</servlet-name>
     <url-pattern>/services/*</url-pattern>
   </servlet-mapping>
 </web-app>

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/html/index.html
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/html/index.html?view=diff&r1=153697&r2=153698
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/html/index.html (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/html/index.html Sun Feb 13 19:07:32 2005
@@ -1,6 +1,10 @@
 <html>
 	<head></head>
 	<body>
+       <form method="post" name="Axis2" action="listServices">
+
 		<h1>Apache Axis2</h1>	
+            <input name="submit" type="submit" value=" List Available services " >
+       </form>
 	</body>
 </html>

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisService.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisService.java?view=diff&r1=153697&r2=153698
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisService.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisService.java Sun Feb 13 19:07:32 2005
@@ -234,6 +234,8 @@
         return (Class)this.getComponentProperty(DescriptionConstants.SERVICE_CLASS);
     }
 
-    
+    public HashMap getOperations() {
+        return operationsMap;
+    }
 
 }

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/EngineRegistry.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/EngineRegistry.java?view=diff&r1=153697&r2=153698
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/EngineRegistry.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/EngineRegistry.java Sun Feb 13 19:07:32 2005
@@ -58,6 +58,7 @@
      * Ordred list of phases
      */
     public ArrayList getPhases();
+    public HashMap getServices();
 
 //    public ArrayList getTransPorts() ;
 //    public void setTransPorts(ArrayList transPorts) ;

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/EngineRegistryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/EngineRegistryImpl.java?view=diff&r1=153697&r2=153698
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/EngineRegistryImpl.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/EngineRegistryImpl.java Sun Feb 13 19:07:32 2005
@@ -39,6 +39,10 @@
         phases = new ArrayList();
     }
 
+    public HashMap getServices() {
+        return services;
+    }
+
     public synchronized void addMdoule(AxisModule module) throws AxisFault {
         modules.put(module.getName(),module);
     }

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseHolder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseHolder.java?view=diff&r1=153697&r2=153698
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseHolder.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/phaseresolver/PhaseHolder.java Sun Feb 13 19:07:32 2005
@@ -157,7 +157,7 @@
     public  void getOrderdHandlers(int chainType) throws PhaseException {
         try {
             OrderdPhases();
-            Vector tempHander = new Vector();
+       //     Vector tempHander = new Vector();
             HandlerMetaData[] handlers;
 
             switch (chainType) {
@@ -212,7 +212,7 @@
     public void buildTransportChain(AxisTransport trnsport , int chainType) throws PhaseException {
         try{
             OrderdPhases();
-            Vector tempHander = new Vector();
+          //  Vector tempHander = new Vector();
             HandlerMetaData[] handlers;
             Class handlerClass = null;
             Handler handler;
@@ -304,7 +304,7 @@
     public  void buildGoblalChain(AxisGlobal axisGlobal, int chainType) throws PhaseException {
         try {
             OrderdPhases();
-            Vector tempHander = new Vector();
+       //     Vector tempHander = new Vector();
             HandlerMetaData[] handlers;
 
             switch (chainType) {

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/AxisServlet.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/AxisServlet.java?view=diff&r1=153697&r2=153698
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/AxisServlet.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/AxisServlet.java Sun Feb 13 19:07:32 2005
@@ -1,24 +1,29 @@
 /*
- * Copyright 2003,2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2003,2004 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
 package org.apache.axis.transport.http;
 
 
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
@@ -43,13 +48,17 @@
 import org.apache.axis.om.SOAPEnvelope;
 import org.apache.axis.om.impl.llom.builder.StAXBuilder;
 import org.apache.axis.om.impl.llom.builder.StAXSOAPModelBuilder;
+import org.apache.axis.description.AxisService;
+import org.apache.axis.description.AxisOperation;
 
 
 
 
 public class AxisServlet extends HttpServlet{
     private EngineRegistry engineRegistry;
-    
+    private final String LISTSERVICES = "listServices";
+
+
     public void init(ServletConfig config) throws ServletException {
         try {
             ServletContext context = config.getServletContext();
@@ -59,33 +68,34 @@
             throw new ServletException(e);
         }
     }
-
-    
-    
-
     /* (non-Javadoc)
-     * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
-     */
+    * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+    */
     protected void doPost(HttpServletRequest req, HttpServletResponse res)
-        throws ServletException, IOException {
+            throws ServletException, IOException {
         try {
             res.setContentType("text/xml; charset=utf-8");
             AxisEngine engine  = new AxisEngine(engineRegistry);
             MessageContext msgContext = new MessageContext(engineRegistry);
             msgContext.setServerSide(true);
             String filePart = req.getRequestURL().toString();
+            if(filePart != null && filePart.endsWith(LISTSERVICES))  {
+                listServices(res);
+                return;
+            }
             msgContext.setTo(new EndpointReference(AddressingConstants.WSA_TO,filePart));
-            
+
             String soapActionString = req.getHeader(HTTPConstants.HEADER_SOAP_ACTION);
+
             if (soapActionString != null) {
                 msgContext.setProperty(MessageContext.SOAP_ACTION, soapActionString);
             }
-            
+
             InputStreamReader isr = new InputStreamReader(req.getInputStream());
             XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(isr);
             StAXBuilder builder = new StAXSOAPModelBuilder(OMFactory.newInstance(), reader);
             msgContext.setEnvelope((SOAPEnvelope) builder.getDocumentElement());
-            
+
             storeOutputInfo(msgContext, res.getOutputStream());
             engine.receive(msgContext);
         } catch (AxisFault e) {
@@ -101,19 +111,53 @@
     protected void storeOutputInfo(MessageContext msgContext,
                                    OutputStream out) throws AxisFault {
 //        try {
-            // Send it on its way...
+        // Send it on its way...
 //            out.write(HTTPConstants.HTTP);
 //            out.write(HTTPConstants.OK);
 //            out.write("\n\n".getBytes());
-            //We do not have any Addressing Headers to put
-            //let us put the information about incoming transport
-            msgContext.setProperty(MessageContext.TRANSPORT_TYPE,
-                    TransportSenderLocator.TRANSPORT_HTTP);
-            msgContext.setProperty(MessageContext.TRANSPORT_DATA, out);
+        //We do not have any Addressing Headers to put
+        //let us put the information about incoming transport
+        msgContext.setProperty(MessageContext.TRANSPORT_TYPE,
+                TransportSenderLocator.TRANSPORT_HTTP);
+        msgContext.setProperty(MessageContext.TRANSPORT_DATA, out);
 //        } catch (IOException e) {
 //            throw AxisFault.makeFault(e);
 //        }
     }
+
+    private void listServices(HttpServletResponse res) throws IOException {
+        HashMap services = engineRegistry.getServices();
+        HashMap operations;
+        String serviceName = "";
+        Collection servicecol= services.values()  ;
+        Collection operationsList;
+        PrintWriter out = res.getWriter();
+        res.setContentType("text/html");
+        String  html = "<HTML>\n" +
+                "<HEAD><TITLE>Avalilable services</TITLE></HEAD>\n" +
+                "<BODY>\n" +
+                "<H1>Avalilable services</H1>\n";
+
+
+        for (Iterator iterator = servicecol.iterator(); iterator.hasNext();) {
+            AxisService axisService = (AxisService) iterator.next();
+            operations = axisService.getOperations();
+            operationsList = operations.values();
+            serviceName = axisService.getName().getLocalPart();
+            html += "<hr><h3><font color=\"blue\">"+ serviceName + "</font><h3>";
+            if(operationsList.size() > 0){
+            html += "<i> Availble operations</i>";
+            }else {
+                html += "<i> There is no any opeartion specified</i>";
+            }
+            for (Iterator iterator1 = operationsList.iterator(); iterator1.hasNext();) {
+                AxisOperation axisOperation = (AxisOperation) iterator1.next();
+            html += "<li>" + axisOperation.getName().getLocalPart()+ "</li>";
+            }
+        }
+        out.println(html + "</BODY></HTML>");
+    }
+
 
 
 }