使用Rest客户端mozzilla消费Rest Web服务

Consuming Rest webservices using REST client mozzilla

本文关键字:Rest Web 服务 消费 mozzilla 客户端 使用      更新时间:2023-09-26

我能够成功地执行对服务的GET请求,现在我想知道如何执行POST、PUT、DELETE命令

通过Rest客户端,我执行了OPTION命令,得到了这个结果

<application>
<doc jersey:generatedBy="Jersey: 1.17 01/17/2013 04:27 PM"/>
<grammars>
<include href= "http://localhost:8081/de.vogella.jersey.todo/rest/application.wadl/xsd0.xsd" >
<doc title="Generated" xml:lang="en"/>
</include>
</grammars>
<resources base="http://localhost:8081/de.vogella.jersey.todo/rest/">
<resource path="todos">
<method id="getTodosBrowser" name="GET">
<response>
<ns2:representation element="todo" mediaType="text/xml"/>
</response>
</method>
<method id="getTodos" name="GET">
<response>
<ns2:representation element="todo" mediaType="application/xml"/>
<ns2:representation element="todo" mediaType="application/json"/>
</response>
</method>
<method id="newTodo" name="POST">
<request>
<representation mediaType="application/x-www-form-urlencoded">
<param name="id" style="query" type="xs:string"/>
<param name="summary" style="query" type="xs:string"/>
<param name="description" style="query" type="xs:string"/>
</representation>
</request>
</method>
<resource path="count">
<method id="getCount" name="GET">
<response>
<representation mediaType="text/plain"/>
</response>
</method>
</resource>
<resource path="{todo}">
<param name="todo" style="template" type="xs:string"/>
<method id="getTodo" name="GET">
<response>
<ns2:representation element="todo" mediaType="application/xml"/>
<ns2:representation element="todo" mediaType="application/json"/>
</response>
</method>
<method id="getTodoHTML" name="GET">
<response>
<ns2:representation element="todo" mediaType="text/xml"/>
</response>
</method>
<method id="putTodo" name="PUT">
<request>
<representation mediaType="application/xml"/>
</request>
<response>
<representation mediaType="*/*"/>
</response>
</method>
<method id="deleteTodo" name="DELETE"/>
</resource>
</resource>
</resources>
</application>

现在你能告诉我如何执行PUT、POST、DELETE命令吗?我应该在body和url中写些什么?

非常感谢

不确定你目前是如何发出请求的,尽管你可以给我的插件https://github.com/jpillora/jquery.rest尝试一下。如果您有任何问题,请在"问题"选项卡上发布问题。