创建一个最简单的restlet webservice
OperationServer1方法里:
public class OperationServer1 extends ServerResource {static String s = "operation1";@Get()public Representation doGet(Representation entity){s = "Get Operation1";StringRepresentation entityRsp=new StringRepresentation(s, MediaType.TEXT_XML);return entityRsp;}@Post()public Representation doPost(Representation entity) {s = "Post Operation1";StringRepresentation entityRsp=new StringRepresentation(s, MediaType.TEXT_XML);return entityRsp; }@Put()public Representation doPut(Representation entity){s = "Put Operation1";StringRepresentation entityRsp=new StringRepresentation(s, MediaType.TEXT_XML);return entityRsp;}@Delete()public Representation doDelete(Representation entity){s = "Delete Operation1";StringRepresentation entityRsp=new StringRepresentation(s, MediaType.TEXT_XML);return entityRsp;}}
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" ><web-app><display-name>restClientExample</display-name><context-param><param-name>contextConfigLocation</param-name><param-value>/WEB-INF/xml/restApi.xml </param-value></context-param><context-param><param-name>logbackConfigLocation</param-name><param-value>/WEB-INF/xml/logback.xml</param-value></context-param><filter> <filter-name>Spring character encoding filter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>utf-8</param-value> </init-param><init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>Spring character encoding filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener><listener-class>ch.qos.logback.classic.servlet.LogbackConfigListener</listener-class></listener><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><servlet><servlet-name>restlet</servlet-name><servlet-class>org.restlet.ext.spring.SpringServerServlet</servlet-class><init-param><param-name>org.restlet.component</param-name><param-value>security_component</param-value></init-param></servlet><servlet-mapping><servlet-name>restlet</servlet-name><url-pattern>/*</url-pattern></servlet-mapping></web-app>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> <beans> <bean id="security_component" ref="security_restRoute" /> </bean> <bean id="security_restRoute" bean="Operation1" /> </bean> </entry> <entry key="/operation2"> <bean bean="Operation2" /> </bean> </entry> </map> </property> </bean> <bean id="Operation1" scope="prototype"></bean><bean id="Operation2" scope="prototype"></bean></beans>
<bean id="fatherSever" ref="公有类"/> </bean><bean id="Operation1" scope="prototype" parent="fatherSever"></bean>