任何人都可以用一个例子来解释我,使用REST Client在Rest Web服务中进行GET / POST / PUT操作吗?
在POST / PUT中,使用REST Client,需要传递整个xml主体来进行POST / PUT操作。
例如,使用REST Client
我需要使用,获取服务的内容,
RESTClient.get(url)
将xml发布到网址:
RESTClient.post(url,entirexml)
将xml输入URL:
RESTClient.put(url,entirexml)
使用REST CLIENT进行删除。
任何人都可以通过示例帮助我提供所有REST客户端HTTP方法的示例吗?
我需要使用REST Client的PUT / POST操作将整个XML和命名空间一起发送到休息服务。
如果有人有这方面的例子,那么请发帖。
require 'rest-client'
RestClient.get 'http://example.com/resource', {:params => {:id => 50, 'foo' => 'bar'}}
RestClient.get 'http://example.com/resource'
xml = '<xml><foo>bar</foo><bar>foo</bar></xml>'
RestClient.post 'http://example.com/resource', xml , {:content_type => :xml}
RestClient.put 'http://example.com/resource', xml , {:content_type => :xml}
RestClient.delete 'http://example.com/resource'
请参阅https://github.com/rest-client/rest-client上的更多示例和文档
git site for the rest-client gem上的自述文件包含大量如何执行请求,包含参数等的示例。
我从那开始。
如果有特定的东西不起作用,那么通常有助于发布你认为应该正常工作的代码,然后人们通常更容易告诉你哪里出错了。