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

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

Revision 1843, 0.9 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/server2.cgi'
5
6 var = SOAP::RPC::Driver.new( server, 'http://tempuri.org/calcService' )
7 var.add_method( 'set', 'newValue' )
8 var.add_method( 'get' )
9 var.add_method_as( '+', 'add', 'rhs' )
10 var.add_method_as( '-', 'sub', 'rhs' )
11 var.add_method_as( '*', 'multi', 'rhs' )
12 var.add_method_as( '/', 'div', 'rhs' )
13
14 puts 'var.set( 1 )'
15 puts '# Bare in mind that another client set another value to this service.'
16 puts '# This is only a sample for proof of concept.'
17 var.set( 1 )
18 puts 'var + 2   # => 1 + 2 = 3'
19 puts var + 2
20 puts 'var - 2.2 # => 1 - 2.2 = -1.2'
21 puts var - 2.2
22 puts 'var * 2.2 # => 1 * 2.2 = 2.2'
23 puts var * 2.2
24 puts 'var / 2   # => 1 / 2 = 0'
25 puts var / 2
26 puts 'var / 2.0 # => 1 / 2.0 = 0.5'
27 puts var / 2.0
28 puts 'var / 0   # => 1 / 0 => ZeroDivisionError'
29 puts var / 0
Note: See TracBrowser for help on using the browser.