Class: VORuby::Services::Registry::STScI
- Defined in:
- lib/voruby/services/registry/registry.rb
Instance Attribute Summary collapse
-
#driver ⇒ Object
readonly
Returns the value of attribute driver.
-
#factory ⇒ Object
readonly
Returns the value of attribute factory.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(driver, debug = false) ⇒ STScI
constructor
A new instance of STScI.
- #queryVOResource(predicate) ⇒ Object
Constructor Details
#initialize(driver, debug = false) ⇒ STScI
Returns a new instance of STScI.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/voruby/services/registry/registry.rb', line 13 def initialize(driver, debug=false) @driver = driver @driver.wiredump_dev = $stderr if debug # This is basically a big hack. We are going to ignore everything soap4r # does for us in terms of interpreting the result of a query. Instead # we'll dump the raw SOAP to file and parse it on our own. This is obviously # not optimal, but works for now. @driver.wiredump_file_base = Dir::tmpdir() + '/stsci_registry' end |
Instance Attribute Details
#driver ⇒ Object (readonly)
Returns the value of attribute driver.
11 12 13 |
# File 'lib/voruby/services/registry/registry.rb', line 11 def driver @driver end |
#factory ⇒ Object (readonly)
Returns the value of attribute factory.
11 12 13 |
# File 'lib/voruby/services/registry/registry.rb', line 11 def factory @factory end |
Class Method Details
.from_wsdl(wsdl = "http://nvo.stsci.edu/VORegistry/registry.asmx?WSDL", debug = false) ⇒ Object
24 25 26 |
# File 'lib/voruby/services/registry/registry.rb', line 24 def self.from_wsdl(wsdl="http://nvo.stsci.edu/VORegistry/registry.asmx?WSDL", debug=false) return STScI.new(SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver, debug) end |
Instance Method Details
#queryVOResource(predicate) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/voruby/services/registry/registry.rb', line 28 def queryVOResource(predicate) params = {'predicate' => predicate} request_file = @driver.wiredump_file_base() + '_queryVOResource_request.xml' response_file = @driver.wiredump_file_base() + '_queryVOResource_response.xml' # Query the registry @driver.queryVOResource(params.to_soap_map) # Parse the returned SOAP envelope and extract the query result soap_envelope = REXML::Document.new File.new(response_file) response = REXML::XPath.first(soap_envelope.root, '//QueryVOResourceResult') # Convert the result into our own domain objects resources = VORuby::Resources::STScI::ArrayOfResource.load_from_xml(VORuby::Resources::STScI::clean(response)) # Clean up the wiredump files. File.unlink(request_file, response_file) return resources end |