Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 43 lines (29 sloc) 1.712 kB
c9f25a4 initial commit
Stefan Henzen authored
1 = ServiceInvoker
2
3 A plugin for accessing web services over http. To Invoke a Web service you create a stub with a request builder and a set of response processors. Request builders are responsible for generating the HTTP request from a set of parameters. Response processors are responsible for retrieving protocol-specific data from the HTTP response.
4
5 Several request builders and response processors are included in this plugin. It includes request builders for xmlrpc and basic (rest-full) requests. It also contains response processors for files, json, xml and xmlrpc responses. Request builders and response processors for SOAP are also included, but these are less easy to use.
6
7 == Example
8
9 Accessing a rest-full resource (Google Search's API):
10
11 class GoogleSearchConsumer < ServiceInvoker::Base
12 request_builder BasicBuilder,
13 :endpoint_url => "http://www.google.com/uds/GwebSearch",
14 :default_get_params => {
15 "hl" => "en",
16 "key" => "<YOUR API KEY>",
17 "v" => "1.0"
18 }
19
20 response_module JSONProcessing
21 end
22
23 Then try
24
25 puts GoogleSearchConsumer.invoke(:url_params => {"q" => 'ruby'}).unmarshal_json
26
27 Accessing an xml-rpc resource (Flickr's XML-RPC API):
28
29 class FlickrConsumer < ServiceInvoker::Base
30 request_builder XMLRPCBuilder,
31 :endpoint_url => "api.flickr.com/services/xmlrpc/"
32
33 response_module XMLRPCProcessing
34 response_module XMLProcessing
35 end
36
37 Than do something like
38
39 Struct.new('EchoStruct', :api_key, :name, :name2)
40 FlickrConsumer.invoke(:name => 'flickr.test.echo', :args =>
41 [Struct::EchoStruct.new('<YOUR API KEY>', 'value', 'value2')])
42
43 Copyright (c) 2008 Nedforce Informatica Specialisten B.V., released under the MIT license
Something went wrong with that request. Please try again.