remoting服务例子
1、remoting-servlet.xml
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE beans PUBLIC "-//Spring//DTD Bean//EN" "http://www.springframework.org/dtd/spring-beans.dtd"><beans><bean name="/hello/find" ref="helloImpl" /><property name="serviceInterface" value="com.IHello" /></bean></beans>
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE beans PUBLIC "-//Spring//DTD Bean//EN" "http://www.springframework.org/dtd/spring-beans.dtd"><beans><bean name="testRemote" value="http://localhost:8080/Test/remoting/hello/find" /><property name="serviceInterface" value="com.inf.IHello" /></bean></beans>
<servlet><servlet-name>remoting</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><load-on-startup>2</load-on-startup></servlet><servlet-mapping><servlet-name>remoting</servlet-name><url-pattern>/remoting/*</url-pattern></servlet-mapping>
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");IHello hello = (IHello)context.getBean("testRemote");Result result = hello.findByName("jack");System.out.println(result.getLstUser().size());//免配置HttpInvokerProxyFactoryBean bean=new HttpInvokerProxyFactoryBean();bean.setServiceUrl("http://localhost:8080/Test/remoting/hello/find");bean.setServiceInterface(IHello.class);bean.afterPropertiesSet();//必须IHello hello = (IHello)bean.getObject();Result result = hello.findByName("jack");System.out.println(result.getLstUser().size());