summaryrefslogtreecommitdiff
path: root/sample/soap
diff options
context:
space:
mode:
Diffstat (limited to 'sample/soap')
-rw-r--r--sample/soap/babelfish.rb16
-rw-r--r--sample/soap/calc/calc.rb17
-rw-r--r--sample/soap/calc/calc2.rb29
-rw-r--r--sample/soap/calc/client.rb26
-rw-r--r--sample/soap/calc/client2.rb29
-rw-r--r--sample/soap/calc/httpd.rb15
-rw-r--r--sample/soap/calc/server.cgi15
-rw-r--r--sample/soap/calc/server.rb17
-rw-r--r--sample/soap/calc/server2.rb20
-rw-r--r--sample/soap/digraph.rb43
-rw-r--r--sample/soap/exchange/client.rb19
-rw-r--r--sample/soap/exchange/exchange.rb17
-rw-r--r--sample/soap/exchange/httpd.rb15
-rw-r--r--sample/soap/exchange/server.cgi14
-rw-r--r--sample/soap/exchange/server.rb16
-rw-r--r--sample/soap/helloworld/hw_c.rb6
-rw-r--r--sample/soap/helloworld/hw_s.rb17
-rw-r--r--sample/soap/icd/IICD.rb17
-rw-r--r--sample/soap/icd/icd.rb46
-rw-r--r--sample/soap/raa/iRAA.rb154
-rw-r--r--sample/soap/raa/soap4r.rb30
-rw-r--r--sample/soap/sampleStruct/client.rb16
-rw-r--r--sample/soap/sampleStruct/httpd.rb15
-rw-r--r--sample/soap/sampleStruct/iSampleStruct.rb22
-rw-r--r--sample/soap/sampleStruct/sampleStruct.rb13
-rw-r--r--sample/soap/sampleStruct/server.cgi14
-rw-r--r--sample/soap/sampleStruct/server.rb16
27 files changed, 674 insertions, 0 deletions
diff --git a/sample/soap/babelfish.rb b/sample/soap/babelfish.rb
new file mode 100644
index 0000000000..eb2421449a
--- /dev/null
+++ b/sample/soap/babelfish.rb
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+
+text = ARGV.shift || 'Hello world.'
+lang = ARGV.shift || 'en_fr'
+
+require 'soap/rpc/driver'
+
+server = 'http://services.xmethods.net/perl/soaplite.cgi'
+InterfaceNS = 'urn:xmethodsBabelFish'
+wireDumpDev = nil # STDERR
+
+drv = SOAP::RPC::Driver.new(server, InterfaceNS)
+drv.wiredump_dev = wireDumpDev
+drv.add_method_with_soapaction('BabelFish', InterfaceNS + "#BabelFish", 'translationmode', 'sourcedata')
+
+p drv.BabelFish(lang, text)
diff --git a/sample/soap/calc/calc.rb b/sample/soap/calc/calc.rb
new file mode 100644
index 0000000000..6bc78803b3
--- /dev/null
+++ b/sample/soap/calc/calc.rb
@@ -0,0 +1,17 @@
+module CalcService
+ def self.add(lhs, rhs)
+ lhs + rhs
+ end
+
+ def self.sub(lhs, rhs)
+ lhs - rhs
+ end
+
+ def self.multi(lhs, rhs)
+ lhs * rhs
+ end
+
+ def self.div(lhs, rhs)
+ lhs / rhs
+ end
+end
diff --git a/sample/soap/calc/calc2.rb b/sample/soap/calc/calc2.rb
new file mode 100644
index 0000000000..e9cf6bbca7
--- /dev/null
+++ b/sample/soap/calc/calc2.rb
@@ -0,0 +1,29 @@
+class CalcService2
+ def initialize(value = 0)
+ @value = value
+ end
+
+ def set(value)
+ @value = value
+ end
+
+ def get
+ @value
+ end
+
+ def +(rhs)
+ @value + rhs
+ end
+
+ def -(rhs)
+ @value - rhs
+ end
+
+ def *(rhs)
+ @value * rhs
+ end
+
+ def /(rhs)
+ @value / rhs
+ end
+end
diff --git a/sample/soap/calc/client.rb b/sample/soap/calc/client.rb
new file mode 100644
index 0000000000..57a4c0ba5b
--- /dev/null
+++ b/sample/soap/calc/client.rb
@@ -0,0 +1,26 @@
+require 'soap/rpc/driver'
+
+server = ARGV.shift || 'http://localhost:7000/'
+# server = 'http://localhost:8808/server.cgi'
+
+calc = SOAP::RPC::Driver.new(server, 'http://tempuri.org/calcService')
+#calc.wiredump_dev = STDERR
+calc.add_method('add', 'lhs', 'rhs')
+calc.add_method('sub', 'lhs', 'rhs')
+calc.add_method('multi', 'lhs', 'rhs')
+calc.add_method('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)
diff --git a/sample/soap/calc/client2.rb b/sample/soap/calc/client2.rb
new file mode 100644
index 0000000000..2c53f09d42
--- /dev/null
+++ b/sample/soap/calc/client2.rb
@@ -0,0 +1,29 @@
+require 'soap/rpc/driver'
+
+server = ARGV.shift || 'http://localhost:7000/'
+# server = 'http://localhost:8808/server2.cgi'
+
+var = SOAP::RPC::Driver.new( server, 'http://tempuri.org/calcService' )
+var.add_method( 'set', 'newValue' )
+var.add_method( 'get' )
+var.add_method_as( '+', 'add', 'rhs' )
+var.add_method_as( '-', 'sub', 'rhs' )
+var.add_method_as( '*', 'multi', 'rhs' )
+var.add_method_as( '/', 'div', 'rhs' )
+
+puts 'var.set( 1 )'
+puts '# Bare in mind that another client set another value to this service.'
+puts '# This is only a sample for proof of concept.'
+var.set( 1 )
+puts 'var + 2 # => 1 + 2 = 3'
+puts var + 2
+puts 'var - 2.2 # => 1 - 2.2 = -1.2'
+puts var - 2.2
+puts 'var * 2.2 # => 1 * 2.2 = 2.2'
+puts var * 2.2
+puts 'var / 2 # => 1 / 2 = 0'
+puts var / 2
+puts 'var / 2.0 # => 1 / 2.0 = 0.5'
+puts var / 2.0
+puts 'var / 0 # => 1 / 0 => ZeroDivisionError'
+puts var / 0
diff --git a/sample/soap/calc/httpd.rb b/sample/soap/calc/httpd.rb
new file mode 100644
index 0000000000..ee8ab09f50
--- /dev/null
+++ b/sample/soap/calc/httpd.rb
@@ -0,0 +1,15 @@
+#!/usr/bin/env ruby
+
+require 'webrick'
+require 'getopts'
+
+getopts "", 'r:', 'p:8808'
+
+s = WEBrick::HTTPServer.new(
+ :BindAddress => "0.0.0.0",
+ :Port => $OPT_p.to_i,
+ :DocumentRoot => $OPT_r || ".",
+ :CGIPathEnv => ENV['PATH']
+)
+trap(:INT){ s.shutdown }
+s.start
diff --git a/sample/soap/calc/server.cgi b/sample/soap/calc/server.cgi
new file mode 100644
index 0000000000..c4fa687550
--- /dev/null
+++ b/sample/soap/calc/server.cgi
@@ -0,0 +1,15 @@
+#!/usr/bin/env ruby
+
+require 'soap/rpc/cgistub'
+
+class CalcServer < SOAP::RPC::CGIStub
+ def initialize(*arg)
+ super
+
+ require 'calc'
+ servant = CalcService
+ add_servant(servant, 'http://tempuri.org/calcService')
+ end
+end
+
+status = CalcServer.new('CalcServer', nil).start
diff --git a/sample/soap/calc/server.rb b/sample/soap/calc/server.rb
new file mode 100644
index 0000000000..12a3968b5a
--- /dev/null
+++ b/sample/soap/calc/server.rb
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+
+require 'soap/rpc/standaloneServer'
+require 'calc'
+
+class CalcServer < SOAP::RPC::StandaloneServer
+ def initialize(*arg)
+ super
+
+ servant = CalcService
+ add_servant(servant, 'http://tempuri.org/calcService')
+ end
+end
+
+if $0 == __FILE__
+ status = CalcServer.new('CalcServer', nil, '0.0.0.0', 7000).start
+end
diff --git a/sample/soap/calc/server2.rb b/sample/soap/calc/server2.rb
new file mode 100644
index 0000000000..735721de64
--- /dev/null
+++ b/sample/soap/calc/server2.rb
@@ -0,0 +1,20 @@
+#!/usr/bin/env ruby
+
+require 'soap/rpc/standaloneServer'
+require 'calc2'
+
+class CalcServer2 < SOAP::RPC::StandaloneServer
+ def on_init
+ servant = CalcService2.new
+ add_method(servant, 'set', 'newValue')
+ add_method(servant, 'get')
+ add_method_as(servant, '+', 'add', 'lhs')
+ add_method_as(servant, '-', 'sub', 'lhs')
+ add_method_as(servant, '*', 'multi', 'lhs')
+ add_method_as(servant, '/', 'div', 'lhs')
+ end
+end
+
+if $0 == __FILE__
+ status = CalcServer2.new('CalcServer', 'http://tempuri.org/calcService', '0.0.0.0', 7000).start
+end
diff --git a/sample/soap/digraph.rb b/sample/soap/digraph.rb
new file mode 100644
index 0000000000..bf4a650cfe
--- /dev/null
+++ b/sample/soap/digraph.rb
@@ -0,0 +1,43 @@
+require 'soap/marshal'
+
+class Node; include SOAP::Marshallable
+ attr_reader :first, :second, :str
+
+ def initialize(*init_next)
+ @first = init_next[0]
+ @second = init_next[1]
+ end
+end
+
+n9 = Node.new
+n81 = Node.new(n9)
+n82 = Node.new(n9)
+n7 = Node.new(n81, n82)
+n61 = Node.new(n7)
+n62 = Node.new(n7)
+n5 = Node.new(n61, n62)
+n41 = Node.new(n5)
+n42 = Node.new(n5)
+n3 = Node.new(n41, n42)
+n21 = Node.new(n3)
+n22 = Node.new(n3)
+n1 = Node.new(n21, n22)
+
+File.open("digraph_marshalled_string.soap", "wb") do |f|
+ SOAP::Marshal.dump(n1, f)
+end
+
+marshalledString = File.open("digraph_marshalled_string.soap").read
+
+puts marshalledString
+
+newnode = SOAP::Marshal.unmarshal(marshalledString)
+
+puts newnode.inspect
+
+p newnode.first.first.__id__
+p newnode.second.first.__id__
+p newnode.first.first.first.first.__id__
+p newnode.second.first.second.first.__id__
+
+File.unlink("digraph_marshalled_string.soap")
diff --git a/sample/soap/exchange/client.rb b/sample/soap/exchange/client.rb
new file mode 100644
index 0000000000..2aa277afef
--- /dev/null
+++ b/sample/soap/exchange/client.rb
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+
+require "soap/rpc/driver"
+
+ExchangeServiceNamespace = 'http://tempuri.org/exchangeService'
+
+server = ARGV.shift || "http://localhost:7000/"
+# server = "http://localhost:8808/server.cgi"
+
+logger = nil
+wiredump_dev = nil
+# logger = Logger.new(STDERR)
+# wiredump_dev = STDERR
+
+drv = SOAP::RPC::Driver.new(server, ExchangeServiceNamespace)
+drv.wiredump_dev = wiredump_dev
+drv.add_method("rate", "country1", "country2")
+
+p drv.rate("USA", "Japan")
diff --git a/sample/soap/exchange/exchange.rb b/sample/soap/exchange/exchange.rb
new file mode 100644
index 0000000000..00f930deb8
--- /dev/null
+++ b/sample/soap/exchange/exchange.rb
@@ -0,0 +1,17 @@
+require 'soap/rpc/driver'
+
+ExchangeServiceNamespace = 'http://tempuri.org/exchangeService'
+
+class Exchange
+ ForeignServer = "http://services.xmethods.net/soap"
+ Namespace = "urn:xmethods-CurrencyExchange"
+
+ def initialize
+ @drv = SOAP::RPC::Driver.new(ForeignServer, Namespace)
+ @drv.add_method("getRate", "country1", "country2")
+ end
+
+ def rate(country1, country2)
+ return @drv.getRate(country1, country2)
+ end
+end
diff --git a/sample/soap/exchange/httpd.rb b/sample/soap/exchange/httpd.rb
new file mode 100644
index 0000000000..ee8ab09f50
--- /dev/null
+++ b/sample/soap/exchange/httpd.rb
@@ -0,0 +1,15 @@
+#!/usr/bin/env ruby
+
+require 'webrick'
+require 'getopts'
+
+getopts "", 'r:', 'p:8808'
+
+s = WEBrick::HTTPServer.new(
+ :BindAddress => "0.0.0.0",
+ :Port => $OPT_p.to_i,
+ :DocumentRoot => $OPT_r || ".",
+ :CGIPathEnv => ENV['PATH']
+)
+trap(:INT){ s.shutdown }
+s.start
diff --git a/sample/soap/exchange/server.cgi b/sample/soap/exchange/server.cgi
new file mode 100644
index 0000000000..16bc85a042
--- /dev/null
+++ b/sample/soap/exchange/server.cgi
@@ -0,0 +1,14 @@
+#!/usr/local/bin/ruby
+
+require 'soap/rpc/cgistub'
+require 'exchange'
+
+class ExchangeServer < SOAP::RPC::CGIStub
+ def initialize(*arg)
+ super
+ servant = Exchange.new
+ add_servant(servant)
+ end
+end
+
+status = ExchangeServer.new('SampleStructServer', ExchangeServiceNamespace).start
diff --git a/sample/soap/exchange/server.rb b/sample/soap/exchange/server.rb
new file mode 100644
index 0000000000..d510d54a76
--- /dev/null
+++ b/sample/soap/exchange/server.rb
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+
+require 'soap/rpc/standaloneServer'
+require 'exchange'
+
+class ExchangeServer < SOAP::RPC::StandaloneServer
+ def initialize(*arg)
+ super
+ servant = Exchange.new
+ add_servant(servant)
+ end
+end
+
+if $0 == __FILE__
+ status = ExchangeServer.new('SampleStructServer', ExchangeServiceNamespace, '0.0.0.0', 7000).start
+end
diff --git a/sample/soap/helloworld/hw_c.rb b/sample/soap/helloworld/hw_c.rb
new file mode 100644
index 0000000000..253d0a409b
--- /dev/null
+++ b/sample/soap/helloworld/hw_c.rb
@@ -0,0 +1,6 @@
+require 'soap/rpc/driver'
+
+s = SOAP::RPC::Driver.new('http://localhost:2000/', 'urn:hws')
+s.add_method("hello_world", "from")
+
+p s.hello_world(self.to_s)
diff --git a/sample/soap/helloworld/hw_s.rb b/sample/soap/helloworld/hw_s.rb
new file mode 100644
index 0000000000..b917f72fc0
--- /dev/null
+++ b/sample/soap/helloworld/hw_s.rb
@@ -0,0 +1,17 @@
+require 'soap/rpc/standaloneServer'
+
+class HelloWorldServer < SOAP::RPC::StandaloneServer
+ def on_init
+ @log.level = Logger::Severity::DEBUG
+ add_method(self, 'hello_world', 'from')
+ end
+
+ def hello_world(from)
+ "Hello World, from #{ from }"
+ end
+end
+
+if $0 == __FILE__
+ server = HelloWorldServer.new('hws', 'urn:hws', '0.0.0.0', 2000)
+ server.start
+end
diff --git a/sample/soap/icd/IICD.rb b/sample/soap/icd/IICD.rb
new file mode 100644
index 0000000000..3b1fa9b32c
--- /dev/null
+++ b/sample/soap/icd/IICD.rb
@@ -0,0 +1,17 @@
+module IICD
+ # All methods in a single namespace?!
+ InterfaceNS = 'http://www.iwebmethod.net'
+
+ Methods = [
+ ['SearchWord', 'query', 'partial'],
+ ['GetItemById', 'id'],
+ ['EnumWords'],
+ ['FullTextSearch', 'query'],
+ ]
+
+ def IICD.add_method(drv)
+ Methods.each do |method, *param|
+ drv.add_method_with_soapaction(method, InterfaceNS + "/#{ method }", *param )
+ end
+ end
+end
diff --git a/sample/soap/icd/icd.rb b/sample/soap/icd/icd.rb
new file mode 100644
index 0000000000..6e1e51c996
--- /dev/null
+++ b/sample/soap/icd/icd.rb
@@ -0,0 +1,46 @@
+#!/usr/bin/env ruby
+
+$KCODE = 'SJIS'
+
+require 'soap/rpc/driver'
+require 'IICD'; include IICD
+
+server = 'http://www.iwebmethod.net/icd1.0/icd.asmx'
+wiredump_dev = nil # STDERR
+
+icd = SOAP::RPC::Driver.new(server, IICD::InterfaceNS)
+icd.wiredump_dev = wiredump_dev
+icd.default_encodingstyle = SOAP::EncodingStyle::ASPDotNetHandler::Namespace
+IICD::add_method(icd)
+
+puts "キーワード: 'microsoft'で見出し検索"
+result = icd.SearchWord('microsoft', true)
+
+id = nil
+result.WORD.each do |word|
+ puts "Title: " << word.title
+ puts "Id: " << word.id
+ puts "English: " << word.english
+ puts "Japanese: " << word.japanese
+ puts "----"
+ id = word.id
+end
+
+item = icd.GetItemById(id)
+puts
+puts
+puts "Title: " << item.word.title
+puts "意味: " << item.meaning
+
+#p icd.EnumWords
+
+puts
+puts
+puts "キーワード: 'IBM'で全文検索"
+icd.FullTextSearch("IBM").WORD.each do |word|
+ puts "Title: " << word.title
+ puts "Id: " << word.id
+ puts "English: " << word.english
+ puts "Japanese: " << word.japanese
+ puts "----"
+end
diff --git a/sample/soap/raa/iRAA.rb b/sample/soap/raa/iRAA.rb
new file mode 100644
index 0000000000..2b188fb887
--- /dev/null
+++ b/sample/soap/raa/iRAA.rb
@@ -0,0 +1,154 @@
+require 'soap/mapping'
+
+
+module RAA; extend SOAP
+
+
+InterfaceNS = "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"
+MappingRegistry = SOAP::Mapping::Registry.new
+
+Methods = [
+ ['getAllListings', ['retval', 'return']],
+ ['getProductTree', ['retval', 'return']],
+ ['getInfoFromCategory', ['in', 'category'], [ 'retval', 'return']],
+ ['getModifiedInfoSince', ['in', 'time'], [ 'retval', 'return']],
+ ['getInfoFromName', ['in', 'name'], ['retval', 'return']],
+]
+
+
+class Category
+ include SOAP::Marshallable
+
+ @@schema_type = 'Category'
+ @@schema_ns = InterfaceNS
+
+ attr_reader :major, :minor
+
+ def initialize(major, minor = nil)
+ @major = major
+ @minor = minor
+ end
+
+ def to_s
+ "#{ @major }/#{ @minor }"
+ end
+
+ def ==(rhs)
+ if @major != rhs.major
+ false
+ elsif !@minor or !rhs.minor
+ true
+ else
+ @minor == rhs.minor
+ end
+ end
+end
+
+MappingRegistry.set(
+ ::RAA::Category,
+ ::SOAP::SOAPStruct,
+ ::SOAP::Mapping::Registry::TypedStructFactory,
+ { :type => XSD::QName.new(InterfaceNS, "Category") }
+)
+
+class Product
+ include SOAP::Marshallable
+
+ @@schema_type = 'Product'
+ @@schema_ns = InterfaceNS
+
+ attr_reader :id, :name
+ attr_accessor :short_description, :version, :status, :homepage, :download, :license, :description
+
+ def initialize(name, short_description = nil, version = nil, status = nil, homepage = nil, download = nil, license = nil, description = nil)
+ @name = name
+ @short_description = short_description
+ @version = version
+ @status = status
+ @homepage = homepage
+ @download = download
+ @license = license
+ @description = description
+ end
+end
+
+MappingRegistry.set(
+ ::RAA::Product,
+ ::SOAP::SOAPStruct,
+ ::SOAP::Mapping::Registry::TypedStructFactory,
+ { :type => XSD::QName.new(InterfaceNS, "Product") }
+)
+
+class Owner
+ include SOAP::Marshallable
+
+ @@schema_type = 'Owner'
+ @@schema_ns = InterfaceNS
+
+ attr_reader :id
+ attr_accessor :email, :name
+
+ def initialize(email, name)
+ @email = email
+ @name = name
+ @id = "#{ @email }-#{ @name }"
+ end
+end
+
+MappingRegistry.set(
+ ::RAA::Owner,
+ ::SOAP::SOAPStruct,
+ ::SOAP::Mapping::Registry::TypedStructFactory,
+ { :type => XSD::QName.new(InterfaceNS, "Owner") }
+)
+
+class Info
+ include SOAP::Marshallable
+
+ @@schema_type = 'Info'
+ @@schema_ns = InterfaceNS
+
+ attr_accessor :category, :product, :owner, :updated, :created
+
+ def initialize(category = nil, product = nil, owner = nil, updated = nil, created = nil)
+ @category = category
+ @product = product
+ @owner = owner
+ @updated = updated
+ @created = created
+ end
+
+ def <=>(rhs)
+ @updated <=> rhs.updated
+ end
+
+ def eql?(rhs)
+ @product.name == rhs.product.name
+ end
+end
+
+MappingRegistry.set(
+ ::RAA::Info,
+ ::SOAP::SOAPStruct,
+ ::SOAP::Mapping::Registry::TypedStructFactory,
+ { :type => XSD::QName.new(InterfaceNS, "Info") }
+)
+
+class StringArray < Array; end
+MappingRegistry.set(
+ ::RAA::StringArray,
+ ::SOAP::SOAPArray,
+ ::SOAP::Mapping::Registry::TypedArrayFactory,
+ { :type => XSD::XSDString::Type }
+)
+
+class InfoArray < Array; end
+MappingRegistry.set(
+ ::RAA::InfoArray,
+ ::SOAP::SOAPArray,
+ ::SOAP::Mapping::Registry::TypedArrayFactory,
+ { :type => XSD::QName.new(InterfaceNS, 'Info') }
+)
+
+
+end
diff --git a/sample/soap/raa/soap4r.rb b/sample/soap/raa/soap4r.rb
new file mode 100644
index 0000000000..b93d1e7dbe
--- /dev/null
+++ b/sample/soap/raa/soap4r.rb
@@ -0,0 +1,30 @@
+#!/usr/bin/env ruby
+
+require 'iRAA'
+require 'soap/rpc/driver'
+
+
+server = ARGV.shift || 'http://raa.ruby-lang.org/soap/1.0.2/'
+
+raa = SOAP::RPC::Driver.new(server, RAA::InterfaceNS)
+raa.mapping_registry = RAA::MappingRegistry
+RAA::Methods.each do |name, *params|
+ raa.add_method(name, params)
+end
+# raa.wiredump_dev = STDOUT
+
+p raa.getAllListings().sort
+
+p raa.getProductTree()
+
+p raa.getInfoFromCategory(RAA::Category.new("Library", "XML"))
+
+t = Time.at(Time.now.to_i - 24 * 3600)
+p raa.getModifiedInfoSince(t)
+
+p raa.getModifiedInfoSince(DateTime.new(t.year, t.mon, t.mday, t.hour, t.min, t.sec))
+
+o = raa.getInfoFromName("SOAP4R")
+p o.class
+p o.owner.name
+p o
diff --git a/sample/soap/sampleStruct/client.rb b/sample/soap/sampleStruct/client.rb
new file mode 100644
index 0000000000..b55c7fdfc5
--- /dev/null
+++ b/sample/soap/sampleStruct/client.rb
@@ -0,0 +1,16 @@
+require 'soap/rpc/driver'
+
+require 'iSampleStruct'
+
+server = ARGV.shift || 'http://localhost:7000/'
+# server = 'http://localhost:8808/server.cgi'
+
+drv = SOAP::RPC::Driver.new(server, SampleStructServiceNamespace)
+drv.wiredump_dev = STDERR
+drv.add_method('hi', 'sampleStruct')
+
+o1 = SampleStruct.new
+puts "Sending struct: #{ o1.inspect }"
+puts
+o2 = drv.hi(o1)
+puts "Received (wrapped): #{ o2.inspect }"
diff --git a/sample/soap/sampleStruct/httpd.rb b/sample/soap/sampleStruct/httpd.rb
new file mode 100644
index 0000000000..ee8ab09f50
--- /dev/null
+++ b/sample/soap/sampleStruct/httpd.rb
@@ -0,0 +1,15 @@
+#!/usr/bin/env ruby
+
+require 'webrick'
+require 'getopts'
+
+getopts "", 'r:', 'p:8808'
+
+s = WEBrick::HTTPServer.new(
+ :BindAddress => "0.0.0.0",
+ :Port => $OPT_p.to_i,
+ :DocumentRoot => $OPT_r || ".",
+ :CGIPathEnv => ENV['PATH']
+)
+trap(:INT){ s.shutdown }
+s.start
diff --git a/sample/soap/sampleStruct/iSampleStruct.rb b/sample/soap/sampleStruct/iSampleStruct.rb
new file mode 100644
index 0000000000..399ea52eb8
--- /dev/null
+++ b/sample/soap/sampleStruct/iSampleStruct.rb
@@ -0,0 +1,22 @@
+require 'soap/mapping'
+
+SampleStructServiceNamespace = 'http://tempuri.org/sampleStructService'
+
+class SampleStruct; include SOAP::Marshallable
+ attr_accessor :sampleArray
+ attr_accessor :date
+
+ def initialize
+ @sampleArray = SampleArray[ "cyclic", self ]
+ @date = DateTime.now
+ end
+
+ def wrap( rhs )
+ @sampleArray = SampleArray[ "wrap", rhs.dup ]
+ @date = DateTime.now
+ self
+ end
+end
+
+class SampleArray < Array; include SOAP::Marshallable
+end
diff --git a/sample/soap/sampleStruct/sampleStruct.rb b/sample/soap/sampleStruct/sampleStruct.rb
new file mode 100644
index 0000000000..394c1bff09
--- /dev/null
+++ b/sample/soap/sampleStruct/sampleStruct.rb
@@ -0,0 +1,13 @@
+require 'iSampleStruct'
+
+class SampleStructService
+ def hi(struct)
+ ack = SampleStruct.new
+ ack.wrap(struct)
+ ack
+ end
+end
+
+if __FILE__ == $0
+ p SampleStructService.new.hi(SampleStruct.new)
+end
diff --git a/sample/soap/sampleStruct/server.cgi b/sample/soap/sampleStruct/server.cgi
new file mode 100644
index 0000000000..42751386a0
--- /dev/null
+++ b/sample/soap/sampleStruct/server.cgi
@@ -0,0 +1,14 @@
+#!/usr/local/bin/ruby
+
+require 'soap/rpc/cgistub'
+require 'sampleStruct'
+
+class SampleStructServer < SOAP::RPC::CGIStub
+ def initialize(*arg)
+ super
+ servant = SampleStructService.new
+ add_servant(servant)
+ end
+end
+
+status = SampleStructServer.new('SampleStructServer', SampleStructServiceNamespace).start
diff --git a/sample/soap/sampleStruct/server.rb b/sample/soap/sampleStruct/server.rb
new file mode 100644
index 0000000000..3caa31a052
--- /dev/null
+++ b/sample/soap/sampleStruct/server.rb
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+
+require 'soap/rpc/standaloneServer'
+require 'sampleStruct'
+
+class SampleStructServer < SOAP::RPC::StandaloneServer
+ def initialize(*arg)
+ super
+ servant = SampleStructService.new
+ add_servant(servant)
+ end
+end
+
+if $0 == __FILE__
+ status = SampleStructServer.new('SampleStructServer', SampleStructServiceNamespace, '0.0.0.0', 7000).start
+end