mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/soap/* (29 files): SOAP4R added.
* lib/wsdl/* (42 files): WSDL4R added. * lib/xsd/* (12 files): XSD4R added. * test/soap/* (16 files): added. * test/wsdl/* (2 files): added. * test/xsd/* (3 files): added. * sample/soap/* (27 files): added. * sample/wsdl/* (13 files): added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8c2fb77787
commit
db9445103c
145 changed files with 20938 additions and 0 deletions
16
sample/soap/babelfish.rb
Normal file
16
sample/soap/babelfish.rb
Normal file
|
|
@ -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)
|
||||
17
sample/soap/calc/calc.rb
Normal file
17
sample/soap/calc/calc.rb
Normal file
|
|
@ -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
|
||||
29
sample/soap/calc/calc2.rb
Normal file
29
sample/soap/calc/calc2.rb
Normal file
|
|
@ -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
|
||||
26
sample/soap/calc/client.rb
Normal file
26
sample/soap/calc/client.rb
Normal file
|
|
@ -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)
|
||||
29
sample/soap/calc/client2.rb
Normal file
29
sample/soap/calc/client2.rb
Normal file
|
|
@ -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
|
||||
15
sample/soap/calc/httpd.rb
Normal file
15
sample/soap/calc/httpd.rb
Normal file
|
|
@ -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
|
||||
15
sample/soap/calc/server.cgi
Normal file
15
sample/soap/calc/server.cgi
Normal file
|
|
@ -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
|
||||
17
sample/soap/calc/server.rb
Normal file
17
sample/soap/calc/server.rb
Normal file
|
|
@ -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
|
||||
20
sample/soap/calc/server2.rb
Normal file
20
sample/soap/calc/server2.rb
Normal file
|
|
@ -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
|
||||
43
sample/soap/digraph.rb
Normal file
43
sample/soap/digraph.rb
Normal file
|
|
@ -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")
|
||||
19
sample/soap/exchange/client.rb
Normal file
19
sample/soap/exchange/client.rb
Normal file
|
|
@ -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")
|
||||
17
sample/soap/exchange/exchange.rb
Normal file
17
sample/soap/exchange/exchange.rb
Normal file
|
|
@ -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
|
||||
15
sample/soap/exchange/httpd.rb
Normal file
15
sample/soap/exchange/httpd.rb
Normal file
|
|
@ -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
|
||||
14
sample/soap/exchange/server.cgi
Normal file
14
sample/soap/exchange/server.cgi
Normal file
|
|
@ -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
|
||||
16
sample/soap/exchange/server.rb
Normal file
16
sample/soap/exchange/server.rb
Normal file
|
|
@ -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
|
||||
6
sample/soap/helloworld/hw_c.rb
Normal file
6
sample/soap/helloworld/hw_c.rb
Normal file
|
|
@ -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)
|
||||
17
sample/soap/helloworld/hw_s.rb
Normal file
17
sample/soap/helloworld/hw_s.rb
Normal file
|
|
@ -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
|
||||
17
sample/soap/icd/IICD.rb
Normal file
17
sample/soap/icd/IICD.rb
Normal file
|
|
@ -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
|
||||
46
sample/soap/icd/icd.rb
Normal file
46
sample/soap/icd/icd.rb
Normal file
|
|
@ -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
|
||||
154
sample/soap/raa/iRAA.rb
Normal file
154
sample/soap/raa/iRAA.rb
Normal file
|
|
@ -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
|
||||
30
sample/soap/raa/soap4r.rb
Normal file
30
sample/soap/raa/soap4r.rb
Normal file
|
|
@ -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
|
||||
16
sample/soap/sampleStruct/client.rb
Normal file
16
sample/soap/sampleStruct/client.rb
Normal file
|
|
@ -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 }"
|
||||
15
sample/soap/sampleStruct/httpd.rb
Normal file
15
sample/soap/sampleStruct/httpd.rb
Normal file
|
|
@ -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
|
||||
22
sample/soap/sampleStruct/iSampleStruct.rb
Normal file
22
sample/soap/sampleStruct/iSampleStruct.rb
Normal file
|
|
@ -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
|
||||
13
sample/soap/sampleStruct/sampleStruct.rb
Normal file
13
sample/soap/sampleStruct/sampleStruct.rb
Normal file
|
|
@ -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
|
||||
14
sample/soap/sampleStruct/server.cgi
Normal file
14
sample/soap/sampleStruct/server.cgi
Normal file
|
|
@ -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
|
||||
16
sample/soap/sampleStruct/server.rb
Normal file
16
sample/soap/sampleStruct/server.rb
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue