mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
9ee320461d
commit
d7f6ed827f
12 changed files with 171 additions and 2 deletions
|
@ -1,3 +1,7 @@
|
|||
Mon Dec 20 22:52:29 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
|
||||
|
||||
* added samples for the previous soap4r's commit.
|
||||
|
||||
Mon Dec 20 22:56:39 2004 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* gc.c (set_stack_end): gcc noinline attribute is available since
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
8
sample/soap/helloworld/hw_c_gzip.rb
Normal file
8
sample/soap/helloworld/hw_c_gzip.rb
Normal file
|
@ -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)
|
|
@ -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
|
||||
|
|
21
sample/soap/helloworld/hw_s_gzip.rb
Normal file
21
sample/soap/helloworld/hw_s_gzip.rb
Normal file
|
@ -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
|
34
sample/soap/scopesample/client.rb
Normal file
34
sample/soap/scopesample/client.rb
Normal file
|
@ -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
|
22
sample/soap/scopesample/httpd.rb
Normal file
22
sample/soap/scopesample/httpd.rb
Normal file
|
@ -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
|
2
sample/soap/scopesample/samplehttpd.conf
Normal file
2
sample/soap/scopesample/samplehttpd.conf
Normal file
|
@ -0,0 +1,2 @@
|
|||
docroot = .
|
||||
port = 8808
|
18
sample/soap/scopesample/servant.rb
Normal file
18
sample/soap/scopesample/servant.rb
Normal file
|
@ -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
|
29
sample/soap/scopesample/server.cgi
Executable file
29
sample/soap/scopesample/server.cgi
Executable file
|
@ -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
|
20
sample/soap/scopesample/server.rb
Normal file
20
sample/soap/scopesample/server.rb
Normal file
|
@ -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
|
Loading…
Reference in a new issue