Testing Service Oriented Architectures
by Arunava Chatterjee

Example 1:

#read the methods and responses from test.properties
fis = FileInputStream.new("test.properties")
          @properties = Properties.new
          @properties.load(fis)
          fis.close
          keys = @properties.keys
#add methods to return the recorded response
          keys.each do |key|
            puts "Adding method " + key.to_s
            add_method(self,key.to_s, Object.new)
            self.class.send('define_method', key.to_s) { |*args|
               if (@properties.containsKey(key.to_s))
                 value= @properties.get(key)
                 puts "Found operation " + key.to_s + " 
                                  with value " + value.to_s
#retrieve the data from the saved result
                 if (value)
                   if (value.rindex('.yml') > 0)
                     data = YAML::load_file(value)
                     return data
                   else
                     file = File.new(value)
                     data = file.readlines
                     file.close
                     return data
                   end
                 end
               end
               }
            end


Example 2:

driver = SOAP::RPC::Driver.new(
    'http://localhost:8080/axis2/services/WeatherService',
    'http://ws.apache.org/axis2')  
driver = SOAP::RPC::Driver.new(
    'http://localhost:9080/','urn:weatherSoapServer')
driver.add_method('getWeather')

file = File.new('getweather.yml','w')
YAML.dump(driver.getWeather,file)
file.close



1


