1 22 package org.jboss.test.webservice.ws4eesimple; 23 24 import org.jboss.logging.Logger; 25 26 import javax.naming.InitialContext ; 27 import javax.servlet.ServletException ; 28 import javax.servlet.http.HttpServlet ; 29 import javax.servlet.http.HttpServletRequest ; 30 import javax.servlet.http.HttpServletResponse ; 31 import javax.xml.rpc.Service ; 32 import java.io.IOException ; 33 import java.io.PrintWriter ; 34 35 public class HelloWsClientServlet extends HttpServlet 36 { 37 private static final Logger log = Logger.getLogger(HelloWsClientServlet.class); 39 40 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException , IOException 41 { 42 response.setContentType("text/plain"); 43 PrintWriter pw = response.getWriter(); 44 try 45 { 46 InitialContext iniCtx = new InitialContext (); 47 Service service = (Service )iniCtx.lookup("java:comp/env/service/HelloService"); 48 HelloWs sei = (HelloWs)service.getPort(HelloWs.class); 49 50 String input = request.getParameter("input"); 51 String output = sei.sayHello(input); 52 53 pw.println(output); 54 } 55 catch (Exception e) 56 { 57 log.error("Access failed", e); 58 e.printStackTrace(pw); 59 } 60 finally 61 { 62 pw.close(); 63 } 64 } 65 } 66 | Popular Tags |