RESTful服务

时间:2015-11-10 19:19:18

标签: java eclipse rest

我想在java上创建RESTful Web服务,我选择了eclipse自动生成并获得了这段代码。

@Path("/message")
public class Rest_test {

    @Context
    @SuppressWarnings("unused")
    private UriInfo context;

    /**
     * Default constructor. 
     */
    public Rest_test() {
        // TODO Auto-generated constructor stub
    }

    /**
     * Retrieves representation of an instance of Rest_test
     * @return an instance of String
     */
    @GET
    @Produces("application/xml")
    public String getXml() {
        // TODO return proper representation object
        return "sdfgdsd";
    }

    /**
     * PUT method for updating or creating an instance of Rest_test
     * @param content representation for the resource
     * @return an HTTP response with content of the updated or created resource.
     */
    @PUT
    @Consumes("application/xml")
    public void putXml(String content) {
    }

}

为了测试我的应用程序我使用程序Postman并从这个adrres调用我的服务器 localhost:8080/test/rest/message 但我总是有相同的页面 HTTP状态404 - 未找到。请帮帮我

1 个答案:

答案 0 :(得分:0)

评论是正确的!你应该致电: 本地主机:8080 / nameOfYourService /休息/消息

我还有一个TestWebService,并且无法突然调用它。

我创建了一个本地客户端应用并使用httpURLconnection:

{{1}}

enter image description here

对你来说“ps”应该是“消息”

相关问题