1 25 package org.objectweb.jonas.ws.axis; 26 27 import java.io.PrintWriter ; 28 import java.util.ArrayList ; 29 import java.util.Iterator ; 30 import javax.naming.InitialContext ; 31 import javax.naming.NamingException ; 32 import javax.servlet.http.HttpServletRequest ; 33 import javax.servlet.http.HttpServletResponse ; 34 import javax.xml.namespace.QName ; 35 import org.apache.axis.AxisEngine; 36 import org.apache.axis.AxisFault; 37 import org.apache.axis.ConfigurationException; 38 import org.apache.axis.description.OperationDesc; 39 import org.apache.axis.description.ServiceDesc; 40 import org.apache.axis.server.AxisServer; 41 import org.apache.axis.transport.http.AxisServlet; 42 import org.objectweb.jonas_ws.deployment.api.WSDeploymentDescException; 43 44 49 public class JAxisServlet extends AxisServlet { 50 51 60 protected void reportAvailableServices(HttpServletResponse response, 61 PrintWriter writer, 62 HttpServletRequest request) throws 63 ConfigurationException, AxisFault { 64 AxisEngine engine = getEngine(); 65 66 response.setContentType("text/html; charset=utf-8"); 67 writer.println("<h2>And now... Some Services</h2>"); 68 69 Iterator i; 70 try { 71 i = engine.getConfig().getDeployedServices(); 72 } catch (ConfigurationException configException) { 73 if (configException.getContainedException() instanceof AxisFault) { 76 throw (AxisFault) configException.getContainedException(); 77 } else { 78 throw configException; 79 } 80 } 81 82 InitialContext iCtx; 84 AxisServer axisServer = getEngine(); 85 org.objectweb.jonas_ws.deployment.api.ServiceDesc serviceDesc = null; 86 try { 87 iCtx = new InitialContext (); 88 serviceDesc = (org.objectweb.jonas_ws.deployment.api.ServiceDesc) iCtx.lookup("java:comp/jonas/" + axisServer.getName() + "/dd"); 89 } catch (NamingException e) { 90 throw new AxisFault("Servlet name not found : " + axisServer.getName(), e); 91 } 92 93 writer.println("<ul>"); 94 while (i.hasNext()) { 95 ServiceDesc sd = (ServiceDesc) i.next(); 96 StringBuffer sb = new StringBuffer (); 97 sb.append("<li>"); 98 String name = sd.getName(); 99 sb.append(name); 100 sb.append(" <a HREF=\""); 101 String endpointURL = null; 102 try { 103 endpointURL = serviceDesc.getWSDL().getLocation(new QName (name)).toExternalForm(); 104 } catch (WSDeploymentDescException e) { 105 throw new AxisFault("Cannot find endpoint URL for server " + axisServer.getName() + " and port " + name, e); 106 } 107 sb.append(endpointURL); 108 sb.append("?jwsdl\"><i>(wsdl)</i></a></li>"); 109 writer.println(sb.toString()); 110 ArrayList operations = sd.getOperations(); 111 if (!operations.isEmpty()) { 112 writer.println("<ul>"); 113 for (Iterator it = operations.iterator(); it.hasNext();) { 114 OperationDesc desc = (OperationDesc) it.next(); 115 writer.println("<li>" + desc.getName()); 116 } 117 writer.println("</ul>"); 118 } 119 } 120 writer.println("</ul>"); 121 } 122 123 } | Popular Tags |