日期:2014-05-17 浏览次数:20852 次
<servlet> <servlet-name>XmlRpcServlet</servlet-name> <servlet-class>org.apache.xmlrpc.webserver.XmlRpcServlet</servlet-class> <init-param> <param-name>enabledForExtensions</param-name> <param-value>true</param-value> </init-param> </servlet>
public class Calculator { public int add(int i1, int i2) { return i1 + i2; } }
Calculator=com.oyl.Calculator
public class CustomRequestProcessorFactoryFactory implements RequestProcessorFactoryFactory { private final RequestProcessorFactory factory = new CustomRequestProcessorFactory(); private final CustomWebServiceHandler service; public CustomRequestProcessorFactoryFactory(CustomWebServiceHandler service) { this.service = service; } @Override public RequestProcessorFactory getRequestProcessorFactory(Class arg0) throws XmlRpcException { return factory; } private class CustomRequestProcessorFactory implements RequestProcessorFactory { @Override public Object getRequestProcessor(XmlRpcRequest arg0) throws XmlRpcException { return service; } } }
public class CustomXmlRpcServlet extends XmlRpcServlet { private static final long serialVersionUID = 8615627610262194L; protected static ApplicationContext ctx = null; public CustomXmlRpcServlet() { super(); } public void init() { if (ctx == null) { ctx = WebApplicationContextUtils .getRequiredWebApplicationContext(this.getServletContext()); } } protected XmlRpcHandlerMapping newXmlRpcHandlerMapping() throws XmlRpcException { PropertyHandlerMapping mapping = new PropertyHandlerMapping(); CustomWebServiceHandler service = (CustomWebServiceHandler) ctx.getBean("customWebServiceHandler"); mapping.setRequestProcessorFactoryFactory(new CustomRequestProcessorFactoryFactory(service)); mapping.addHandler("CustomWebServiceHandler", CustomWebServiceHandler.class); return mapping; } }