| | 1 | This code does '''not''' work! Please help! Is XMLRPC or SOAP4R better for the initial talking to MOBY. |
| | 2 | |
| | 3 | {{{ |
| | 4 | require 'rubygems' |
| | 5 | require 'soap/rpc/driver' |
| | 6 | require 'xmlrpc/client' |
| | 7 | |
| | 8 | class Foo |
| | 9 | end |
| | 10 | |
| | 11 | module Bio |
| | 12 | module Moby |
| | 13 | module Client |
| | 14 | class Central |
| | 15 | |
| | 16 | URI = 'http://biomoby.org/MOBY/Central' |
| | 17 | |
| | 18 | def initialize |
| | 19 | mobycentral,ontologyser = getDefaultCentral |
| | 20 | p mobycentral |
| | 21 | p ontologyser |
| | 22 | @driver = SOAP::RPC::Driver.new(mobycentral,URI) |
| | 23 | @driver.wiredump_dev = STDOUT |
| | 24 | @driver2 = XMLRPC::Client.new2(URI) |
| | 25 | |
| | 26 | begin |
| | 27 | p @driver2.call('retrieveServiceNames') |
| | 28 | rescue RuntimeError => e |
| | 29 | puts "error #{e.inspect}" |
| | 30 | end |
| | 31 | |
| | 32 | @driver.add_method_with_soapaction( |
| | 33 | "findService", |
| | 34 | "http://biomoby.org/MOBY/Central#findService", |
| | 35 | "args" |
| | 36 | ) |
| | 37 | |
| | 38 | end |
| | 39 | |
| | 40 | def getDefaultCentral |
| | 41 | |
| | 42 | require 'httpclient' |
| | 43 | |
| | 44 | client = HTTPClient.new |
| | 45 | mobycentral = client.head('http://biomoby.org/mobycentral').header['location'] |
| | 46 | ontologyser = client.head('http://biomoby.org/ontologyserver').header['location'] |
| | 47 | return mobycentral,ontologyser |
| | 48 | end |
| | 49 | |
| | 50 | def findService(keyword) |
| | 51 | message = "<findservice>\n" |
| | 52 | message += "<authoritative></authoritative>" |
| | 53 | message += "<serviceName>#{keyword}</serviceName>" |
| | 54 | message += "<expandObjects>0</expandObjects>" |
| | 55 | message += "<expandServices>0</expandServices>" |
| | 56 | message += "</findservice>" |
| | 57 | #@driver.findService(message) |
| | 58 | p @driver2.call('findService',message) |
| | 59 | end |
| | 60 | |
| | 61 | end |
| | 62 | end |
| | 63 | end |
| | 64 | end |
| | 65 | |
| | 66 | Bio::Moby::Client::Central.new.findService('getGoTerm') |
| | 67 | |
| | 68 | }}} |