File: client.rb

package info (click to toggle)
soap4r 1.4.8-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,472 kB
  • ctags: 2,206
  • sloc: ruby: 19,295; makefile: 58; sh: 41; perl: 10
file content (25 lines) | stat: -rw-r--r-- 728 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require 'soap/driver'

server = 'http://localhost:7000/'
# server = 'http://localhost/cgi-bin/server.cgi'

calc = SOAP::Driver.new( nil, nil, 'http://tempuri.org/calcService', server )
calc.addMethod( 'add', 'lhs', 'rhs' )
calc.addMethod( 'sub', 'lhs', 'rhs' )
calc.addMethod( 'multi', 'lhs', 'rhs' )
calc.addMethod( 'div', 'lhs', 'rhs' )

puts 'add: 1 + 2	# => 3'
puts calc.add( 1, 2 )
puts 'sub: 1.1 - 2.2	# => -1.1'
puts calc.sub( 1.1, 2.2 )
puts 'multi: 1.1 * 2.2	# => 2.42'
puts calc.multi( 1.1, 2.2 )
puts 'div: 5 / 2	# => 2'
puts calc.div( 5, 2 )
puts 'div: 5.0 / 2	# => 2.5'
puts calc.div( 5.0, 2 )
puts 'div: 1.1 / 0	# => Infinity'
puts calc.div( 1.1, 0 )
puts 'div: 1 / 0	# => ZeroDivisionError'
puts calc.div( 1, 0 )