实现Restful API的方法

实现REST API有两种方法。
第一种:

The main tool for building a REST API based on internal services and entity operations is to define resource paths in aService REST APIXML file such as themoqui.rest.xmlfile inmoqui-frameworkand themantle.rest.xmlfile inmantle-usl. With your own Service REST API XML files you can define sets of web services to match the structure of the applications you are building, and grant authorization to different paths for different sets of users just like with XML Screens. In the Tools app you can view Service REST API details using automatic Swagger output produced by the framework based on the REST XML file and the entities and services used within it.

这是主要工具,它基于内部服务和实体操作,在服务的rest.api.xml中定义resource paths,例如框架的moqui.rest.xml和mantle-usl衷的mantle.rest.xml。

本质上是定义一种服务(Service),服务内部的定义标签是 ,可以多层嵌套,每一层都可以单独设置该层的属性,譬如访问控制属性 require-authentication。调用路径(注意rest/s1的前缀):http://localhost:8080/rest/s1/example/examples/100051/featureAppls

第二种:

Another alternative for REST style services a screen transition can be declared with a HTTP request method (get, put, etc) as well as a name to match against the incoming URL. For more flexible support of parameters in the URL beyond the transition’s place in the URL path values following the transition can be configured to be treated the same as named parameters. To make things easier for JSON payloads they are also automatically mapped to parameters and can be treated just like parameters from any other source, allowing for easily reusable server-side code. To handle these REST service transitions an internal service can be called with very little configuration, providing for an efficient mapping between exposed REST services and internal services.

第二种基于screen的 transition。定义一个带有HTTP请求方法(get、put等)的 transition 。REST样式服务的另一个替代方案是屏幕转换,可以使用HTTP请求方法(get、put等)以及与传入URL匹配的名称来声明。为了更灵活地支持URL中超出转换位置的参数,可以将转换后的URL路径值配置为与命名参数相同。为了使JSON有效负载更容易,它们还自动映射到参数,并且可以像来自任何其他源的参数一样处理,从而允许轻松地重用服务器端代码。来处理这些REST服务转换。

调用路径:http://localhost:8080/apps/example/ExampleEntity2/TEST1