[edit] David made RESTful requests instead of using the XMLRPC, and it works nicely

here’s the test code:


1 require 'net/http'
2 require 'pp' # pretty print
3 require 'rubygems'
4 require 'json' # need to gem install this
5
6 url = 'http://.com:60091/get_context?data=%7B%22x%22:20,%22y%22:20,% 22z%22:20%7D'
7 response = Net::HTTP.get_response(URI.parse(url))
8 case response
9 when Net::HTTPSuccess then data = response.body
10 when Net::HTTPRedirection then fetch(response['location'], limit - 1)
11 else
12 data.error!
13 end
14
15 result = JSON.parse(data) # the magic!
16
17 pp result


Ok, so I’m trying to use an XMLRPC call to the display server, and here’s my test code:

1 require ‘xmlrpc/client’
2 require ‘pp’
3 server = XMLRPC::Client.new2(‘http://.com:60091’)
4 @resp = server.call(‘data={%22x%22:10,%22y%22:10,%22z%22:10}’)
5 pp @resp
But then i get this error message:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/xmlrpc/client.rb:554:in `do_rpc’: Wrong content-type (RuntimeError)
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/xmlrpc/client.rb:420:in `call2′
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/xmlrpc/client.rb:410:in `call’ from xmlrpcsample.rb:4

So can someone give me a more detailed instruction on how to make the proper call?

Advertisements