1 7 package org.jboss.webservice.server; 8 9 11 import org.jboss.axis.AxisEngine; 12 import org.jboss.axis.AxisFault; 13 import org.jboss.axis.MessageContext; 14 import org.jboss.axis.handlers.soap.SOAPService; 15 import org.jboss.logging.Logger; 16 import org.jboss.webservice.ServiceDeployer; 17 18 import javax.servlet.ServletException ; 19 import javax.servlet.http.HttpServletRequest ; 20 import javax.servlet.http.HttpServletResponse ; 21 import java.io.IOException ; 22 import java.io.PrintWriter ; 23 24 33 public class ServiceEndpointServlet extends AbstractServlet 34 { 35 36 static final long serialVersionUID = 3806847653370058302L; 37 38 protected final Logger log = Logger.getLogger(getClass()); 40 41 44 public void doGet(HttpServletRequest req, HttpServletResponse res) 45 throws ServletException , IOException 46 { 47 String url = req.getRequestURL().toString(); 48 String queryString = req.getQueryString(); 49 log.debug("doGet: " + url + (queryString != null ? "?" + queryString : "")); 50 51 PrintWriter writer = res.getWriter(); 52 try 53 { 54 AxisEngine engine = getEngine(); 55 56 String serviceName = getServiceName(req); 58 SOAPService service = (serviceName != null ? engine.getService(serviceName) : null); 59 60 boolean wsdlRequested = req.getParameter("wsdl") != null || req.getParameter("WSDL") != null; 61 62 if (!wsdlRequested) 63 { 64 log.debug("Report available services"); 65 66 reportAvailableServices(res, writer, req); 70 return; 71 } 72 73 if (service == null) 74 { 75 log.error("Cannot get axis service: " + serviceName); 76 reportCantGetAxisService(req, res, writer); 77 return; 78 } 79 80 MessageContext msgContext = createMessageContext(engine, req, res); 82 83 if (service != null) 86 msgContext.setTargetService(serviceName); 87 88 String transportURL = getTransportURL(req, serviceName); 89 if (transportURL != null) 90 { 91 msgContext.setProperty(MessageContext.TRANS_URL, transportURL); 92 log.debug("Set transport.url=" + transportURL); 93 } 94 95 if (wsdlRequested) 96 { 97 String wsdlResource = req.getParameter("resource"); 98 if (wsdlResource != null) 99 { 100 log.debug("Process wsdl import request: " + wsdlResource); 101 msgContext.setProperty(MessageContext.WSDLGEN_RESOURCE, wsdlResource); 102 } 103 else 104 { 105 log.debug("Process wsdl request"); 106 } 107 108 processWsdlRequest(msgContext, res, writer); 109 return; 110 } 111 112 log.debug("Report service info"); 114 reportServiceInfo(res, writer, service, serviceName); 115 } 116 catch (AxisFault fault) 117 { 118 reportTrouble(fault, res, writer); 119 } 120 catch (Exception e) 121 { 122 reportTrouble(e, res, writer); 123 } 124 finally 125 { 126 AxisEngine.setCurrentMessageContext(null); 128 writer.close(); 129 } 130 } 131 132 137 protected String getServiceName(HttpServletRequest req) 138 { 139 String serviceName = getServletConfig().getInitParameter(ServiceDeployer.INIT_PARAM_WEBSERVICE_ID); 140 return serviceName; 141 } 142 } 143 | Popular Tags |