Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

root/trunk/sample/basic/calc/client.rb

Revision 1843, 0.7 kB (checked in by nahi, 2 years ago)
  • reorganize sampless
  • Property svn:eol-style set to native
  • Property svn:keywords set to author date id revision
Line 
1 require 'soap/rpc/driver'
2
3 server = ARGV.shift || 'http://localhost:7000/'
4 # server = 'http://localhost:8808/server.cgi'
5
6 calc = SOAP::RPC::Driver.new(server, 'http://tempuri.org/calcService')
7 calc.wiredump_dev = STDERR if $DEBUG
8 calc.add_method('add', 'lhs', 'rhs')
9 calc.add_method('sub', 'lhs', 'rhs')
10 calc.add_method('multi', 'lhs', 'rhs')
11 calc.add_method('div', 'lhs', 'rhs')
12
13 puts 'add: 1 + 2        # => 3'
14 puts calc.add(1, 2)
15 puts 'sub: 1.1 - 2.2    # => -1.1'
16 puts calc.sub(1.1, 2.2)
17 puts 'multi: 1.1 * 2.2  # => 2.42'
18 puts calc.multi(1.1, 2.2)
19 puts 'div: 5 / 2        # => 2'
20 puts calc.div(5, 2)
21 puts 'div: 5.0 / 2      # => 2.5'
22 puts calc.div(5.0, 2)
23 puts 'div: 1.1 / 0      # => Infinity'
24 puts calc.div(1.1, 0)
25 puts 'div: 1 / 0        # => ZeroDivisionError'
26 puts calc.div(1, 0)
Note: See TracBrowser for help on using the browser.