1 6 7 package org.jfox.ioc.connector.soap; 8 9 import java.io.OutputStream ; 10 import java.io.IOException ; 11 import javax.servlet.http.HttpServletRequest ; 12 import javax.servlet.http.HttpServletResponse ; 13 import javax.servlet.http.HttpServlet ; 14 import javax.servlet.ServletException ; 15 16 import org.apache.xmlrpc.XmlRpcServer; 17 18 22 23 public class XMLRPCServlet extends HttpServlet { 24 private static XmlRpcServer xmlrpc; 25 26 public void init() throws ServletException { 27 xmlrpc = new XmlRpcServer(); 28 try { 29 xmlrpc.addHandler("$default", new JRMPXmlRpcHandler()); 30 } 31 catch(Exception e) { 32 throw new ServletException (e); 33 } 34 } 35 36 protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException , IOException { 37 res.setContentType("text/plain"); 38 OutputStream out = res.getOutputStream(); 39 out.write("xml rpc proxy servlet\n".getBytes()); 40 out.close(); 41 } 42 43 protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException , IOException { 44 byte[] result = xmlrpc.execute(req.getInputStream()); 45 res.setContentType("text/xml"); 46 res.setContentLength(result.length); 47 OutputStream output = res.getOutputStream(); 48 output.write(result); 49 output.flush(); 50 output.close(); 51 } 52 53 public static void main(String [] args) { 54 55 } 56 } | Popular Tags |