summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
authornahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-20 14:00:21 +0000
committernahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-20 14:00:21 +0000
commitd7f6ed827fdfcabcd1e5a0d4419f5ea06f90ebaf (patch)
tree5604e10b00870c4facd7b7627a8899273dca092a /sample
parent9ee320461dd0f4c6897ae2c34443d343e0df9335 (diff)
* added samples for the previous soap4r's commit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample')
-rw-r--r--sample/soap/calc/server.rb6
-rw-r--r--sample/soap/calc/server2.rb6
-rw-r--r--sample/soap/helloworld/hw_c_gzip.rb8
-rw-r--r--sample/soap/helloworld/hw_s.rb3
-rw-r--r--sample/soap/helloworld/hw_s_gzip.rb21
-rw-r--r--sample/soap/scopesample/client.rb34
-rw-r--r--sample/soap/scopesample/httpd.rb22
-rw-r--r--sample/soap/scopesample/samplehttpd.conf2
-rw-r--r--sample/soap/scopesample/servant.rb18
-rwxr-xr-xsample/soap/scopesample/server.cgi29
-rw-r--r--sample/soap/scopesample/server.rb20
11 files changed, 167 insertions, 2 deletions
diff --git a/sample/soap/calc/server.rb b/sample/soap/calc/server.rb
index 12a3968b5a..97661be9d3 100644
--- a/sample/soap/calc/server.rb
+++ b/sample/soap/calc/server.rb
@@ -13,5 +13,9 @@ class CalcServer < SOAP::RPC::StandaloneServer
end
if $0 == __FILE__
- status = CalcServer.new('CalcServer', nil, '0.0.0.0', 7000).start
+ server = CalcServer.new('CalcServer', nil, '0.0.0.0', 7000)
+ trap(:INT) do
+ server.shutdown
+ end
+ server.start
end
diff --git a/sample/soap/calc/server2.rb b/sample/soap/calc/server2.rb
index 735721de64..bb0f643d77 100644
--- a/sample/soap/calc/server2.rb
+++ b/sample/soap/calc/server2.rb
@@ -16,5 +16,9 @@ class CalcServer2 < SOAP::RPC::StandaloneServer
end
if $0 == __FILE__
- status = CalcServer2.new('CalcServer', 'http://tempuri.org/calcService', '0.0.0.0', 7000).start
+ server = CalcServer2.new('CalcServer', 'http://tempuri.org/calcService', '0.0.0.0', 7000)
+ trap(:INT) do
+ server.shutdown
+ end
+ status = server.start
end
diff --git a/sample/soap/helloworld/hw_c_gzip.rb b/sample/soap/helloworld/hw_c_gzip.rb
new file mode 100644
index 0000000000..3335b5f571
--- /dev/null
+++ b/sample/soap/helloworld/hw_c_gzip.rb
@@ -0,0 +1,8 @@
+require 'soap/rpc/driver'
+
+s = SOAP::RPC::Driver.new('http://localhost:2000/', 'urn:hws')
+s.add_method("hello_world", "from")
+#s.wiredump_dev = STDOUT # care about binary output.
+s.streamhandler.accept_encoding_gzip = true
+
+p s.hello_world(self.to_s)
diff --git a/sample/soap/helloworld/hw_s.rb b/sample/soap/helloworld/hw_s.rb
index b917f72fc0..f9f819a19f 100644
--- a/sample/soap/helloworld/hw_s.rb
+++ b/sample/soap/helloworld/hw_s.rb
@@ -13,5 +13,8 @@ end
if $0 == __FILE__
server = HelloWorldServer.new('hws', 'urn:hws', '0.0.0.0', 2000)
+ trap(:INT) do
+ server.shutdown
+ end
server.start
end
diff --git a/sample/soap/helloworld/hw_s_gzip.rb b/sample/soap/helloworld/hw_s_gzip.rb
new file mode 100644
index 0000000000..d124df0e04
--- /dev/null
+++ b/sample/soap/helloworld/hw_s_gzip.rb
@@ -0,0 +1,21 @@
+require 'soap/rpc/standaloneServer'
+
+class HelloWorldServer < SOAP::RPC::StandaloneServer
+ def on_init
+ @soaplet.allow_content_encoding_gzip = true
+ @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)
+ trap(:INT) do
+ server.shutdown
+ end
+ server.start
+end
diff --git a/sample/soap/scopesample/client.rb b/sample/soap/scopesample/client.rb
new file mode 100644
index 0000000000..009fdf1919
--- /dev/null
+++ b/sample/soap/scopesample/client.rb
@@ -0,0 +1,34 @@
+require 'soap/rpc/driver'
+
+server = ARGV.shift || 'http://localhost:7000/'
+# server = 'http://localhost:8808/server.cgi'
+
+# client which accesses application scope servant.
+app = SOAP::RPC::Driver.new(server,
+ 'http://tempuri.org/applicationScopeService')
+app.add_method('push', 'value')
+app.add_method('pop')
+
+# client which accesses request scope servant must send SOAPAction to identify
+# the service.
+req = SOAP::RPC::Driver.new(server,
+ 'http://tempuri.org/requestScopeService')
+req.add_method_with_soapaction('push',
+ 'http://tempuri.org/requestScopeService', 'value')
+req.add_method_with_soapaction('pop',
+ 'http://tempuri.org/requestScopeService')
+
+# exec
+app.push(1)
+app.push(2)
+app.push(3)
+p app.pop
+p app.pop
+p app.pop
+
+req.push(1)
+req.push(2)
+req.push(3)
+p req.pop
+p req.pop
+p req.pop
diff --git a/sample/soap/scopesample/httpd.rb b/sample/soap/scopesample/httpd.rb
new file mode 100644
index 0000000000..5f58c7e14a
--- /dev/null
+++ b/sample/soap/scopesample/httpd.rb
@@ -0,0 +1,22 @@
+#!/usr/bin/env ruby
+
+require 'webrick'
+require 'soap/property'
+
+docroot = "."
+port = 8808
+if opt = SOAP::Property.loadproperty("samplehttpd.conf")
+ docroot = opt["docroot"]
+ port = Integer(opt["port"])
+end
+
+s = WEBrick::HTTPServer.new(
+ :BindAddress => "0.0.0.0",
+ :Port => port,
+ :DocumentRoot => docroot,
+ :CGIPathEnv => ENV['PATH']
+)
+trap(:INT) do
+ s.shutdown
+end
+s.start
diff --git a/sample/soap/scopesample/samplehttpd.conf b/sample/soap/scopesample/samplehttpd.conf
new file mode 100644
index 0000000000..85e9995021
--- /dev/null
+++ b/sample/soap/scopesample/samplehttpd.conf
@@ -0,0 +1,2 @@
+docroot = .
+port = 8808
diff --git a/sample/soap/scopesample/servant.rb b/sample/soap/scopesample/servant.rb
new file mode 100644
index 0000000000..5076050076
--- /dev/null
+++ b/sample/soap/scopesample/servant.rb
@@ -0,0 +1,18 @@
+class Servant
+ def self.create
+ new
+ end
+
+ def initialize
+ STDERR.puts "Servant created."
+ @task = []
+ end
+
+ def push(value)
+ @task.push(value)
+ end
+
+ def pop
+ @task.pop
+ end
+end
diff --git a/sample/soap/scopesample/server.cgi b/sample/soap/scopesample/server.cgi
new file mode 100755
index 0000000000..ebe13eb131
--- /dev/null
+++ b/sample/soap/scopesample/server.cgi
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+
+require 'soap/rpc/cgistub'
+require 'servant'
+
+class Server < SOAP::RPC::CGIStub
+ class DummyServant
+ def push(value)
+ "Not supported"
+ end
+
+ def pop
+ "Not supported"
+ end
+ end
+
+ def initialize(*arg)
+ super
+ add_rpc_servant(Servant.new, 'http://tempuri.org/requestScopeService')
+
+ # Application scope servant is not supported in CGI environment.
+ # See server.rb to support application scope servant.
+ dummy = DummyServant.new
+ add_method_with_namespace('http://tempuri.org/applicationScopeService', dummy, 'push', 'value')
+ add_method_with_namespace('http://tempuri.org/applicationScopeService', dummy, 'pop')
+ end
+end
+
+status = Server.new('Server', nil).start
diff --git a/sample/soap/scopesample/server.rb b/sample/soap/scopesample/server.rb
new file mode 100644
index 0000000000..6b87b74c2f
--- /dev/null
+++ b/sample/soap/scopesample/server.rb
@@ -0,0 +1,20 @@
+#!/usr/bin/env ruby
+
+require 'soap/rpc/standaloneServer'
+require 'servant'
+
+class Server < SOAP::RPC::StandaloneServer
+ def initialize(*arg)
+ super
+ add_rpc_servant(Servant.new, 'http://tempuri.org/applicationScopeService')
+ add_rpc_request_servant(Servant, 'http://tempuri.org/requestScopeService')
+ end
+end
+
+if $0 == __FILE__
+ server = Server.new('Server', nil, '0.0.0.0', 7000)
+ trap(:INT) do
+ server.shutdown
+ end
+ server.start
+end