* added files:
* lib/soap/header/* * lib/soap/rpc/httpserver.rb * lib/wsdl/soap/cgiStubCreator.rb * lib/wsdl/soap/classDefCreator.rb * lib/wsdl/soap/classDefCreatorSupport.rb * lib/wsdl/soap/clientSkeltonCreator.rb * lib/wsdl/soap/driverCreator.rb * lib/wsdl/soap/mappingRegistryCreator.rb * lib/wsdl/soap/methodDefCreator.rb * lib/wsdl/soap/servantSkeltonCreator.rb * lib/wsdl/soap/standaloneServerStubCreator.rb * lib/wsdl/xmlSchema/enumeration.rb * lib/wsdl/xmlSchema/simpleRestriction.rb * lib/wsdl/xmlSchema/simpleType.rb * lib/xsd/codegen/* * lib/xsd/codegen.rb * sample/soap/authheader/* * sample/soap/raa2.4/* * sample/soap/ssl/* * sample/soap/swa/* * sample/soap/whois.rb * sample/wsdl/raa2.4/* * test/soap/header/* * test/soap/ssl/* * test/soap/struct/* * test/soap/swa/* * test/soap/wsdlDriver/* * test/wsdl/multiplefault.wsdl * test/wsdl/simpletype/* * test/wsdl/test_multiplefault.rb * modified files: * lib/soap/baseData.rb * lib/soap/element.rb * lib/soap/generator.rb * lib/soap/netHttpClient.rb * lib/soap/parser.rb * lib/soap/property.rb * lib/soap/soap.rb * lib/soap/streamHandler.rb * lib/soap/wsdlDriver.rb * lib/soap/wsdlDriver.rb * lib/soap/encodingstyle/handler.rb * lib/soap/encodingstyle/literalHandler.rb * lib/soap/encodingstyle/soapHandler.rb * lib/soap/mapping/factory.rb * lib/soap/mapping/mapping.rb * lib/soap/mapping/registry.rb * lib/soap/mapping/rubytypeFactory.rb * lib/soap/mapping/wsdlRegistry.rb * lib/soap/rpc/cgistub.rb * lib/soap/rpc/driver.rb * lib/soap/rpc/proxy.rb * lib/soap/rpc/router.rb * lib/soap/rpc/soaplet.rb * lib/soap/rpc/standaloneServer.rb * lib/wsdl/data.rb * lib/wsdl/definitions.rb * lib/wsdl/operation.rb * lib/wsdl/parser.rb * lib/wsdl/soap/definitions.rb * lib/wsdl/xmlSchema/complexContent.rb * lib/wsdl/xmlSchema/complexType.rb * lib/wsdl/xmlSchema/data.rb * lib/wsdl/xmlSchema/parser.rb * lib/wsdl/xmlSchema/schema.rb * lib/xsd/datatypes.rb * lib/xsd/qname.rb * sample/soap/sampleStruct/server.rb * sample/wsdl/amazon/AmazonSearch.rb * sample/wsdl/amazon/AmazonSearchDriver.rb * test/soap/test_property.rb * test/soap/calc/test_calc_cgi.rb * test/wsdl/test_emptycomplextype.rb * summary * add SOAP Header mustUnderstand support. * add HTTP client SSL configuration and Cookies support (works completely with http-access2). * add header handler for handling sending/receiving SOAP Header. * map Ruby's anonymous Struct to common SOAP Struct in SOAP Object Model. it caused error. * add WSDL simpleType support to restrict lexical value space. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0d6fa996d9
commit
df731e37a1
90
ChangeLog
90
ChangeLog
@ -1,3 +1,93 @@
|
|||||||
|
Sat Jul 3 22:25:27 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
|
||||||
|
|
||||||
|
* added files:
|
||||||
|
* lib/soap/header/*
|
||||||
|
* lib/soap/rpc/httpserver.rb
|
||||||
|
* lib/wsdl/soap/cgiStubCreator.rb
|
||||||
|
* lib/wsdl/soap/classDefCreator.rb
|
||||||
|
* lib/wsdl/soap/classDefCreatorSupport.rb
|
||||||
|
* lib/wsdl/soap/clientSkeltonCreator.rb
|
||||||
|
* lib/wsdl/soap/driverCreator.rb
|
||||||
|
* lib/wsdl/soap/mappingRegistryCreator.rb
|
||||||
|
* lib/wsdl/soap/methodDefCreator.rb
|
||||||
|
* lib/wsdl/soap/servantSkeltonCreator.rb
|
||||||
|
* lib/wsdl/soap/standaloneServerStubCreator.rb
|
||||||
|
* lib/wsdl/xmlSchema/enumeration.rb
|
||||||
|
* lib/wsdl/xmlSchema/simpleRestriction.rb
|
||||||
|
* lib/wsdl/xmlSchema/simpleType.rb
|
||||||
|
* lib/xsd/codegen/*
|
||||||
|
* lib/xsd/codegen.rb
|
||||||
|
* sample/soap/authheader/*
|
||||||
|
* sample/soap/raa2.4/*
|
||||||
|
* sample/soap/ssl/*
|
||||||
|
* sample/soap/swa/*
|
||||||
|
* sample/soap/whois.rb
|
||||||
|
* sample/wsdl/raa2.4/*
|
||||||
|
* test/soap/header/*
|
||||||
|
* test/soap/ssl/*
|
||||||
|
* test/soap/struct/*
|
||||||
|
* test/soap/swa/*
|
||||||
|
* test/soap/wsdlDriver/*
|
||||||
|
* test/wsdl/multiplefault.wsdl
|
||||||
|
* test/wsdl/simpletype/*
|
||||||
|
* test/wsdl/test_multiplefault.rb
|
||||||
|
|
||||||
|
* modified files:
|
||||||
|
* lib/soap/baseData.rb
|
||||||
|
* lib/soap/element.rb
|
||||||
|
* lib/soap/generator.rb
|
||||||
|
* lib/soap/netHttpClient.rb
|
||||||
|
* lib/soap/parser.rb
|
||||||
|
* lib/soap/property.rb
|
||||||
|
* lib/soap/soap.rb
|
||||||
|
* lib/soap/streamHandler.rb
|
||||||
|
* lib/soap/wsdlDriver.rb
|
||||||
|
* lib/soap/encodingstyle/handler.rb
|
||||||
|
* lib/soap/encodingstyle/literalHandler.rb
|
||||||
|
* lib/soap/encodingstyle/soapHandler.rb
|
||||||
|
* lib/soap/mapping/factory.rb
|
||||||
|
* lib/soap/mapping/mapping.rb
|
||||||
|
* lib/soap/mapping/registry.rb
|
||||||
|
* lib/soap/mapping/rubytypeFactory.rb
|
||||||
|
* lib/soap/mapping/wsdlRegistry.rb
|
||||||
|
* lib/soap/rpc/cgistub.rb
|
||||||
|
* lib/soap/rpc/driver.rb
|
||||||
|
* lib/soap/rpc/proxy.rb
|
||||||
|
* lib/soap/rpc/router.rb
|
||||||
|
* lib/soap/rpc/soaplet.rb
|
||||||
|
* lib/soap/rpc/standaloneServer.rb
|
||||||
|
* lib/wsdl/data.rb
|
||||||
|
* lib/wsdl/definitions.rb
|
||||||
|
* lib/wsdl/operation.rb
|
||||||
|
* lib/wsdl/parser.rb
|
||||||
|
* lib/wsdl/soap/definitions.rb
|
||||||
|
* lib/wsdl/xmlSchema/complexContent.rb
|
||||||
|
* lib/wsdl/xmlSchema/complexType.rb
|
||||||
|
* lib/wsdl/xmlSchema/data.rb
|
||||||
|
* lib/wsdl/xmlSchema/parser.rb
|
||||||
|
* lib/wsdl/xmlSchema/schema.rb
|
||||||
|
* lib/xsd/datatypes.rb
|
||||||
|
* lib/xsd/qname.rb
|
||||||
|
* sample/soap/sampleStruct/server.rb
|
||||||
|
* sample/wsdl/amazon/AmazonSearch.rb
|
||||||
|
* sample/wsdl/amazon/AmazonSearchDriver.rb
|
||||||
|
* test/soap/test_property.rb
|
||||||
|
* test/soap/calc/test_calc_cgi.rb
|
||||||
|
* test/wsdl/test_emptycomplextype.rb
|
||||||
|
|
||||||
|
* summary
|
||||||
|
* add SOAP Header mustUnderstand support.
|
||||||
|
|
||||||
|
* add HTTP client SSL configuration and Cookies support (works
|
||||||
|
completely with http-access2).
|
||||||
|
|
||||||
|
* add header handler for handling sending/receiving SOAP Header.
|
||||||
|
|
||||||
|
* map Ruby's anonymous Struct to common SOAP Struct in SOAP Object
|
||||||
|
Model. it caused error.
|
||||||
|
|
||||||
|
* add WSDL simpleType support to restrict lexical value space.
|
||||||
|
|
||||||
Sat Jul 3 17:19:44 2004 WATANABE Hirofumi <eban@ruby-lang.org>
|
Sat Jul 3 17:19:44 2004 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||||
|
|
||||||
* ext/tk/lib/tkextlib/tkDND.rb: fix syntax error.
|
* ext/tk/lib/tkextlib/tkDND.rb: fix syntax error.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# soap/baseData.rb: SOAP4R - Base type library
|
# soap/baseData.rb: SOAP4R - Base type library
|
||||||
# Copyright (C) 2000, 2001, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
# Copyright (C) 2000, 2001, 2003, 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
# redistribute it and/or modify it under the same terms of Ruby's license;
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
@ -30,20 +30,10 @@ end
|
|||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
## Marker of SOAP/DM types.
|
## for SOAP type(base and compound)
|
||||||
#
|
#
|
||||||
module SOAPType; end
|
module SOAPType
|
||||||
|
|
||||||
|
|
||||||
###
|
|
||||||
## Mix-in module for SOAP base type instances.
|
|
||||||
#
|
|
||||||
module SOAPBasetype
|
|
||||||
include SOAPType
|
|
||||||
include SOAP
|
|
||||||
|
|
||||||
attr_accessor :encodingstyle
|
attr_accessor :encodingstyle
|
||||||
|
|
||||||
attr_accessor :elename
|
attr_accessor :elename
|
||||||
attr_accessor :id
|
attr_accessor :id
|
||||||
attr_reader :precedents
|
attr_reader :precedents
|
||||||
@ -51,17 +41,18 @@ module SOAPBasetype
|
|||||||
attr_accessor :parent
|
attr_accessor :parent
|
||||||
attr_accessor :position
|
attr_accessor :position
|
||||||
attr_reader :extraattr
|
attr_reader :extraattr
|
||||||
|
attr_accessor :definedtype
|
||||||
|
|
||||||
public
|
def initialize(*arg)
|
||||||
|
super(*arg)
|
||||||
def initialize(*vars)
|
|
||||||
super(*vars)
|
|
||||||
@encodingstyle = nil
|
@encodingstyle = nil
|
||||||
@elename = XSD::QName.new
|
@elename = XSD::QName.new
|
||||||
@id = nil
|
@id = nil
|
||||||
@precedents = []
|
@precedents = []
|
||||||
|
@root = false
|
||||||
@parent = nil
|
@parent = nil
|
||||||
@position = nil
|
@position = nil
|
||||||
|
@definedtype = nil
|
||||||
@extraattr = {}
|
@extraattr = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -76,38 +67,27 @@ end
|
|||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
## Mix-in module for SOAP compound type instances.
|
## for SOAP base type
|
||||||
|
#
|
||||||
|
module SOAPBasetype
|
||||||
|
include SOAPType
|
||||||
|
include SOAP
|
||||||
|
|
||||||
|
def initialize(*arg)
|
||||||
|
super(*arg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
## for SOAP compound type
|
||||||
#
|
#
|
||||||
module SOAPCompoundtype
|
module SOAPCompoundtype
|
||||||
include SOAPType
|
include SOAPType
|
||||||
include SOAP
|
include SOAP
|
||||||
|
|
||||||
attr_accessor :encodingstyle
|
def initialize(*arg)
|
||||||
|
super(*arg)
|
||||||
attr_accessor :elename
|
|
||||||
attr_accessor :id
|
|
||||||
attr_reader :precedents
|
|
||||||
attr_accessor :root
|
|
||||||
attr_accessor :parent
|
|
||||||
attr_accessor :position
|
|
||||||
attr_reader :extraattr
|
|
||||||
|
|
||||||
attr_accessor :definedtype
|
|
||||||
|
|
||||||
public
|
|
||||||
|
|
||||||
def initialize(type)
|
|
||||||
super()
|
|
||||||
@type = type
|
|
||||||
@encodingstyle = nil
|
|
||||||
@elename = XSD::QName.new
|
|
||||||
@id = nil
|
|
||||||
@precedents = []
|
|
||||||
@root = false
|
|
||||||
@parent = nil
|
|
||||||
@position = nil
|
|
||||||
@definedtype = nil
|
|
||||||
@extraattr = {}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -122,18 +102,11 @@ class SOAPReference < XSD::NSDBase
|
|||||||
public
|
public
|
||||||
|
|
||||||
attr_accessor :refid
|
attr_accessor :refid
|
||||||
attr_accessor :elename
|
|
||||||
|
|
||||||
# Override the definition in SOAPBasetype.
|
# Override the definition in SOAPBasetype.
|
||||||
def initialize(obj = nil)
|
def initialize(obj = nil)
|
||||||
super()
|
super()
|
||||||
@type = XSD::QName.new
|
@type = XSD::QName.new
|
||||||
@encodingstyle = nil
|
|
||||||
@elename = XSD::QName.new
|
|
||||||
@id = nil
|
|
||||||
@precedents = []
|
|
||||||
@root = false
|
|
||||||
@parent = nil
|
|
||||||
@refid = nil
|
@refid = nil
|
||||||
@obj = nil
|
@obj = nil
|
||||||
__setobj__(obj) if obj
|
__setobj__(obj) if obj
|
||||||
@ -198,11 +171,6 @@ class SOAPExternalReference < XSD::NSDBase
|
|||||||
def initialize
|
def initialize
|
||||||
super()
|
super()
|
||||||
@type = XSD::QName.new
|
@type = XSD::QName.new
|
||||||
@encodingstyle = nil
|
|
||||||
@elename = XSD::QName.new
|
|
||||||
@precedents = []
|
|
||||||
@root = false
|
|
||||||
@parent = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def referred
|
def referred
|
||||||
@ -377,7 +345,8 @@ class SOAPStruct < XSD::NSDBase
|
|||||||
public
|
public
|
||||||
|
|
||||||
def initialize(type = nil)
|
def initialize(type = nil)
|
||||||
super(type || XSD::QName.new)
|
super()
|
||||||
|
@type = type || XSD::QName.new
|
||||||
@array = []
|
@array = []
|
||||||
@data = []
|
@data = []
|
||||||
end
|
end
|
||||||
@ -459,7 +428,7 @@ private
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# SOAPElement is not typed so it does not derive NSDBase.
|
# SOAPElement is not typed so it is not derived from NSDBase.
|
||||||
class SOAPElement
|
class SOAPElement
|
||||||
include Enumerable
|
include Enumerable
|
||||||
|
|
||||||
@ -534,7 +503,7 @@ class SOAPElement
|
|||||||
else
|
else
|
||||||
hash = {}
|
hash = {}
|
||||||
each do |k, v|
|
each do |k, v|
|
||||||
hash[k] = v.to_obj
|
hash[k] = v.is_a?(SOAPElement) ? v.to_obj : v.to_s
|
||||||
end
|
end
|
||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
@ -547,8 +516,7 @@ class SOAPElement
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.decode(elename)
|
def self.decode(elename)
|
||||||
o = SOAPElement.new
|
o = SOAPElement.new(elename)
|
||||||
o.elename = elename
|
|
||||||
o
|
o
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -557,7 +525,7 @@ class SOAPElement
|
|||||||
if hash_or_string.is_a?(Hash)
|
if hash_or_string.is_a?(Hash)
|
||||||
hash_or_string.each do |k, v|
|
hash_or_string.each do |k, v|
|
||||||
child = self.from_obj(v)
|
child = self.from_obj(v)
|
||||||
child.elename = XSD::QName.new(nil, k)
|
child.elename = k.is_a?(XSD::QName) ? k : XSD::QName.new(nil, k.to_s)
|
||||||
o.add(child)
|
o.add(child)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -616,7 +584,8 @@ public
|
|||||||
attr_reader :arytype
|
attr_reader :arytype
|
||||||
|
|
||||||
def initialize(type = nil, rank = 1, arytype = nil)
|
def initialize(type = nil, rank = 1, arytype = nil)
|
||||||
super(type || XSD::QName.new)
|
super()
|
||||||
|
@type = type || XSD::QName.new
|
||||||
@rank = rank
|
@rank = rank
|
||||||
@data = Array.new
|
@data = Array.new
|
||||||
@sparse = false
|
@sparse = false
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# SOAP4R - SOAP elements library
|
# SOAP4R - SOAP elements library
|
||||||
# Copyright (C) 2000, 2001, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
# Copyright (C) 2000, 2001, 2003, 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
# redistribute it and/or modify it under the same terms of Ruby's license;
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
@ -95,8 +95,6 @@ end
|
|||||||
class SOAPBody < SOAPStruct
|
class SOAPBody < SOAPStruct
|
||||||
include SOAPEnvelopeElement
|
include SOAPEnvelopeElement
|
||||||
|
|
||||||
public
|
|
||||||
|
|
||||||
def initialize(data = nil, is_fault = false)
|
def initialize(data = nil, is_fault = false)
|
||||||
super(nil)
|
super(nil)
|
||||||
@elename = EleBodyName
|
@elename = EleBodyName
|
||||||
@ -142,39 +140,39 @@ class SOAPHeaderItem < XSD::NSDBase
|
|||||||
|
|
||||||
public
|
public
|
||||||
|
|
||||||
attr_accessor :content
|
attr_accessor :element
|
||||||
attr_accessor :mustunderstand
|
attr_accessor :mustunderstand
|
||||||
attr_accessor :encodingstyle
|
attr_accessor :encodingstyle
|
||||||
|
|
||||||
def initialize(content, mustunderstand = true, encodingstyle = nil)
|
def initialize(element, mustunderstand = true, encodingstyle = nil)
|
||||||
super(nil)
|
super()
|
||||||
@content = content
|
@type = nil
|
||||||
|
@element = element
|
||||||
@mustunderstand = mustunderstand
|
@mustunderstand = mustunderstand
|
||||||
@encodingstyle = encodingstyle || LiteralNamespace
|
@encodingstyle = encodingstyle
|
||||||
content.parent = self if content
|
element.parent = self if element
|
||||||
end
|
end
|
||||||
|
|
||||||
def encode(generator, ns, attrs = {})
|
def encode(generator, ns, attrs = {})
|
||||||
attrs.each do |key, value|
|
attrs.each do |key, value|
|
||||||
@content.attr[key] = value
|
@element.extraattr[key] = value
|
||||||
end
|
end
|
||||||
@content.attr[ns.name(EnvelopeNamespace, AttrMustUnderstand)] =
|
@element.extraattr[ns.name(AttrMustUnderstandName)] =
|
||||||
(@mustunderstand ? '1' : '0')
|
(@mustunderstand ? '1' : '0')
|
||||||
if @encodingstyle
|
if @encodingstyle
|
||||||
@content.attr[ns.name(EnvelopeNamespace, AttrEncodingStyle)] =
|
@element.extraattr[ns.name(AttrEncodingStyleName)] = @encodingstyle
|
||||||
@encodingstyle
|
|
||||||
end
|
end
|
||||||
@content.encodingstyle = @encodingstyle if !@content.encodingstyle
|
@element.encodingstyle = @encodingstyle if !@element.encodingstyle
|
||||||
yield(@content, true)
|
yield(@element, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
class SOAPHeader < SOAPArray
|
class SOAPHeader < SOAPStruct
|
||||||
include SOAPEnvelopeElement
|
include SOAPEnvelopeElement
|
||||||
|
|
||||||
def initialize()
|
def initialize
|
||||||
super(nil, 1) # rank == 1
|
super(nil)
|
||||||
@elename = EleHeaderName
|
@elename = EleHeaderName
|
||||||
@encodingstyle = nil
|
@encodingstyle = nil
|
||||||
end
|
end
|
||||||
@ -188,9 +186,17 @@ class SOAPHeader < SOAPArray
|
|||||||
generator.encode_tag_end(name, true)
|
generator.encode_tag_end(name, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def add(name, value)
|
||||||
|
mu = (value.extraattr[AttrMustUnderstandName] == '1')
|
||||||
|
encstyle = value.extraattr[AttrEncodingStyleName]
|
||||||
|
item = SOAPHeaderItem.new(value, mu, encstyle)
|
||||||
|
super(name, item)
|
||||||
|
end
|
||||||
|
|
||||||
def length
|
def length
|
||||||
@data.length
|
@data.length
|
||||||
end
|
end
|
||||||
|
alias size length
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -203,7 +209,8 @@ class SOAPEnvelope < XSD::NSDBase
|
|||||||
attr_reader :external_content
|
attr_reader :external_content
|
||||||
|
|
||||||
def initialize(header = nil, body = nil)
|
def initialize(header = nil, body = nil)
|
||||||
super(nil)
|
super()
|
||||||
|
@type = nil
|
||||||
@elename = EleEnvelopeName
|
@elename = EleEnvelopeName
|
||||||
@encodingstyle = nil
|
@encodingstyle = nil
|
||||||
@header = header
|
@header = header
|
||||||
|
@ -44,8 +44,8 @@ class Handler
|
|||||||
|
|
||||||
attr_reader :charset
|
attr_reader :charset
|
||||||
attr_accessor :generate_explicit_type
|
attr_accessor :generate_explicit_type
|
||||||
def decode_typemap=(complextypes)
|
def decode_typemap=(definedtypes)
|
||||||
@decode_typemap = complextypes
|
@decode_typemap = definedtypes
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(charset)
|
def initialize(charset)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# SOAP4R - XML Literal EncodingStyle handler library
|
# SOAP4R - XML Literal EncodingStyle handler library
|
||||||
# Copyright (C) 2001, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
# Copyright (C) 2001, 2003, 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
# redistribute it and/or modify it under the same terms of Ruby's license;
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
@ -41,14 +41,18 @@ class LiteralHandler < Handler
|
|||||||
generator.encode_rawstring(data.to_s)
|
generator.encode_rawstring(data.to_s)
|
||||||
when XSD::XSDString
|
when XSD::XSDString
|
||||||
generator.encode_tag(name, attrs)
|
generator.encode_tag(name, attrs)
|
||||||
generator.encode_string(@charset ? XSD::Charset.encoding_to_xml(data.to_s, @charset) : data.to_s)
|
str = data.to_s
|
||||||
|
str = XSD::Charset.encoding_to_xml(str, @charset) if @charset
|
||||||
|
generator.encode_string(str)
|
||||||
when XSD::XSDAnySimpleType
|
when XSD::XSDAnySimpleType
|
||||||
generator.encode_tag(name, attrs)
|
generator.encode_tag(name, attrs)
|
||||||
generator.encode_string(data.to_s)
|
generator.encode_string(data.to_s)
|
||||||
when SOAPStruct
|
when SOAPStruct
|
||||||
generator.encode_tag(name, attrs)
|
generator.encode_tag(name, attrs)
|
||||||
data.each do |key, value|
|
data.each do |key, value|
|
||||||
value.elename.namespace = data.elename.namespace if !value.elename.namespace
|
if !value.elename.namespace
|
||||||
|
value.elename.namespace = data.elename.namespace
|
||||||
|
end
|
||||||
yield(value, true)
|
yield(value, true)
|
||||||
end
|
end
|
||||||
when SOAPArray
|
when SOAPArray
|
||||||
@ -61,8 +65,6 @@ class LiteralHandler < Handler
|
|||||||
generator.encode_tag(name, attrs.update(data.extraattr))
|
generator.encode_tag(name, attrs.update(data.extraattr))
|
||||||
generator.encode_rawstring(data.text) if data.text
|
generator.encode_rawstring(data.text) if data.text
|
||||||
data.each do |key, value|
|
data.each do |key, value|
|
||||||
value.elename.namespace = data.elename.namespace if !value.elename.namespace
|
|
||||||
#yield(value, data.qualified)
|
|
||||||
yield(value, qualified)
|
yield(value, qualified)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -76,7 +78,8 @@ class LiteralHandler < Handler
|
|||||||
else
|
else
|
||||||
data.elename.name
|
data.elename.name
|
||||||
end
|
end
|
||||||
generator.encode_tag_end(name)
|
cr = data.is_a?(SOAPElement) && !data.text
|
||||||
|
generator.encode_tag_end(name, cr)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -92,15 +95,17 @@ class LiteralHandler < Handler
|
|||||||
end
|
end
|
||||||
|
|
||||||
class SOAPUnknown < SOAPTemporalObject
|
class SOAPUnknown < SOAPTemporalObject
|
||||||
def initialize(handler, elename)
|
def initialize(handler, elename, extraattr)
|
||||||
super()
|
super()
|
||||||
@handler = handler
|
@handler = handler
|
||||||
@elename = elename
|
@elename = elename
|
||||||
|
@extraattr = extraattr
|
||||||
end
|
end
|
||||||
|
|
||||||
def as_struct
|
def as_element
|
||||||
o = SOAPStruct.decode(@elename, XSD::AnyTypeName)
|
o = SOAPElement.decode(@elename)
|
||||||
o.parent = @parent
|
o.parent = @parent
|
||||||
|
o.extraattr.update(@extraattr)
|
||||||
@handler.decode_parent(@parent, o)
|
@handler.decode_parent(@parent, o)
|
||||||
o
|
o
|
||||||
end
|
end
|
||||||
@ -108,6 +113,7 @@ class LiteralHandler < Handler
|
|||||||
def as_string
|
def as_string
|
||||||
o = SOAPString.decode(@elename)
|
o = SOAPString.decode(@elename)
|
||||||
o.parent = @parent
|
o.parent = @parent
|
||||||
|
o.extraattr.update(@extraattr)
|
||||||
@handler.decode_parent(@parent, o)
|
@handler.decode_parent(@parent, o)
|
||||||
o
|
o
|
||||||
end
|
end
|
||||||
@ -115,6 +121,7 @@ class LiteralHandler < Handler
|
|||||||
def as_nil
|
def as_nil
|
||||||
o = SOAPNil.decode(@elename)
|
o = SOAPNil.decode(@elename)
|
||||||
o.parent = @parent
|
o.parent = @parent
|
||||||
|
o.extraattr.update(@extraattr)
|
||||||
@handler.decode_parent(@parent, o)
|
@handler.decode_parent(@parent, o)
|
||||||
o
|
o
|
||||||
end
|
end
|
||||||
@ -123,7 +130,7 @@ class LiteralHandler < Handler
|
|||||||
def decode_tag(ns, elename, attrs, parent)
|
def decode_tag(ns, elename, attrs, parent)
|
||||||
# ToDo: check if @textbuf is empty...
|
# ToDo: check if @textbuf is empty...
|
||||||
@textbuf = ''
|
@textbuf = ''
|
||||||
o = SOAPUnknown.new(self, elename)
|
o = SOAPUnknown.new(self, elename, decode_attrs(ns, attrs))
|
||||||
o.parent = parent
|
o.parent = parent
|
||||||
o
|
o
|
||||||
end
|
end
|
||||||
@ -132,7 +139,7 @@ class LiteralHandler < Handler
|
|||||||
o = node.node
|
o = node.node
|
||||||
if o.is_a?(SOAPUnknown)
|
if o.is_a?(SOAPUnknown)
|
||||||
newnode = if /\A\s*\z/ =~ @textbuf
|
newnode = if /\A\s*\z/ =~ @textbuf
|
||||||
o.as_struct
|
o.as_element
|
||||||
else
|
else
|
||||||
o.as_string
|
o.as_string
|
||||||
end
|
end
|
||||||
@ -149,6 +156,15 @@ class LiteralHandler < Handler
|
|||||||
@textbuf << text
|
@textbuf << text
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def decode_attrs(ns, attrs)
|
||||||
|
extraattr = {}
|
||||||
|
attrs.each do |key, value|
|
||||||
|
qname = ns.parse(key)
|
||||||
|
extraattr[qname] = value
|
||||||
|
end
|
||||||
|
extraattr
|
||||||
|
end
|
||||||
|
|
||||||
def decode_prologue
|
def decode_prologue
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -158,13 +174,18 @@ class LiteralHandler < Handler
|
|||||||
def decode_parent(parent, node)
|
def decode_parent(parent, node)
|
||||||
case parent.node
|
case parent.node
|
||||||
when SOAPUnknown
|
when SOAPUnknown
|
||||||
newparent = parent.node.as_struct
|
newparent = parent.node.as_element
|
||||||
node.parent = newparent
|
node.parent = newparent
|
||||||
parent.replace_node(newparent)
|
parent.replace_node(newparent)
|
||||||
decode_parent(parent, node)
|
decode_parent(parent, node)
|
||||||
|
|
||||||
|
when SOAPElement
|
||||||
|
parent.node.add(node)
|
||||||
|
node.parent = parent.node
|
||||||
|
|
||||||
when SOAPStruct
|
when SOAPStruct
|
||||||
parent.node.add(node.name, node)
|
parent.node.add(node.elename.name, node)
|
||||||
|
node.parent = parent.node
|
||||||
|
|
||||||
when SOAPArray
|
when SOAPArray
|
||||||
if node.position
|
if node.position
|
||||||
@ -173,13 +194,14 @@ class LiteralHandler < Handler
|
|||||||
else
|
else
|
||||||
parent.node.add(node)
|
parent.node.add(node)
|
||||||
end
|
end
|
||||||
|
node.parent = parent.node
|
||||||
|
|
||||||
when SOAPBasetype
|
when SOAPBasetype
|
||||||
raise EncodingStyleError.new("SOAP base type must not have a child.")
|
raise EncodingStyleError.new("SOAP base type must not have a child.")
|
||||||
|
|
||||||
else
|
else
|
||||||
# SOAPUnknown does not have parent.
|
# SOAPUnknown does not have parent.
|
||||||
# raise EncodingStyleError.new("Illegal parent: #{ parent }.")
|
raise EncodingStyleError.new("Illegal parent: #{ parent }.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class SOAPHandler < Handler
|
|||||||
attrs = encode_attrs(generator, ns, data, parent)
|
attrs = encode_attrs(generator, ns, data, parent)
|
||||||
|
|
||||||
if parent && parent.is_a?(SOAPArray) && parent.position
|
if parent && parent.is_a?(SOAPArray) && parent.position
|
||||||
attrs[ns.name(AttrPositionName)] = '[' << parent.position.join(',') << ']'
|
attrs[ns.name(AttrPositionName)] = "[#{ parent.position.join(',') }]"
|
||||||
end
|
end
|
||||||
|
|
||||||
name = nil
|
name = nil
|
||||||
@ -207,16 +207,12 @@ class SOAPHandler < Handler
|
|||||||
node.replace_node(newnode)
|
node.replace_node(newnode)
|
||||||
o = node.node
|
o = node.node
|
||||||
end
|
end
|
||||||
if o.is_a?(SOAPCompoundtype)
|
|
||||||
o.definedtype = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
decode_textbuf(o)
|
decode_textbuf(o)
|
||||||
@textbuf = ''
|
# unlink definedtype
|
||||||
|
o.definedtype = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def decode_text(ns, text)
|
def decode_text(ns, text)
|
||||||
# @textbuf is set at decode_tag_end.
|
|
||||||
@textbuf << text
|
@textbuf << text
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -240,11 +236,9 @@ class SOAPHandler < Handler
|
|||||||
end
|
end
|
||||||
parent.replace_node(newparent)
|
parent.replace_node(newparent)
|
||||||
decode_parent(parent, node)
|
decode_parent(parent, node)
|
||||||
|
|
||||||
when SOAPStruct
|
when SOAPStruct
|
||||||
parent.node.add(node.elename.name, node)
|
parent.node.add(node.elename.name, node)
|
||||||
node.parent = parent.node
|
node.parent = parent.node
|
||||||
|
|
||||||
when SOAPArray
|
when SOAPArray
|
||||||
if node.position
|
if node.position
|
||||||
parent.node[*(decode_arypos(node.position))] = node
|
parent.node[*(decode_arypos(node.position))] = node
|
||||||
@ -253,10 +247,8 @@ class SOAPHandler < Handler
|
|||||||
parent.node.add(node)
|
parent.node.add(node)
|
||||||
end
|
end
|
||||||
node.parent = parent.node
|
node.parent = parent.node
|
||||||
|
|
||||||
when SOAPBasetype
|
when SOAPBasetype
|
||||||
raise EncodingStyleError.new("SOAP base type must not have a child.")
|
raise EncodingStyleError.new("SOAP base type must not have a child.")
|
||||||
|
|
||||||
else
|
else
|
||||||
raise EncodingStyleError.new("Illegal parent: #{ parent.node }.")
|
raise EncodingStyleError.new("Illegal parent: #{ parent.node }.")
|
||||||
end
|
end
|
||||||
@ -274,7 +266,7 @@ private
|
|||||||
|
|
||||||
def create_arytype(ns, data)
|
def create_arytype(ns, data)
|
||||||
XSD::QName.new(data.arytype.namespace,
|
XSD::QName.new(data.arytype.namespace,
|
||||||
content_typename(data.arytype.name) << '[' << data.size.join(',') << ']')
|
content_typename(data.arytype.name) + "[#{ data.size.join(',') }]")
|
||||||
end
|
end
|
||||||
|
|
||||||
def encode_attrs(generator, ns, data, parent)
|
def encode_attrs(generator, ns, data, parent)
|
||||||
@ -353,8 +345,7 @@ private
|
|||||||
typename = ns.parse(typestr)
|
typename = ns.parse(typestr)
|
||||||
typedef = @decode_typemap[typename]
|
typedef = @decode_typemap[typename]
|
||||||
if typedef
|
if typedef
|
||||||
return decode_defined_compoundtype(elename, typename, typedef,
|
return decode_definedtype(elename, typename, typedef, arytypestr)
|
||||||
arytypestr)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return decode_tag_by_type(ns, elename, typestr, parent, arytypestr,
|
return decode_tag_by_type(ns, elename, typestr, parent, arytypestr,
|
||||||
@ -376,21 +367,42 @@ private
|
|||||||
|
|
||||||
definedtype_name = parenttype.child_type(elename)
|
definedtype_name = parenttype.child_type(elename)
|
||||||
if definedtype_name and (klass = TypeMap[definedtype_name])
|
if definedtype_name and (klass = TypeMap[definedtype_name])
|
||||||
return klass.decode(elename)
|
return decode_basetype(klass, elename)
|
||||||
elsif definedtype_name == XSD::AnyTypeName
|
elsif definedtype_name == XSD::AnyTypeName
|
||||||
return decode_tag_by_type(ns, elename, typestr, parent, arytypestr,
|
return decode_tag_by_type(ns, elename, typestr, parent, arytypestr,
|
||||||
extraattr)
|
extraattr)
|
||||||
end
|
end
|
||||||
|
|
||||||
typedef = definedtype_name ? @decode_typemap[definedtype_name] :
|
if definedtype_name
|
||||||
parenttype.child_defined_complextype(elename)
|
typedef = @decode_typemap[definedtype_name]
|
||||||
decode_defined_compoundtype(elename, definedtype_name, typedef, arytypestr)
|
else
|
||||||
|
typedef = parenttype.child_defined_complextype(elename)
|
||||||
|
end
|
||||||
|
decode_definedtype(elename, definedtype_name, typedef, arytypestr)
|
||||||
end
|
end
|
||||||
|
|
||||||
def decode_defined_compoundtype(elename, typename, typedef, arytypestr)
|
def decode_definedtype(elename, typename, typedef, arytypestr)
|
||||||
unless typedef
|
unless typedef
|
||||||
raise EncodingStyleError.new("Unknown type '#{ typename }'.")
|
raise EncodingStyleError.new("Unknown type '#{ typename }'.")
|
||||||
end
|
end
|
||||||
|
if typedef.is_a?(::WSDL::XMLSchema::SimpleType)
|
||||||
|
decode_defined_simpletype(elename, typename, typedef, arytypestr)
|
||||||
|
else
|
||||||
|
decode_defined_complextype(elename, typename, typedef, arytypestr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def decode_basetype(klass, elename)
|
||||||
|
klass.decode(elename)
|
||||||
|
end
|
||||||
|
|
||||||
|
def decode_defined_simpletype(elename, typename, typedef, arytypestr)
|
||||||
|
o = decode_basetype(TypeMap[typedef.base], elename)
|
||||||
|
o.definedtype = typedef
|
||||||
|
o
|
||||||
|
end
|
||||||
|
|
||||||
|
def decode_defined_complextype(elename, typename, typedef, arytypestr)
|
||||||
case typedef.compoundtype
|
case typedef.compoundtype
|
||||||
when :TYPE_STRUCT
|
when :TYPE_STRUCT
|
||||||
o = SOAPStruct.decode(elename, typename)
|
o = SOAPStruct.decode(elename, typename)
|
||||||
@ -410,7 +422,7 @@ private
|
|||||||
o.definedtype = typedef
|
o.definedtype = typedef
|
||||||
return o
|
return o
|
||||||
end
|
end
|
||||||
return nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def decode_tag_by_type(ns, elename, typestr, parent, arytypestr, extraattr)
|
def decode_tag_by_type(ns, elename, typestr, parent, arytypestr, extraattr)
|
||||||
@ -435,7 +447,7 @@ private
|
|||||||
end
|
end
|
||||||
|
|
||||||
if (klass = TypeMap[type])
|
if (klass = TypeMap[type])
|
||||||
node = klass.decode(elename)
|
node = decode_basetype(klass, elename)
|
||||||
node.extraattr.update(extraattr)
|
node.extraattr.update(extraattr)
|
||||||
return node
|
return node
|
||||||
end
|
end
|
||||||
@ -450,10 +462,12 @@ private
|
|||||||
node.set_encoded(@textbuf)
|
node.set_encoded(@textbuf)
|
||||||
when XSD::XSDString
|
when XSD::XSDString
|
||||||
if @charset
|
if @charset
|
||||||
node.set(XSD::Charset.encoding_from_xml(@textbuf, @charset))
|
@textbuf = XSD::Charset.encoding_from_xml(@textbuf, @charset)
|
||||||
else
|
|
||||||
node.set(@textbuf)
|
|
||||||
end
|
end
|
||||||
|
if node.definedtype
|
||||||
|
node.definedtype.check_lexical_format(@textbuf)
|
||||||
|
end
|
||||||
|
node.set(@textbuf)
|
||||||
when SOAPNil
|
when SOAPNil
|
||||||
# Nothing to do.
|
# Nothing to do.
|
||||||
when SOAPBasetype
|
when SOAPBasetype
|
||||||
@ -461,6 +475,7 @@ private
|
|||||||
else
|
else
|
||||||
# Nothing to do...
|
# Nothing to do...
|
||||||
end
|
end
|
||||||
|
@textbuf = ''
|
||||||
end
|
end
|
||||||
|
|
||||||
NilLiteralMap = {
|
NilLiteralMap = {
|
||||||
|
@ -90,9 +90,9 @@ public
|
|||||||
raise FormatEncodeError.new("Element name not defined: #{ obj }.")
|
raise FormatEncodeError.new("Element name not defined: #{ obj }.")
|
||||||
end
|
end
|
||||||
|
|
||||||
handler.encode_data(self, ns, qualified, obj, parent) do |child, child_q|
|
handler.encode_data(self, ns, qualified, obj, parent) do |child, nextq|
|
||||||
indent_backup, @indent = @indent, @indent + ' '
|
indent_backup, @indent = @indent, @indent + ' '
|
||||||
encode_data(ns.clone_ns, child_q, child, obj)
|
encode_data(ns.clone_ns, nextq, child, obj)
|
||||||
@indent = indent_backup
|
@indent = indent_backup
|
||||||
end
|
end
|
||||||
handler.encode_data_end(self, ns, qualified, obj, parent)
|
handler.encode_data_end(self, ns, qualified, obj, parent)
|
||||||
@ -109,9 +109,9 @@ public
|
|||||||
attrs = {}
|
attrs = {}
|
||||||
if obj.is_a?(SOAPBody)
|
if obj.is_a?(SOAPBody)
|
||||||
@reftarget = obj
|
@reftarget = obj
|
||||||
obj.encode(self, ns, attrs) do |child, child_q|
|
obj.encode(self, ns, attrs) do |child, nextq|
|
||||||
indent_backup, @indent = @indent, @indent + ' '
|
indent_backup, @indent = @indent, @indent + ' '
|
||||||
encode_data(ns.clone_ns, child_q, child, obj)
|
encode_data(ns.clone_ns, nextq, child, obj)
|
||||||
@indent = indent_backup
|
@indent = indent_backup
|
||||||
end
|
end
|
||||||
@reftarget = nil
|
@reftarget = nil
|
||||||
@ -124,9 +124,9 @@ public
|
|||||||
SOAPGenerator.assign_ns(attrs, ns, XSD::Namespace, XSDNamespaceTag)
|
SOAPGenerator.assign_ns(attrs, ns, XSD::Namespace, XSDNamespaceTag)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
obj.encode(self, ns, attrs) do |child, child_q|
|
obj.encode(self, ns, attrs) do |child, nextq|
|
||||||
indent_backup, @indent = @indent, @indent + ' '
|
indent_backup, @indent = @indent, @indent + ' '
|
||||||
encode_data(ns.clone_ns, child_q, child, obj)
|
encode_data(ns.clone_ns, nextq, child, obj)
|
||||||
@indent = indent_backup
|
@indent = indent_backup
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
57
lib/soap/header/handler.rb
Normal file
57
lib/soap/header/handler.rb
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
# SOAP4R - SOAP Header handler item
|
||||||
|
# Copyright (C) 2003, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'soap/element'
|
||||||
|
|
||||||
|
|
||||||
|
module SOAP
|
||||||
|
module Header
|
||||||
|
|
||||||
|
|
||||||
|
class Handler
|
||||||
|
attr_reader :elename
|
||||||
|
attr_reader :mustunderstand
|
||||||
|
attr_reader :encodingstyle
|
||||||
|
|
||||||
|
def initialize(elename)
|
||||||
|
@elename = elename
|
||||||
|
@mustunderstand = false
|
||||||
|
@encodingstyle = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
# Should return a SOAP/OM, a SOAPHeaderItem or nil.
|
||||||
|
def on_outbound
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
# Given header is a SOAPHeaderItem or nil.
|
||||||
|
def on_inbound(header, mustunderstand = false)
|
||||||
|
# do something.
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_outbound_headeritem
|
||||||
|
item = on_outbound
|
||||||
|
if item.nil?
|
||||||
|
nil
|
||||||
|
elsif item.is_a?(::SOAP::SOAPHeaderItem)
|
||||||
|
item.elename = @elename
|
||||||
|
item
|
||||||
|
else
|
||||||
|
item.elename = @elename
|
||||||
|
::SOAP::SOAPHeaderItem.new(item, @mustunderstand, @encodingstyle)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_inbound_headeritem(header)
|
||||||
|
on_inbound(header.element, header.mustunderstand)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
58
lib/soap/header/handlerset.rb
Normal file
58
lib/soap/header/handlerset.rb
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
# SOAP4R - SOAP Header handler set
|
||||||
|
# Copyright (C) 2003, 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'xsd/namedelements'
|
||||||
|
|
||||||
|
|
||||||
|
module SOAP
|
||||||
|
module Header
|
||||||
|
|
||||||
|
|
||||||
|
class HandlerSet
|
||||||
|
def initialize
|
||||||
|
@store = XSD::NamedElements.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def add(handler)
|
||||||
|
@store << handler
|
||||||
|
end
|
||||||
|
alias << add
|
||||||
|
|
||||||
|
def delete(handler)
|
||||||
|
@store.delete(handler)
|
||||||
|
end
|
||||||
|
|
||||||
|
def include?(handler)
|
||||||
|
@store.include?(handler)
|
||||||
|
end
|
||||||
|
|
||||||
|
# returns: Array of SOAPHeaderItem
|
||||||
|
def on_outbound
|
||||||
|
@store.collect { |handler|
|
||||||
|
handler.on_outbound_headeritem
|
||||||
|
}.compact
|
||||||
|
end
|
||||||
|
|
||||||
|
# headers: SOAPHeaderItem enumerable object
|
||||||
|
def on_inbound(headers)
|
||||||
|
headers.each do |name, item|
|
||||||
|
handler = @store.find { |handler|
|
||||||
|
handler.elename == item.element.elename
|
||||||
|
}
|
||||||
|
if handler
|
||||||
|
handler.on_inbound_headeritem(item)
|
||||||
|
elsif item.mustunderstand
|
||||||
|
raise UnhandledMustUnderstandHeaderError.new(item.element.elename.to_s)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
44
lib/soap/header/simplehandler.rb
Normal file
44
lib/soap/header/simplehandler.rb
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# SOAP4R - SOAP Simple header item handler
|
||||||
|
# Copyright (C) 2003, 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'soap/header/handler'
|
||||||
|
require 'soap/baseData'
|
||||||
|
|
||||||
|
|
||||||
|
module SOAP
|
||||||
|
module Header
|
||||||
|
|
||||||
|
|
||||||
|
class SimpleHandler < SOAP::Header::Handler
|
||||||
|
def initialize(elename)
|
||||||
|
super(elename)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Should return a Hash or nil.
|
||||||
|
def on_simple_outbound
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
# Given header is a Hash or nil.
|
||||||
|
def on_simple_inbound(header, mustunderstand)
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_outbound
|
||||||
|
h = on_simple_outbound
|
||||||
|
h ? SOAPElement.from_obj(h) : nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_inbound(header, mustunderstand)
|
||||||
|
h = header.to_obj
|
||||||
|
on_simple_inbound(h, mustunderstand)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
@ -70,6 +70,7 @@ class Factory
|
|||||||
end
|
end
|
||||||
|
|
||||||
def setiv2soap(node, obj, map)
|
def setiv2soap(node, obj, map)
|
||||||
|
# should we sort instance_variables?
|
||||||
obj.instance_variables.each do |var|
|
obj.instance_variables.each do |var|
|
||||||
name = var.sub(/^@/, '')
|
name = var.sub(/^@/, '')
|
||||||
node.add(Mapping.name2elename(name),
|
node.add(Mapping.name2elename(name),
|
||||||
|
@ -68,24 +68,26 @@ module Mapping
|
|||||||
md_ary
|
md_ary
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.fault2exception(e, registry = nil)
|
def self.fault2exception(fault, registry = nil)
|
||||||
registry ||= Mapping::DefaultRegistry
|
registry ||= Mapping::DefaultRegistry
|
||||||
detail = if e.detail
|
detail = if fault.detail
|
||||||
soap2obj(e.detail, registry) || ""
|
soap2obj(fault.detail, registry) || ""
|
||||||
else
|
else
|
||||||
""
|
""
|
||||||
end
|
end
|
||||||
if detail.is_a?(Mapping::SOAPException)
|
if detail.is_a?(Mapping::SOAPException)
|
||||||
begin
|
begin
|
||||||
remote_backtrace = detail.to_e.backtrace
|
e = detail.to_e
|
||||||
raise detail.to_e
|
remote_backtrace = e.backtrace
|
||||||
rescue Exception => e2
|
e.set_backtrace(nil)
|
||||||
e2.set_backtrace(remote_backtrace + e2.backtrace)
|
raise e # ruby sets current caller as local backtrace of e => e2.
|
||||||
|
rescue Exception => e
|
||||||
|
e.set_backtrace(remote_backtrace + e.backtrace[1..-1])
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
e.detail = detail
|
fault.detail = detail
|
||||||
e.set_backtrace(
|
fault.set_backtrace(
|
||||||
if detail.is_a?(Array)
|
if detail.is_a?(Array)
|
||||||
detail
|
detail
|
||||||
else
|
else
|
||||||
|
@ -44,14 +44,15 @@ class SOAPException; include Marshallable
|
|||||||
if @cause.is_a?(::Exception)
|
if @cause.is_a?(::Exception)
|
||||||
@cause.extend(::SOAP::Mapping::MappedException)
|
@cause.extend(::SOAP::Mapping::MappedException)
|
||||||
return @cause
|
return @cause
|
||||||
|
elsif @cause.respond_to?(:message) and @cause.respond_to?(:backtrace)
|
||||||
|
e = RuntimeError.new(@cause.message)
|
||||||
|
e.set_backtrace(@cause.backtrace)
|
||||||
|
return e
|
||||||
end
|
end
|
||||||
klass = Mapping.class_from_name(
|
klass = Mapping.class_from_name(
|
||||||
Mapping.elename2name(@excn_type_name.to_s))
|
Mapping.elename2name(@excn_type_name.to_s))
|
||||||
if klass.nil?
|
if klass.nil? or not klass <= ::Exception
|
||||||
raise RuntimeError.new(@cause.message)
|
return RuntimeError.new(@cause.inspect)
|
||||||
end
|
|
||||||
unless klass <= ::Exception
|
|
||||||
raise NameError.new
|
|
||||||
end
|
end
|
||||||
obj = klass.new(@cause.message)
|
obj = klass.new(@cause.message)
|
||||||
obj.extend(::SOAP::Mapping::MappedException)
|
obj.extend(::SOAP::Mapping::MappedException)
|
||||||
@ -62,50 +63,78 @@ end
|
|||||||
|
|
||||||
# For anyType object: SOAP::Mapping::Object not ::Object
|
# For anyType object: SOAP::Mapping::Object not ::Object
|
||||||
class Object; include Marshallable
|
class Object; include Marshallable
|
||||||
def set_property(name, value)
|
def initialize
|
||||||
var_name = name
|
@__members = []
|
||||||
begin
|
@__value_type = {}
|
||||||
instance_eval <<-EOS
|
|
||||||
def #{ var_name }
|
|
||||||
@#{ var_name }
|
|
||||||
end
|
|
||||||
|
|
||||||
def #{ var_name }=(value)
|
|
||||||
@#{ var_name } = value
|
|
||||||
end
|
|
||||||
EOS
|
|
||||||
self.send(var_name + '=', value)
|
|
||||||
rescue SyntaxError
|
|
||||||
var_name = safe_name(var_name)
|
|
||||||
retry
|
|
||||||
end
|
|
||||||
|
|
||||||
var_name
|
|
||||||
end
|
|
||||||
|
|
||||||
def members
|
|
||||||
instance_variables.collect { |str| str[1..-1] }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def [](name)
|
def [](name)
|
||||||
if self.respond_to?(name)
|
if @__members.include?(name)
|
||||||
self.send(name)
|
self.__send__(name)
|
||||||
else
|
else
|
||||||
self.send(safe_name(name))
|
self.__send__(Object.safe_name(name))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def []=(name, value)
|
def []=(name, value)
|
||||||
if self.respond_to?(name)
|
if @__members.include?(name)
|
||||||
self.send(name + '=', value)
|
self.__send__(name + '=', value)
|
||||||
else
|
else
|
||||||
self.send(safe_name(name) + '=', value)
|
self.__send__(Object.safe_name(name) + '=', value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def __set_property(name, value)
|
||||||
|
var_name = name
|
||||||
|
unless @__members.include?(name)
|
||||||
|
var_name = __define_attr_accessor(var_name)
|
||||||
|
end
|
||||||
|
__set_property_value(var_name, value)
|
||||||
|
var_name
|
||||||
|
end
|
||||||
|
|
||||||
|
def __members
|
||||||
|
@__members
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def safe_name(name)
|
def __set_property_value(name, value)
|
||||||
|
org = self.__send__(name)
|
||||||
|
case @__value_type[name]
|
||||||
|
when :single
|
||||||
|
self.__send__(name + '=', [org, value])
|
||||||
|
@__value_type[name] = :multi
|
||||||
|
when :multi
|
||||||
|
org << value
|
||||||
|
else
|
||||||
|
self.__send__(name + '=', value)
|
||||||
|
@__value_type[name] = :single
|
||||||
|
end
|
||||||
|
value
|
||||||
|
end
|
||||||
|
|
||||||
|
def __define_attr_accessor(name)
|
||||||
|
var_name = name
|
||||||
|
begin
|
||||||
|
instance_eval <<-EOS
|
||||||
|
def #{ var_name }
|
||||||
|
@#{ var_name }
|
||||||
|
end
|
||||||
|
|
||||||
|
def #{ var_name }=(value)
|
||||||
|
@#{ var_name } = value
|
||||||
|
end
|
||||||
|
EOS
|
||||||
|
rescue SyntaxError
|
||||||
|
var_name = Object.safe_name(var_name)
|
||||||
|
retry
|
||||||
|
end
|
||||||
|
@__members << var_name
|
||||||
|
var_name
|
||||||
|
end
|
||||||
|
|
||||||
|
def Object.safe_name(name)
|
||||||
require 'md5'
|
require 'md5'
|
||||||
"var_" << MD5.new(name).hexdigest
|
"var_" << MD5.new(name).hexdigest
|
||||||
end
|
end
|
||||||
@ -309,7 +338,7 @@ class Registry
|
|||||||
def add(obj_class, soap_class, factory, info = nil)
|
def add(obj_class, soap_class, factory, info = nil)
|
||||||
@map.add(obj_class, soap_class, factory, info)
|
@map.add(obj_class, soap_class, factory, info)
|
||||||
end
|
end
|
||||||
alias :set :add
|
alias set add
|
||||||
|
|
||||||
# This mapping registry ignores type hint.
|
# This mapping registry ignores type hint.
|
||||||
def obj2soap(klass, obj, type_qname = nil)
|
def obj2soap(klass, obj, type_qname = nil)
|
||||||
|
@ -38,7 +38,7 @@ class RubytypeFactory < Factory
|
|||||||
def obj2soap(soap_class, obj, info, map)
|
def obj2soap(soap_class, obj, info, map)
|
||||||
param = nil
|
param = nil
|
||||||
case obj
|
case obj
|
||||||
when String
|
when ::String
|
||||||
unless @allow_original_mapping
|
unless @allow_original_mapping
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@ -47,7 +47,7 @@ class RubytypeFactory < Factory
|
|||||||
param.extraattr[RubyTypeName] = obj.class.name
|
param.extraattr[RubyTypeName] = obj.class.name
|
||||||
end
|
end
|
||||||
addiv2soapattr(param, obj, map)
|
addiv2soapattr(param, obj, map)
|
||||||
when Time
|
when ::Time
|
||||||
unless @allow_original_mapping
|
unless @allow_original_mapping
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@ -56,7 +56,7 @@ class RubytypeFactory < Factory
|
|||||||
param.extraattr[RubyTypeName] = obj.class.name
|
param.extraattr[RubyTypeName] = obj.class.name
|
||||||
end
|
end
|
||||||
addiv2soapattr(param, obj, map)
|
addiv2soapattr(param, obj, map)
|
||||||
when Array
|
when ::Array
|
||||||
unless @allow_original_mapping
|
unless @allow_original_mapping
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@ -65,19 +65,19 @@ class RubytypeFactory < Factory
|
|||||||
param.extraattr[RubyTypeName] = obj.class.name
|
param.extraattr[RubyTypeName] = obj.class.name
|
||||||
end
|
end
|
||||||
addiv2soapattr(param, obj, map)
|
addiv2soapattr(param, obj, map)
|
||||||
when NilClass
|
when ::NilClass
|
||||||
unless @allow_original_mapping
|
unless @allow_original_mapping
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
param = @basetype_factory.obj2soap(SOAPNil, obj, info, map)
|
param = @basetype_factory.obj2soap(SOAPNil, obj, info, map)
|
||||||
addiv2soapattr(param, obj, map)
|
addiv2soapattr(param, obj, map)
|
||||||
when FalseClass, TrueClass
|
when ::FalseClass, ::TrueClass
|
||||||
unless @allow_original_mapping
|
unless @allow_original_mapping
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
param = @basetype_factory.obj2soap(SOAPBoolean, obj, info, map)
|
param = @basetype_factory.obj2soap(SOAPBoolean, obj, info, map)
|
||||||
addiv2soapattr(param, obj, map)
|
addiv2soapattr(param, obj, map)
|
||||||
when Integer
|
when ::Integer
|
||||||
unless @allow_original_mapping
|
unless @allow_original_mapping
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@ -85,7 +85,7 @@ class RubytypeFactory < Factory
|
|||||||
param ||= @basetype_factory.obj2soap(SOAPInteger, obj, info, map)
|
param ||= @basetype_factory.obj2soap(SOAPInteger, obj, info, map)
|
||||||
param ||= @basetype_factory.obj2soap(SOAPDecimal, obj, info, map)
|
param ||= @basetype_factory.obj2soap(SOAPDecimal, obj, info, map)
|
||||||
addiv2soapattr(param, obj, map)
|
addiv2soapattr(param, obj, map)
|
||||||
when Float
|
when ::Float
|
||||||
unless @allow_original_mapping
|
unless @allow_original_mapping
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@ -94,7 +94,7 @@ class RubytypeFactory < Factory
|
|||||||
param.extraattr[RubyTypeName] = obj.class.name
|
param.extraattr[RubyTypeName] = obj.class.name
|
||||||
end
|
end
|
||||||
addiv2soapattr(param, obj, map)
|
addiv2soapattr(param, obj, map)
|
||||||
when Hash
|
when ::Hash
|
||||||
unless @allow_original_mapping
|
unless @allow_original_mapping
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@ -114,7 +114,7 @@ class RubytypeFactory < Factory
|
|||||||
end
|
end
|
||||||
param.add('default', Mapping._obj2soap(obj.default, map))
|
param.add('default', Mapping._obj2soap(obj.default, map))
|
||||||
addiv2soapattr(param, obj, map)
|
addiv2soapattr(param, obj, map)
|
||||||
when Regexp
|
when ::Regexp
|
||||||
unless @allow_original_mapping
|
unless @allow_original_mapping
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@ -150,7 +150,7 @@ class RubytypeFactory < Factory
|
|||||||
end
|
end
|
||||||
param.add('options', SOAPInt.new(options))
|
param.add('options', SOAPInt.new(options))
|
||||||
addiv2soapattr(param, obj, map)
|
addiv2soapattr(param, obj, map)
|
||||||
when Range
|
when ::Range
|
||||||
unless @allow_original_mapping
|
unless @allow_original_mapping
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@ -163,29 +163,29 @@ class RubytypeFactory < Factory
|
|||||||
param.add('end', Mapping._obj2soap(obj.end, map))
|
param.add('end', Mapping._obj2soap(obj.end, map))
|
||||||
param.add('exclude_end', SOAP::SOAPBoolean.new(obj.exclude_end?))
|
param.add('exclude_end', SOAP::SOAPBoolean.new(obj.exclude_end?))
|
||||||
addiv2soapattr(param, obj, map)
|
addiv2soapattr(param, obj, map)
|
||||||
when Class
|
when ::Class
|
||||||
unless @allow_original_mapping
|
unless @allow_original_mapping
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
if obj.to_s[0] == ?#
|
if obj.to_s[0] == ?#
|
||||||
raise TypeError.new("Can't dump anonymous class #{ obj }.")
|
raise TypeError.new("can't dump anonymous class #{ obj }")
|
||||||
end
|
end
|
||||||
param = SOAPStruct.new(TYPE_CLASS)
|
param = SOAPStruct.new(TYPE_CLASS)
|
||||||
mark_marshalled_obj(obj, param)
|
mark_marshalled_obj(obj, param)
|
||||||
param.add('name', SOAPString.new(obj.name))
|
param.add('name', SOAPString.new(obj.name))
|
||||||
addiv2soapattr(param, obj, map)
|
addiv2soapattr(param, obj, map)
|
||||||
when Module
|
when ::Module
|
||||||
unless @allow_original_mapping
|
unless @allow_original_mapping
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
if obj.to_s[0] == ?#
|
if obj.to_s[0] == ?#
|
||||||
raise TypeError.new("Can't dump anonymous module #{ obj }.")
|
raise TypeError.new("can't dump anonymous module #{ obj }")
|
||||||
end
|
end
|
||||||
param = SOAPStruct.new(TYPE_MODULE)
|
param = SOAPStruct.new(TYPE_MODULE)
|
||||||
mark_marshalled_obj(obj, param)
|
mark_marshalled_obj(obj, param)
|
||||||
param.add('name', SOAPString.new(obj.name))
|
param.add('name', SOAPString.new(obj.name))
|
||||||
addiv2soapattr(param, obj, map)
|
addiv2soapattr(param, obj, map)
|
||||||
when Symbol
|
when ::Symbol
|
||||||
unless @allow_original_mapping
|
unless @allow_original_mapping
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@ -193,28 +193,37 @@ class RubytypeFactory < Factory
|
|||||||
mark_marshalled_obj(obj, param)
|
mark_marshalled_obj(obj, param)
|
||||||
param.add('id', SOAPString.new(obj.id2name))
|
param.add('id', SOAPString.new(obj.id2name))
|
||||||
addiv2soapattr(param, obj, map)
|
addiv2soapattr(param, obj, map)
|
||||||
when Struct
|
when ::Struct
|
||||||
unless @allow_original_mapping
|
unless @allow_original_mapping
|
||||||
return nil
|
# treat it as an user defined class. [ruby-talk:104980]
|
||||||
|
#param = unknownobj2soap(soap_class, obj, info, map)
|
||||||
|
param = SOAPStruct.new(XSD::AnyTypeName)
|
||||||
|
mark_marshalled_obj(obj, param)
|
||||||
|
obj.members.each do |member|
|
||||||
|
param.add(Mapping.name2elename(member),
|
||||||
|
Mapping._obj2soap(obj[member], map))
|
||||||
|
end
|
||||||
|
else
|
||||||
|
param = SOAPStruct.new(TYPE_STRUCT)
|
||||||
|
mark_marshalled_obj(obj, param)
|
||||||
|
param.add('type', ele_type = SOAPString.new(obj.class.to_s))
|
||||||
|
ele_member = SOAPStruct.new
|
||||||
|
obj.members.each do |member|
|
||||||
|
ele_member.add(Mapping.name2elename(member),
|
||||||
|
Mapping._obj2soap(obj[member], map))
|
||||||
|
end
|
||||||
|
param.add('member', ele_member)
|
||||||
|
addiv2soapattr(param, obj, map)
|
||||||
end
|
end
|
||||||
param = SOAPStruct.new(TYPE_STRUCT)
|
when ::IO, ::Binding, ::Continuation, ::Data, ::Dir, ::File::Stat,
|
||||||
mark_marshalled_obj(obj, param)
|
::MatchData, Method, ::Proc, ::Thread, ::ThreadGroup
|
||||||
param.add('type', ele_type = SOAPString.new(obj.class.to_s))
|
# from 1.8: Process::Status, UnboundMethod
|
||||||
ele_member = SOAPStruct.new
|
|
||||||
obj.members.each do |member|
|
|
||||||
ele_member.add(Mapping.name2elename(member),
|
|
||||||
Mapping._obj2soap(obj[member], map))
|
|
||||||
end
|
|
||||||
param.add('member', ele_member)
|
|
||||||
addiv2soapattr(param, obj, map)
|
|
||||||
when IO, Binding, Continuation, Data, Dir, File::Stat, MatchData, Method,
|
|
||||||
Proc, Thread, ThreadGroup # from 1.8: Process::Status, UnboundMethod
|
|
||||||
return nil
|
return nil
|
||||||
when ::SOAP::Mapping::Object
|
when ::SOAP::Mapping::Object
|
||||||
param = SOAPStruct.new(XSD::AnyTypeName)
|
param = SOAPStruct.new(XSD::AnyTypeName)
|
||||||
mark_marshalled_obj(obj, param)
|
mark_marshalled_obj(obj, param)
|
||||||
addiv2soapattr(param, obj, map)
|
addiv2soapattr(param, obj, map)
|
||||||
when Exception
|
when ::Exception
|
||||||
typestr = Mapping.name2elename(obj.class.to_s)
|
typestr = Mapping.name2elename(obj.class.to_s)
|
||||||
param = SOAPStruct.new(XSD::QName.new(RubyTypeNamespace, typestr))
|
param = SOAPStruct.new(XSD::QName.new(RubyTypeNamespace, typestr))
|
||||||
mark_marshalled_obj(obj, param)
|
mark_marshalled_obj(obj, param)
|
||||||
@ -249,7 +258,7 @@ private
|
|||||||
|
|
||||||
def unknownobj2soap(soap_class, obj, info, map)
|
def unknownobj2soap(soap_class, obj, info, map)
|
||||||
if obj.class.name.empty?
|
if obj.class.name.empty?
|
||||||
raise TypeError.new("Can't dump anonymous class #{ obj }.")
|
raise TypeError.new("can't dump anonymous class #{ obj }")
|
||||||
end
|
end
|
||||||
singleton_class = class << obj; self; end
|
singleton_class = class << obj; self; end
|
||||||
if !singleton_methods_true(obj).empty? or
|
if !singleton_methods_true(obj).empty? or
|
||||||
@ -369,7 +378,7 @@ private
|
|||||||
obj = klass.new
|
obj = klass.new
|
||||||
mark_unmarshalled_obj(node, obj)
|
mark_unmarshalled_obj(node, obj)
|
||||||
node.each do |name, value|
|
node.each do |name, value|
|
||||||
obj.set_property(name, Mapping._soap2obj(value, map))
|
obj.__set_property(name, Mapping._soap2obj(value, map))
|
||||||
end
|
end
|
||||||
return true, obj
|
return true, obj
|
||||||
else
|
else
|
||||||
|
@ -18,10 +18,10 @@ module Mapping
|
|||||||
class WSDLRegistry
|
class WSDLRegistry
|
||||||
include TraverseSupport
|
include TraverseSupport
|
||||||
|
|
||||||
attr_reader :complextypes
|
attr_reader :definedtypes
|
||||||
|
|
||||||
def initialize(complextypes, config = {})
|
def initialize(definedtypes, config = {})
|
||||||
@complextypes = complextypes
|
@definedtypes = definedtypes
|
||||||
@config = config
|
@config = config
|
||||||
@excn_handler_obj2soap = nil
|
@excn_handler_obj2soap = nil
|
||||||
# For mapping AnyType element.
|
# For mapping AnyType element.
|
||||||
@ -37,27 +37,20 @@ class WSDLRegistry
|
|||||||
soap_obj = SOAPNil.new
|
soap_obj = SOAPNil.new
|
||||||
elsif obj.is_a?(XSD::NSDBase)
|
elsif obj.is_a?(XSD::NSDBase)
|
||||||
soap_obj = soap2soap(obj, type_qname)
|
soap_obj = soap2soap(obj, type_qname)
|
||||||
elsif (type = @complextypes[type_qname])
|
elsif type = @definedtypes[type_qname]
|
||||||
case type.compoundtype
|
soap_obj = obj2type(obj, type)
|
||||||
when :TYPE_STRUCT
|
|
||||||
soap_obj = struct2soap(obj, type_qname, type)
|
|
||||||
when :TYPE_ARRAY
|
|
||||||
soap_obj = array2soap(obj, type_qname, type)
|
|
||||||
end
|
|
||||||
elsif (type = TypeMap[type_qname])
|
elsif (type = TypeMap[type_qname])
|
||||||
soap_obj = base2soap(obj, type)
|
soap_obj = base2soap(obj, type)
|
||||||
elsif type_qname == XSD::AnyTypeName
|
elsif type_qname == XSD::AnyTypeName
|
||||||
soap_obj = @rubytype_factory.obj2soap(nil, obj, nil, nil)
|
soap_obj = @rubytype_factory.obj2soap(nil, obj, nil, nil)
|
||||||
end
|
end
|
||||||
return soap_obj if soap_obj
|
return soap_obj if soap_obj
|
||||||
|
|
||||||
if @excn_handler_obj2soap
|
if @excn_handler_obj2soap
|
||||||
soap_obj = @excn_handler_obj2soap.call(obj) { |yield_obj|
|
soap_obj = @excn_handler_obj2soap.call(obj) { |yield_obj|
|
||||||
Mapping._obj2soap(yield_obj, self)
|
Mapping._obj2soap(yield_obj, self)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
return soap_obj if soap_obj
|
return soap_obj if soap_obj
|
||||||
|
|
||||||
raise MappingError.new("Cannot map #{ klass.name } to SOAP/OM.")
|
raise MappingError.new("Cannot map #{ klass.name } to SOAP/OM.")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -74,12 +67,12 @@ private
|
|||||||
def soap2soap(obj, type_qname)
|
def soap2soap(obj, type_qname)
|
||||||
if obj.is_a?(SOAPBasetype)
|
if obj.is_a?(SOAPBasetype)
|
||||||
obj
|
obj
|
||||||
elsif obj.is_a?(SOAPStruct) && (type = @complextypes[type_qname])
|
elsif obj.is_a?(SOAPStruct) && (type = @definedtypes[type_qname])
|
||||||
soap_obj = obj
|
soap_obj = obj
|
||||||
mark_marshalled_obj(obj, soap_obj)
|
mark_marshalled_obj(obj, soap_obj)
|
||||||
elements2soap(obj, soap_obj, type.content.elements)
|
elements2soap(obj, soap_obj, type.content.elements)
|
||||||
soap_obj
|
soap_obj
|
||||||
elsif obj.is_a?(SOAPArray) && (type = @complextypes[type_qname])
|
elsif obj.is_a?(SOAPArray) && (type = @definedtypes[type_qname])
|
||||||
soap_obj = obj
|
soap_obj = obj
|
||||||
contenttype = type.child_type
|
contenttype = type.child_type
|
||||||
mark_marshalled_obj(obj, soap_obj)
|
mark_marshalled_obj(obj, soap_obj)
|
||||||
@ -92,6 +85,33 @@ private
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def obj2type(obj, type)
|
||||||
|
if type.is_a?(::WSDL::XMLSchema::SimpleType)
|
||||||
|
simple2soap(obj, type)
|
||||||
|
else
|
||||||
|
complex2soap(obj, type)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def simple2soap(obj, type)
|
||||||
|
o = base2soap(obj, TypeMap[type.base])
|
||||||
|
if type.restriction.enumeration.empty?
|
||||||
|
STDERR.puts("#{type.name}: simpleType which is not enum type not supported.")
|
||||||
|
return o
|
||||||
|
end
|
||||||
|
type.check_lexical_format(obj)
|
||||||
|
o
|
||||||
|
end
|
||||||
|
|
||||||
|
def complex2soap(obj, type)
|
||||||
|
case type.compoundtype
|
||||||
|
when :TYPE_STRUCT
|
||||||
|
struct2soap(obj, type.name, type)
|
||||||
|
when :TYPE_ARRAY
|
||||||
|
array2soap(obj, type.name, type)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def base2soap(obj, type)
|
def base2soap(obj, type)
|
||||||
soap_obj = nil
|
soap_obj = nil
|
||||||
if type <= XSD::XSDString
|
if type <= XSD::XSDString
|
||||||
|
@ -34,6 +34,10 @@ class NetHttpClient
|
|||||||
@session_manager = SessionManager.new
|
@session_manager = SessionManager.new
|
||||||
@no_proxy = nil
|
@no_proxy = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_loopback_response
|
||||||
|
raise NotImplementedError.new("not supported for now")
|
||||||
|
end
|
||||||
|
|
||||||
def proxy=(proxy_str)
|
def proxy=(proxy_str)
|
||||||
if proxy_str.nil?
|
if proxy_str.nil?
|
||||||
@ -54,7 +58,11 @@ class NetHttpClient
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_cookie_store(filename)
|
def set_cookie_store(filename)
|
||||||
# ignored.
|
raise NotImplementedError.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def save_cookie_store(filename)
|
||||||
|
raise NotImplementedError.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset(url)
|
def reset(url)
|
||||||
@ -70,8 +78,8 @@ class NetHttpClient
|
|||||||
extra = header.dup
|
extra = header.dup
|
||||||
extra['User-Agent'] = @agent if @agent
|
extra['User-Agent'] = @agent if @agent
|
||||||
res = start(url) { |http|
|
res = start(url) { |http|
|
||||||
http.post(url.request_uri, req_body, extra)
|
http.post(url.request_uri, req_body, extra)
|
||||||
}
|
}
|
||||||
Response.new(res)
|
Response.new(res)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -117,7 +117,13 @@ public
|
|||||||
encodingstyle = find_encodingstyle(ns, attrs)
|
encodingstyle = find_encodingstyle(ns, attrs)
|
||||||
|
|
||||||
# Children's encodingstyle is derived from its parent.
|
# Children's encodingstyle is derived from its parent.
|
||||||
encodingstyle ||= parent_encodingstyle || @default_encodingstyle
|
if encodingstyle.nil?
|
||||||
|
if parent.node.is_a?(SOAPHeader)
|
||||||
|
encodingstyle = LiteralNamespace
|
||||||
|
else
|
||||||
|
encodingstyle = parent_encodingstyle || @default_encodingstyle
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
node = decode_tag(ns, name, attrs, parent, encodingstyle)
|
node = decode_tag(ns, name, attrs, parent, encodingstyle)
|
||||||
|
|
||||||
|
@ -34,22 +34,24 @@ module SOAP
|
|||||||
class Property
|
class Property
|
||||||
include Enumerable
|
include Enumerable
|
||||||
|
|
||||||
|
module Util
|
||||||
|
def const_from_name(fqname)
|
||||||
|
fqname.split("::").inject(Kernel) { |klass, name| klass.const_get(name) }
|
||||||
|
end
|
||||||
|
module_function :const_from_name
|
||||||
|
|
||||||
|
def require_from_name(fqname)
|
||||||
|
require File.join(fqname.split("::").collect { |ele| ele.downcase })
|
||||||
|
end
|
||||||
|
module_function :require_from_name
|
||||||
|
end
|
||||||
|
|
||||||
def self.load(stream)
|
def self.load(stream)
|
||||||
new.load(stream)
|
new.load(stream)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.open(filename)
|
|
||||||
File.open(filename) { |f| load(f) }
|
|
||||||
end
|
|
||||||
|
|
||||||
# find property from $:.
|
|
||||||
def self.loadproperty(propname)
|
def self.loadproperty(propname)
|
||||||
$:.each do |path|
|
new.loadproperty(propname)
|
||||||
if File.file?(file = File.join(path, propname))
|
|
||||||
return open(file)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@ -87,6 +89,17 @@ class Property
|
|||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# find property from $:.
|
||||||
|
def loadproperty(propname)
|
||||||
|
return loadpropertyfile(propname) if File.file?(propname)
|
||||||
|
$:.each do |path|
|
||||||
|
if File.file?(file = File.join(path, propname))
|
||||||
|
return loadpropertyfile(file)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
# name: a Symbol, String or an Array
|
# name: a Symbol, String or an Array
|
||||||
def [](name)
|
def [](name)
|
||||||
referent(name_to_a(name))
|
referent(name_to_a(name))
|
||||||
@ -95,10 +108,10 @@ class Property
|
|||||||
# name: a Symbol, String or an Array
|
# name: a Symbol, String or an Array
|
||||||
# value: an Object
|
# value: an Object
|
||||||
def []=(name, value)
|
def []=(name, value)
|
||||||
hooks = assign(name_to_a(name), value)
|
name_pair = name_to_a(name).freeze
|
||||||
normalized_name = normalize_name(name)
|
hooks = assign(name_pair, value)
|
||||||
hooks.each do |hook|
|
hooks.each do |hook|
|
||||||
hook.call(normalized_name, value)
|
hook.call(name_pair, value)
|
||||||
end
|
end
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
@ -109,13 +122,15 @@ class Property
|
|||||||
self[generate_new_key] = value
|
self[generate_new_key] = value
|
||||||
end
|
end
|
||||||
|
|
||||||
# name: a Symbol, String or an Array. nil means hook to the root
|
# name: a Symbol, String or an Array; nil means hook to the root
|
||||||
|
# cascade: true/false; for cascading hook of sub key
|
||||||
# hook: block which will be called with 2 args, name and value
|
# hook: block which will be called with 2 args, name and value
|
||||||
def add_hook(name = nil, &hook)
|
def add_hook(name = nil, cascade = false, &hook)
|
||||||
if name.nil?
|
if name == nil or name == true or name == false
|
||||||
assign_self_hook(&hook)
|
cascade = name
|
||||||
|
assign_self_hook(cascade, &hook)
|
||||||
else
|
else
|
||||||
assign_hook(name_to_a(name), &hook)
|
assign_hook(name_to_a(name), cascade, &hook)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -192,14 +207,18 @@ protected
|
|||||||
@store[key] = value
|
@store[key] = value
|
||||||
end
|
end
|
||||||
|
|
||||||
def local_hook(key)
|
def local_hook(key, direct)
|
||||||
@self_hook + (@hook[key] || NO_HOOK)
|
hooks = []
|
||||||
|
(@self_hook + (@hook[key] || NO_HOOK)).each do |hook, cascade|
|
||||||
|
hooks << hook if direct or cascade
|
||||||
|
end
|
||||||
|
hooks
|
||||||
end
|
end
|
||||||
|
|
||||||
def local_assign_hook(key, &hook)
|
def local_assign_hook(key, cascade, &hook)
|
||||||
check_lock(key)
|
check_lock(key)
|
||||||
@store[key] ||= nil
|
@store[key] ||= nil
|
||||||
(@hook[key] ||= []) << hook
|
(@hook[key] ||= []) << [hook, cascade]
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@ -217,23 +236,23 @@ private
|
|||||||
hook = NO_HOOK
|
hook = NO_HOOK
|
||||||
ary[0..-2].each do |name|
|
ary[0..-2].each do |name|
|
||||||
key = to_key(name)
|
key = to_key(name)
|
||||||
hook += ref.local_hook(key)
|
hook += ref.local_hook(key, false)
|
||||||
ref = ref.deref_key(key)
|
ref = ref.deref_key(key)
|
||||||
end
|
end
|
||||||
last_key = to_key(ary.last)
|
last_key = to_key(ary.last)
|
||||||
ref.local_assign(last_key, value)
|
ref.local_assign(last_key, value)
|
||||||
hook + ref.local_hook(last_key)
|
hook + ref.local_hook(last_key, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def assign_hook(ary, &hook)
|
def assign_hook(ary, cascade, &hook)
|
||||||
ary[0..-2].inject(self) { |ref, name|
|
ary[0..-2].inject(self) { |ref, name|
|
||||||
ref.deref_key(to_key(name))
|
ref.deref_key(to_key(name))
|
||||||
}.local_assign_hook(to_key(ary.last), &hook)
|
}.local_assign_hook(to_key(ary.last), cascade, &hook)
|
||||||
end
|
end
|
||||||
|
|
||||||
def assign_self_hook(&hook)
|
def assign_self_hook(cascade, &hook)
|
||||||
check_lock(nil)
|
check_lock(nil)
|
||||||
@self_hook << hook
|
@self_hook << [hook, cascade]
|
||||||
end
|
end
|
||||||
|
|
||||||
def each_key
|
def each_key
|
||||||
@ -267,10 +286,6 @@ private
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize_name(name)
|
|
||||||
name_to_a(name).collect { |key| to_key(key) }.join('.')
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_key(name)
|
def to_key(name)
|
||||||
name.to_s.downcase
|
name.to_s.downcase
|
||||||
end
|
end
|
||||||
@ -286,6 +301,13 @@ private
|
|||||||
def key_max
|
def key_max
|
||||||
(@store.keys.max { |l, r| l.to_s.to_i <=> r.to_s.to_i }).to_s.to_i
|
(@store.keys.max { |l, r| l.to_s.to_i <=> r.to_s.to_i }).to_s.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def loadpropertyfile(file)
|
||||||
|
puts "find property at #{file}" if $DEBUG
|
||||||
|
File.open(file) do |f|
|
||||||
|
load(f)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# SOAP4R - CGI stub library
|
# SOAP4R - CGI stub library
|
||||||
# Copyright (C) 2001, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
# Copyright (C) 2001, 2003, 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
# redistribute it and/or modify it under the same terms of Ruby's license;
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
@ -94,15 +94,21 @@ class CGIStub < Logger::Application
|
|||||||
on_init
|
on_init
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_servant(obj, namespace = @default_namespace, soapaction = nil)
|
def add_rpc_servant(obj, namespace = @default_namespace, soapaction = nil)
|
||||||
RPC.defined_methods(obj).each do |name|
|
RPC.defined_methods(obj).each do |name|
|
||||||
qname = XSD::QName.new(namespace, name)
|
qname = XSD::QName.new(namespace, name)
|
||||||
param_size = obj.method(name).arity.abs
|
param_size = obj.method(name).arity.abs
|
||||||
params = (1..param_size).collect { |i| "p#{ i }" }
|
params = (1..param_size).collect { |i| "p#{i}" }
|
||||||
param_def = SOAP::RPC::SOAPMethod.create_param_def(params)
|
param_def = SOAP::RPC::SOAPMethod.create_param_def(params)
|
||||||
@router.add_method(obj, qname, soapaction, name, param_def)
|
@router.add_method(obj, qname, soapaction, name, param_def)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
alias add_servant add_rpc_servant
|
||||||
|
|
||||||
|
def add_rpc_headerhandler(obj)
|
||||||
|
@router.headerhandler << obj
|
||||||
|
end
|
||||||
|
alias add_headerhandler add_rpc_headerhandler
|
||||||
|
|
||||||
def on_init
|
def on_init
|
||||||
# Override this method in derived class to call 'add_method' to add methods.
|
# Override this method in derived class to call 'add_method' to add methods.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# SOAP4R - SOAP RPC driver
|
# SOAP4R - SOAP RPC driver
|
||||||
# Copyright (C) 2000, 2001, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
# Copyright (C) 2000, 2001, 2003, 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
# redistribute it and/or modify it under the same terms of Ruby's license;
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
@ -13,6 +13,7 @@ require 'soap/rpc/proxy'
|
|||||||
require 'soap/rpc/element'
|
require 'soap/rpc/element'
|
||||||
require 'soap/streamHandler'
|
require 'soap/streamHandler'
|
||||||
require 'soap/property'
|
require 'soap/property'
|
||||||
|
require 'soap/header/handlerset'
|
||||||
|
|
||||||
|
|
||||||
module SOAP
|
module SOAP
|
||||||
@ -41,6 +42,8 @@ class Driver
|
|||||||
end
|
end
|
||||||
|
|
||||||
__attr_proxy :options
|
__attr_proxy :options
|
||||||
|
__attr_proxy :headerhandler
|
||||||
|
__attr_proxy :test_loopback_response
|
||||||
__attr_proxy :endpoint_url, true
|
__attr_proxy :endpoint_url, true
|
||||||
__attr_proxy :mapping_registry, true
|
__attr_proxy :mapping_registry, true
|
||||||
__attr_proxy :soapaction, true
|
__attr_proxy :soapaction, true
|
||||||
@ -84,6 +87,12 @@ class Driver
|
|||||||
@proxy = @servant.proxy
|
@proxy = @servant.proxy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def loadproperty(propertyname)
|
||||||
|
unless options.loadproperty(propertyname)
|
||||||
|
raise LoadError.new("No such property to load -- #{propertyname}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def inspect
|
def inspect
|
||||||
"#<#{self.class}:#{@servant.streamhandler.inspect}>"
|
"#<#{self.class}:#{@servant.streamhandler.inspect}>"
|
||||||
end
|
end
|
||||||
@ -130,6 +139,7 @@ private
|
|||||||
class Servant__
|
class Servant__
|
||||||
attr_reader :options
|
attr_reader :options
|
||||||
attr_reader :streamhandler
|
attr_reader :streamhandler
|
||||||
|
attr_reader :headerhandler
|
||||||
attr_reader :proxy
|
attr_reader :proxy
|
||||||
|
|
||||||
def initialize(host, endpoint_url, namespace)
|
def initialize(host, endpoint_url, namespace)
|
||||||
@ -141,6 +151,7 @@ private
|
|||||||
@options = setup_options
|
@options = setup_options
|
||||||
@streamhandler = HTTPPostStreamHandler.new(endpoint_url,
|
@streamhandler = HTTPPostStreamHandler.new(endpoint_url,
|
||||||
@options["protocol.http"] ||= ::SOAP::Property.new)
|
@options["protocol.http"] ||= ::SOAP::Property.new)
|
||||||
|
@headerhandler = Header::HandlerSet.new
|
||||||
@proxy = Proxy.new(@streamhandler, @soapaction)
|
@proxy = Proxy.new(@streamhandler, @soapaction)
|
||||||
@proxy.allow_unqualified_element = true
|
@proxy.allow_unqualified_element = true
|
||||||
end
|
end
|
||||||
@ -178,6 +189,10 @@ private
|
|||||||
@proxy.default_encodingstyle = encodingstyle
|
@proxy.default_encodingstyle = encodingstyle
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_loopback_response
|
||||||
|
@streamhandler.test_loopback_response
|
||||||
|
end
|
||||||
|
|
||||||
def invoke(headers, body)
|
def invoke(headers, body)
|
||||||
set_wiredump_file_base(body.elename.name)
|
set_wiredump_file_base(body.elename.name)
|
||||||
env = @proxy.invoke(headers, body)
|
env = @proxy.invoke(headers, body)
|
||||||
@ -192,19 +207,19 @@ private
|
|||||||
set_wiredump_file_base(name)
|
set_wiredump_file_base(name)
|
||||||
# Convert parameters: params array => SOAPArray => members array
|
# Convert parameters: params array => SOAPArray => members array
|
||||||
params = Mapping.obj2soap(params, @mapping_registry).to_a
|
params = Mapping.obj2soap(params, @mapping_registry).to_a
|
||||||
env = @proxy.call(nil, name, *params)
|
env = @proxy.call(call_headers, name, *params)
|
||||||
raise EmptyResponseError.new("Empty response.") unless env
|
raise EmptyResponseError.new("Empty response.") unless env
|
||||||
header, body = env.header, env.body
|
receive_headers(env.header)
|
||||||
begin
|
begin
|
||||||
@proxy.check_fault(body)
|
@proxy.check_fault(env.body)
|
||||||
rescue SOAP::FaultError => e
|
rescue SOAP::FaultError => e
|
||||||
Mapping.fault2exception(e)
|
Mapping.fault2exception(e)
|
||||||
end
|
end
|
||||||
|
|
||||||
ret = body.response ?
|
ret = env.body.response ?
|
||||||
Mapping.soap2obj(body.response, @mapping_registry) : nil
|
Mapping.soap2obj(env.body.response, @mapping_registry) : nil
|
||||||
if body.outparams
|
if env.body.outparams
|
||||||
outparams = body.outparams.collect { |outparam|
|
outparams = env.body.outparams.collect { |outparam|
|
||||||
Mapping.soap2obj(outparam)
|
Mapping.soap2obj(outparam)
|
||||||
}
|
}
|
||||||
return [ret].concat(outparams)
|
return [ret].concat(outparams)
|
||||||
@ -233,10 +248,28 @@ private
|
|||||||
@servant.call(#{ name.dump }#{ callparam })
|
@servant.call(#{ name.dump }#{ callparam })
|
||||||
end
|
end
|
||||||
EOS
|
EOS
|
||||||
|
@host.method(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def call_headers
|
||||||
|
headers = @headerhandler.on_outbound
|
||||||
|
if headers.empty?
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
h = ::SOAP::SOAPHeader.new
|
||||||
|
headers.each do |header|
|
||||||
|
h.add(header.elename.name, header)
|
||||||
|
end
|
||||||
|
h
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def receive_headers(headers)
|
||||||
|
@headerhandler.on_inbound(headers) if headers
|
||||||
|
end
|
||||||
|
|
||||||
def set_wiredump_file_base(name)
|
def set_wiredump_file_base(name)
|
||||||
if @wiredump_file_base
|
if @wiredump_file_base
|
||||||
@streamhandler.wiredump_file_base = @wiredump_file_base + "_#{ name }"
|
@streamhandler.wiredump_file_base = @wiredump_file_base + "_#{ name }"
|
||||||
|
105
lib/soap/rpc/httpserver.rb
Normal file
105
lib/soap/rpc/httpserver.rb
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
# SOAP4R - WEBrick HTTP Server
|
||||||
|
# Copyright (C) 2003, 2004 by NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'logger'
|
||||||
|
require 'soap/rpc/soaplet'
|
||||||
|
require 'soap/streamHandler'
|
||||||
|
require 'webrick'
|
||||||
|
|
||||||
|
|
||||||
|
module SOAP
|
||||||
|
module RPC
|
||||||
|
|
||||||
|
|
||||||
|
class HTTPServer < Logger::Application
|
||||||
|
attr_reader :server
|
||||||
|
attr_accessor :default_namespace
|
||||||
|
|
||||||
|
def initialize(config)
|
||||||
|
super(config[:SOAPHTTPServerApplicationName] || self.class.name)
|
||||||
|
@default_namespace = config[:SOAPDefaultNamespace]
|
||||||
|
@webrick_config = config.dup
|
||||||
|
@webrick_config[:Logger] ||= @log
|
||||||
|
@server = nil
|
||||||
|
@soaplet = ::SOAP::RPC::SOAPlet.new
|
||||||
|
self.level = Logger::Severity::INFO
|
||||||
|
on_init
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_init
|
||||||
|
# define extra methods in derived class.
|
||||||
|
end
|
||||||
|
|
||||||
|
def status
|
||||||
|
if @server
|
||||||
|
@server.status
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def shutdown
|
||||||
|
@server.shutdown if @server
|
||||||
|
end
|
||||||
|
|
||||||
|
def mapping_registry
|
||||||
|
@soaplet.app_scope_router.mapping_registry
|
||||||
|
end
|
||||||
|
|
||||||
|
def mapping_registry=(mapping_registry)
|
||||||
|
@soaplet.app_scope_router.mapping_registry = mapping_registry
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_rpc_request_servant(factory, namespace = @default_namespace,
|
||||||
|
mapping_registry = nil)
|
||||||
|
@soaplet.add_rpc_request_servant(factory, namespace, mapping_registry)
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_rpc_servant(obj, namespace = @default_namespace)
|
||||||
|
@soaplet.add_rpc_servant(obj, namespace)
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_rpc_request_headerhandler(factory)
|
||||||
|
@soaplet.add_rpc_request_headerhandler(factory)
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_rpc_headerhandler(obj)
|
||||||
|
@soaplet.add_rpc_headerhandler(obj)
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_method(obj, name, *param)
|
||||||
|
add_method_as(obj, name, name, *param)
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_method_as(obj, name, name_as, *param)
|
||||||
|
qname = XSD::QName.new(@default_namespace, name_as)
|
||||||
|
soapaction = nil
|
||||||
|
method = obj.method(name)
|
||||||
|
param_def = if param.size == 1 and param[0].is_a?(Array)
|
||||||
|
param[0]
|
||||||
|
elsif param.empty?
|
||||||
|
::SOAP::RPC::SOAPMethod.create_param_def(
|
||||||
|
(1..method.arity.abs).collect { |i| "p#{ i }" })
|
||||||
|
else
|
||||||
|
SOAP::RPC::SOAPMethod.create_param_def(param)
|
||||||
|
end
|
||||||
|
@soaplet.app_scope_router.add_method(obj, qname, soapaction, name, param_def)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def run
|
||||||
|
@server = WEBrick::HTTPServer.new(@webrick_config)
|
||||||
|
@server.mount('/', @soaplet)
|
||||||
|
@server.start
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
@ -1,5 +1,5 @@
|
|||||||
# SOAP4R - RPC Proxy library.
|
# SOAP4R - RPC Proxy library.
|
||||||
# Copyright (C) 2000, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
# Copyright (C) 2000, 2003, 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
# redistribute it and/or modify it under the same terms of Ruby's license;
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
@ -112,9 +112,9 @@ public
|
|||||||
unmarshal(conn_data, opt)
|
unmarshal(conn_data, opt)
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(headers, name, *values)
|
def call(req_header, name, *values)
|
||||||
req = create_request(name, *values)
|
req = create_request(name, *values)
|
||||||
invoke(headers, req.method, req.method.soapaction || @soapaction)
|
invoke(req_header, req.method, req.method.soapaction || @soapaction)
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_fault(body)
|
def check_fault(body)
|
||||||
|
@ -13,6 +13,7 @@ require 'soap/rpc/rpc'
|
|||||||
require 'soap/rpc/element'
|
require 'soap/rpc/element'
|
||||||
require 'soap/streamHandler'
|
require 'soap/streamHandler'
|
||||||
require 'soap/mimemessage'
|
require 'soap/mimemessage'
|
||||||
|
require 'soap/header/handlerset'
|
||||||
|
|
||||||
|
|
||||||
module SOAP
|
module SOAP
|
||||||
@ -26,6 +27,7 @@ class Router
|
|||||||
attr_accessor :allow_unqualified_element
|
attr_accessor :allow_unqualified_element
|
||||||
attr_accessor :default_encodingstyle
|
attr_accessor :default_encodingstyle
|
||||||
attr_accessor :mapping_registry
|
attr_accessor :mapping_registry
|
||||||
|
attr_reader :headerhandler
|
||||||
|
|
||||||
def initialize(actor)
|
def initialize(actor)
|
||||||
@actor = actor
|
@actor = actor
|
||||||
@ -35,6 +37,7 @@ class Router
|
|||||||
@allow_unqualified_element = false
|
@allow_unqualified_element = false
|
||||||
@default_encodingstyle = nil
|
@default_encodingstyle = nil
|
||||||
@mapping_registry = nil
|
@mapping_registry = nil
|
||||||
|
@headerhandler = Header::HandlerSet.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_method(receiver, qname, soapaction, name, param_def)
|
def add_method(receiver, qname, soapaction, name, param_def)
|
||||||
@ -44,12 +47,6 @@ class Router
|
|||||||
@method[fqname] = RPC::SOAPMethodRequest.new(qname, param_def, soapaction)
|
@method[fqname] = RPC::SOAPMethodRequest.new(qname, param_def, soapaction)
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_header_handler
|
|
||||||
raise NotImplementedError.new
|
|
||||||
end
|
|
||||||
|
|
||||||
# Routing...
|
|
||||||
#def route(soap_string, charset = nil)
|
|
||||||
def route(conn_data)
|
def route(conn_data)
|
||||||
soap_response = nil
|
soap_response = nil
|
||||||
begin
|
begin
|
||||||
@ -57,7 +54,7 @@ class Router
|
|||||||
if env.nil?
|
if env.nil?
|
||||||
raise ArgumentError.new("Illegal SOAP marshal format.")
|
raise ArgumentError.new("Illegal SOAP marshal format.")
|
||||||
end
|
end
|
||||||
# So far, header is omitted...
|
receive_headers(env.header)
|
||||||
soap_request = env.body.request
|
soap_request = env.body.request
|
||||||
unless soap_request.is_a?(SOAPStruct)
|
unless soap_request.is_a?(SOAPStruct)
|
||||||
raise RPCRoutingError.new("Not an RPC style.")
|
raise RPCRoutingError.new("Not an RPC style.")
|
||||||
@ -70,7 +67,7 @@ class Router
|
|||||||
|
|
||||||
opt = options
|
opt = options
|
||||||
opt[:external_content] = nil
|
opt[:external_content] = nil
|
||||||
header = SOAPHeader.new
|
header = call_headers
|
||||||
body = SOAPBody.new(soap_response)
|
body = SOAPBody.new(soap_response)
|
||||||
env = SOAPEnvelope.new(header, body)
|
env = SOAPEnvelope.new(header, body)
|
||||||
response_string = Processor.marshal(env, opt)
|
response_string = Processor.marshal(env, opt)
|
||||||
@ -114,13 +111,30 @@ class Router
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def call_headers
|
||||||
|
headers = @headerhandler.on_outbound
|
||||||
|
if headers.empty?
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
h = ::SOAP::SOAPHeader.new
|
||||||
|
headers.each do |header|
|
||||||
|
h.add(header.elename.name, header)
|
||||||
|
end
|
||||||
|
h
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def receive_headers(headers)
|
||||||
|
@headerhandler.on_inbound(headers) if headers
|
||||||
|
end
|
||||||
|
|
||||||
def unmarshal(conn_data)
|
def unmarshal(conn_data)
|
||||||
opt = options
|
opt = options
|
||||||
contenttype = conn_data.receive_contenttype
|
contenttype = conn_data.receive_contenttype
|
||||||
if /#{MIMEMessage::MultipartContentType}/i =~ contenttype
|
if /#{MIMEMessage::MultipartContentType}/i =~ contenttype
|
||||||
opt[:external_content] = {}
|
opt[:external_content] = {}
|
||||||
mime = MIMEMessage.parse("Content-Type: " + contenttype,
|
mime = MIMEMessage.parse("Content-Type: " + contenttype,
|
||||||
conn_data.receive_string)
|
conn_data.receive_string)
|
||||||
mime.parts.each do |part|
|
mime.parts.each do |part|
|
||||||
value = Attachment.new(part.content)
|
value = Attachment.new(part.content)
|
||||||
value.contentid = part.contentid
|
value.contentid = part.contentid
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# SOAP4R - SOAP handler servlet for WEBrick
|
# SOAP4R - SOAP handler servlet for WEBrick
|
||||||
# Copyright (C) 2001, 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
# Copyright (C) 2001, 2002, 2003, 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
# redistribute it and/or modify it under the same terms of Ruby's license;
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
@ -22,20 +22,28 @@ public
|
|||||||
def initialize
|
def initialize
|
||||||
@router_map = {}
|
@router_map = {}
|
||||||
@app_scope_router = ::SOAP::RPC::Router.new(self.class.name)
|
@app_scope_router = ::SOAP::RPC::Router.new(self.class.name)
|
||||||
|
@headerhandlerfactory = []
|
||||||
|
@app_scope_headerhandler = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add servant klass whose object has request scope. A servant object is
|
# Add servant factory whose object has request scope. A servant object is
|
||||||
# instantiated for each request.
|
# instanciated for each request.
|
||||||
#
|
#
|
||||||
# Bare in mind that servant klasses are distinguished by HTTP SOAPAction
|
# Bear in mind that servant factories are distinguished by HTTP SOAPAction
|
||||||
# header in request. Client which calls request-scoped servant must have a
|
# header in request. Client which calls request-scoped servant must have a
|
||||||
# SOAPAction header which is a namespace of the servant klass.
|
# SOAPAction header which is a namespace of the servant factory.
|
||||||
# I mean, use Driver#add_method_with_soapaction instead of Driver#add_method
|
# I mean, use Driver#add_method_with_soapaction instead of Driver#add_method
|
||||||
# at client side.
|
# at client side.
|
||||||
#
|
#
|
||||||
def add_rpc_request_servant(klass, namespace, mapping_registry = nil)
|
# A factory must respond to :create.
|
||||||
router = RequestRouter.new(klass, namespace, mapping_registry)
|
#
|
||||||
add_router(namespace, router)
|
def add_rpc_request_servant(factory, namespace, mapping_registry = nil)
|
||||||
|
unless factory.respond_to?(:create)
|
||||||
|
raise TypeError.new("factory must respond to 'create'")
|
||||||
|
end
|
||||||
|
router = setup_request_router(namespace)
|
||||||
|
router.factory = factory
|
||||||
|
router.mapping_registry = mapping_registry
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add servant object which has application scope.
|
# Add servant object which has application scope.
|
||||||
@ -46,6 +54,17 @@ public
|
|||||||
end
|
end
|
||||||
alias add_servant add_rpc_servant
|
alias add_servant add_rpc_servant
|
||||||
|
|
||||||
|
def add_rpc_request_headerhandler(factory)
|
||||||
|
unless factory.respond_to?(:create)
|
||||||
|
raise TypeError.new("factory must respond to 'create'")
|
||||||
|
end
|
||||||
|
@headerhandlerfactory << factory
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_rpc_headerhandler(obj)
|
||||||
|
@app_scope_headerhandler = obj
|
||||||
|
end
|
||||||
|
alias add_headerhandler add_rpc_headerhandler
|
||||||
|
|
||||||
###
|
###
|
||||||
## Servlet interfaces for WEBrick.
|
## Servlet interfaces for WEBrick.
|
||||||
@ -67,21 +86,23 @@ public
|
|||||||
def do_POST(req, res)
|
def do_POST(req, res)
|
||||||
namespace = parse_soapaction(req.meta_vars['HTTP_SOAPACTION'])
|
namespace = parse_soapaction(req.meta_vars['HTTP_SOAPACTION'])
|
||||||
router = lookup_router(namespace)
|
router = lookup_router(namespace)
|
||||||
begin
|
with_headerhandler(router) do |router|
|
||||||
conn_data = ::SOAP::StreamHandler::ConnectionData.new
|
begin
|
||||||
conn_data.receive_string = req.body
|
conn_data = ::SOAP::StreamHandler::ConnectionData.new
|
||||||
conn_data.receive_contenttype = req['content-type']
|
conn_data.receive_string = req.body
|
||||||
conn_data = router.route(conn_data)
|
conn_data.receive_contenttype = req['content-type']
|
||||||
if conn_data.is_fault
|
conn_data = router.route(conn_data)
|
||||||
|
if conn_data.is_fault
|
||||||
|
res.status = WEBrick::HTTPStatus::RC_INTERNAL_SERVER_ERROR
|
||||||
|
end
|
||||||
|
res.body = conn_data.send_string
|
||||||
|
res['content-type'] = conn_data.send_contenttype
|
||||||
|
rescue Exception => e
|
||||||
|
conn_data = router.create_fault_response(e)
|
||||||
res.status = WEBrick::HTTPStatus::RC_INTERNAL_SERVER_ERROR
|
res.status = WEBrick::HTTPStatus::RC_INTERNAL_SERVER_ERROR
|
||||||
|
res.body = conn_data.send_string
|
||||||
|
res['content-type'] = conn_data.send_contenttype || "text/xml"
|
||||||
end
|
end
|
||||||
res.body = conn_data.send_string
|
|
||||||
res['content-type'] = conn_data.send_contenttype
|
|
||||||
rescue Exception => e
|
|
||||||
conn_data = router.create_fault_response(e)
|
|
||||||
res.status = WEBrick::HTTPStatus::RC_INTERNAL_SERVER_ERROR
|
|
||||||
res.body = conn_data.send_string
|
|
||||||
res['content-type'] = conn_data.send_contenttype || "text/xml"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if res.body.is_a?(IO)
|
if res.body.is_a?(IO)
|
||||||
@ -92,17 +113,16 @@ public
|
|||||||
private
|
private
|
||||||
|
|
||||||
class RequestRouter < ::SOAP::RPC::Router
|
class RequestRouter < ::SOAP::RPC::Router
|
||||||
def initialize(klass, namespace, mapping_registry = nil)
|
attr_accessor :factory
|
||||||
|
|
||||||
|
def initialize(namespace = nil)
|
||||||
super(namespace)
|
super(namespace)
|
||||||
if mapping_registry
|
|
||||||
self.mapping_registry = mapping_registry
|
|
||||||
end
|
|
||||||
@klass = klass
|
|
||||||
@namespace = namespace
|
@namespace = namespace
|
||||||
|
@factory = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def route(soap_string)
|
def route(soap_string)
|
||||||
obj = @klass.new
|
obj = @factory.create
|
||||||
namespace = self.actor
|
namespace = self.actor
|
||||||
router = ::SOAP::RPC::Router.new(@namespace)
|
router = ::SOAP::RPC::Router.new(@namespace)
|
||||||
SOAPlet.add_servant_to_router(router, obj, namespace)
|
SOAPlet.add_servant_to_router(router, obj, namespace)
|
||||||
@ -110,6 +130,12 @@ private
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def setup_request_router(namespace)
|
||||||
|
router = @router_map[namespace] || RequestRouter.new(namespace)
|
||||||
|
add_router(namespace, router)
|
||||||
|
router
|
||||||
|
end
|
||||||
|
|
||||||
def add_router(namespace, router)
|
def add_router(namespace, router)
|
||||||
@router_map[namespace] = router
|
@router_map[namespace] = router
|
||||||
end
|
end
|
||||||
@ -132,11 +158,29 @@ private
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def with_headerhandler(router)
|
||||||
|
if @app_scope_headerhandler and
|
||||||
|
!router.headerhandler.include?(@app_scope_headerhandler)
|
||||||
|
router.headerhandler.add(@app_scope_headerhandler)
|
||||||
|
end
|
||||||
|
handlers = @headerhandlerfactory.collect { |f| f.create }
|
||||||
|
begin
|
||||||
|
handlers.each { |h| router.headerhandler.add(h) }
|
||||||
|
yield(router)
|
||||||
|
ensure
|
||||||
|
handlers.each { |h| router.headerhandler.delete(h) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
public
|
public
|
||||||
def add_servant_to_router(router, obj, namespace)
|
def add_servant_to_router(router, obj, namespace)
|
||||||
::SOAP::RPC.defined_methods(obj).each do |name|
|
::SOAP::RPC.defined_methods(obj).each do |name|
|
||||||
add_servant_method_to_router(router, obj, namespace, name)
|
begin
|
||||||
|
add_servant_method_to_router(router, obj, namespace, name)
|
||||||
|
rescue SOAP::RPC::MethodDefinitionError => e
|
||||||
|
p e if $DEBUG
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -145,7 +189,7 @@ private
|
|||||||
soapaction = nil
|
soapaction = nil
|
||||||
method = obj.method(name)
|
method = obj.method(name)
|
||||||
param_def = ::SOAP::RPC::SOAPMethod.create_param_def(
|
param_def = ::SOAP::RPC::SOAPMethod.create_param_def(
|
||||||
(1..method.arity.abs).collect { |i| "p#{ i }" })
|
(1..method.arity.abs).collect { |i| "p#{ i }" })
|
||||||
router.add_method(obj, qname, soapaction, name, param_def)
|
router.add_method(obj, qname, soapaction, name, param_def)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -6,111 +6,35 @@
|
|||||||
# either the dual license version in 2003, or any later version.
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
require 'logger'
|
require 'soap/rpc/httpserver'
|
||||||
require 'soap/rpc/soaplet'
|
|
||||||
require 'soap/streamHandler'
|
|
||||||
|
|
||||||
# require 'webrick'
|
|
||||||
require 'webrick/compat.rb'
|
|
||||||
require 'webrick/version.rb'
|
|
||||||
require 'webrick/config.rb'
|
|
||||||
require 'webrick/log.rb'
|
|
||||||
require 'webrick/server.rb'
|
|
||||||
require 'webrick/utils.rb'
|
|
||||||
require 'webrick/accesslog'
|
|
||||||
# require 'webrick/htmlutils.rb'
|
|
||||||
require 'webrick/httputils.rb'
|
|
||||||
# require 'webrick/cookie.rb'
|
|
||||||
require 'webrick/httpversion.rb'
|
|
||||||
require 'webrick/httpstatus.rb'
|
|
||||||
require 'webrick/httprequest.rb'
|
|
||||||
require 'webrick/httpresponse.rb'
|
|
||||||
require 'webrick/httpserver.rb'
|
|
||||||
# require 'webrick/httpservlet.rb'
|
|
||||||
# require 'webrick/httpauth.rb'
|
|
||||||
|
|
||||||
|
|
||||||
module SOAP
|
module SOAP
|
||||||
module RPC
|
module RPC
|
||||||
|
|
||||||
|
|
||||||
class StandaloneServer < Logger::Application
|
class StandaloneServer < HTTPServer
|
||||||
attr_reader :server
|
def initialize(appname, default_namespace, host = "0.0.0.0", port = 8080)
|
||||||
|
@appname = appname
|
||||||
def initialize(app_name, namespace, host = "0.0.0.0", port = 8080)
|
@default_namespace = default_namespace
|
||||||
super(app_name)
|
|
||||||
self.level = Logger::Severity::INFO
|
|
||||||
@namespace = namespace
|
|
||||||
@host = host
|
@host = host
|
||||||
@port = port
|
@port = port
|
||||||
@server = nil
|
super(create_config)
|
||||||
@soaplet = ::SOAP::RPC::SOAPlet.new
|
|
||||||
on_init
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def on_init
|
|
||||||
# define extra methods in derived class.
|
|
||||||
end
|
|
||||||
|
|
||||||
def status
|
|
||||||
if @server
|
|
||||||
@server.status
|
|
||||||
else
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def shutdown
|
|
||||||
@server.shutdown
|
|
||||||
end
|
|
||||||
|
|
||||||
def add_rpc_request_servant(klass, namespace = @namespace, mapping_registry = nil)
|
|
||||||
@soaplet.add_rpc_request_servant(klass, namespace, mapping_registry)
|
|
||||||
end
|
|
||||||
|
|
||||||
def add_rpc_servant(obj, namespace = @namespace)
|
|
||||||
@soaplet.add_rpc_servant(obj, namespace)
|
|
||||||
end
|
|
||||||
alias add_servant add_rpc_servant
|
alias add_servant add_rpc_servant
|
||||||
|
alias add_headerhandler add_rpc_headerhandler
|
||||||
def mapping_registry
|
|
||||||
@soaplet.app_scope_router.mapping_registry
|
|
||||||
end
|
|
||||||
|
|
||||||
def mapping_registry=(mapping_registry)
|
|
||||||
@soaplet.app_scope_router.mapping_registry = mapping_registry
|
|
||||||
end
|
|
||||||
|
|
||||||
def add_method(obj, name, *param)
|
|
||||||
add_method_as(obj, name, name, *param)
|
|
||||||
end
|
|
||||||
|
|
||||||
def add_method_as(obj, name, name_as, *param)
|
|
||||||
qname = XSD::QName.new(@namespace, name_as)
|
|
||||||
soapaction = nil
|
|
||||||
method = obj.method(name)
|
|
||||||
param_def = if param.size == 1 and param[0].is_a?(Array)
|
|
||||||
param[0]
|
|
||||||
elsif param.empty?
|
|
||||||
::SOAP::RPC::SOAPMethod.create_param_def(
|
|
||||||
(1..method.arity.abs).collect { |i| "p#{ i }" })
|
|
||||||
else
|
|
||||||
SOAP::RPC::SOAPMethod.create_param_def(param)
|
|
||||||
end
|
|
||||||
@soaplet.app_scope_router.add_method(obj, qname, soapaction, name, param_def)
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def run
|
def create_config
|
||||||
@server = WEBrick::HTTPServer.new(
|
{
|
||||||
:BindAddress => @host,
|
:BindAddress => @host,
|
||||||
:Logger => @log,
|
:Port => @port,
|
||||||
:AccessLog => [],
|
:AccessLog => [],
|
||||||
:Port => @port
|
:SOAPDefaultNamespace => @default_namespace,
|
||||||
)
|
:SOAPHTTPServerApplicationName => @appname,
|
||||||
@server.mount('/', @soaplet)
|
}
|
||||||
@server.start
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# soap/soap.rb: SOAP4R - Base definitions.
|
# soap/soap.rb: SOAP4R - Base definitions.
|
||||||
# Copyright (C) 2000, 2001, 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
# Copyright (C) 2000-2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
# redistribute it and/or modify it under the same terms of Ruby's license;
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
@ -48,6 +48,7 @@ EleFaultStringName = XSD::QName.new(nil, EleFaultString)
|
|||||||
EleFaultActorName = XSD::QName.new(nil, EleFaultActor)
|
EleFaultActorName = XSD::QName.new(nil, EleFaultActor)
|
||||||
EleFaultCodeName = XSD::QName.new(nil, EleFaultCode)
|
EleFaultCodeName = XSD::QName.new(nil, EleFaultCode)
|
||||||
EleFaultDetailName = XSD::QName.new(nil, EleFaultDetail)
|
EleFaultDetailName = XSD::QName.new(nil, EleFaultDetail)
|
||||||
|
AttrMustUnderstandName = XSD::QName.new(EnvelopeNamespace, AttrMustUnderstand)
|
||||||
AttrEncodingStyleName = XSD::QName.new(EnvelopeNamespace, AttrEncodingStyle)
|
AttrEncodingStyleName = XSD::QName.new(EnvelopeNamespace, AttrEncodingStyle)
|
||||||
AttrRootName = XSD::QName.new(EncodingNamespace, AttrRoot)
|
AttrRootName = XSD::QName.new(EncodingNamespace, AttrRoot)
|
||||||
AttrArrayTypeName = XSD::QName.new(EncodingNamespace, AttrArrayType)
|
AttrArrayTypeName = XSD::QName.new(EncodingNamespace, AttrArrayType)
|
||||||
@ -75,6 +76,8 @@ class ArrayStoreError < Error; end
|
|||||||
|
|
||||||
class RPCRoutingError < Error; end
|
class RPCRoutingError < Error; end
|
||||||
|
|
||||||
|
class UnhandledMustUnderstandHeaderError < Error; end
|
||||||
|
|
||||||
class FaultError < Error
|
class FaultError < Error
|
||||||
attr_reader :faultcode
|
attr_reader :faultcode
|
||||||
attr_reader :faultstring
|
attr_reader :faultstring
|
||||||
|
@ -83,6 +83,11 @@ public
|
|||||||
@options = options
|
@options = options
|
||||||
set_options
|
set_options
|
||||||
@client.debug_dev = @wiredump_dev
|
@client.debug_dev = @wiredump_dev
|
||||||
|
@cookie_store = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_loopback_response
|
||||||
|
@client.test_loopback_response
|
||||||
end
|
end
|
||||||
|
|
||||||
def inspect
|
def inspect
|
||||||
@ -95,6 +100,7 @@ public
|
|||||||
|
|
||||||
def reset
|
def reset
|
||||||
@client.reset(@endpoint_url)
|
@client.reset(@endpoint_url)
|
||||||
|
@client.save_cookie_store if @cookie_store
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@ -118,10 +124,6 @@ private
|
|||||||
@options.add_hook("cookie_store_file") do |key, value|
|
@options.add_hook("cookie_store_file") do |key, value|
|
||||||
set_cookie_store_file(value)
|
set_cookie_store_file(value)
|
||||||
end
|
end
|
||||||
set_ssl_config(@options["ssl_config"])
|
|
||||||
@options.add_hook("ssl_config") do |key, value|
|
|
||||||
set_ssl_config(@options["ssl_config"])
|
|
||||||
end
|
|
||||||
@charset = @options["charset"] || XSD::Charset.charset_label($KCODE)
|
@charset = @options["charset"] || XSD::Charset.charset_label($KCODE)
|
||||||
@options.add_hook("charset") do |key, value|
|
@options.add_hook("charset") do |key, value|
|
||||||
@charset = value
|
@charset = value
|
||||||
@ -131,12 +133,18 @@ private
|
|||||||
@wiredump_dev = value
|
@wiredump_dev = value
|
||||||
@client.debug_dev = @wiredump_dev
|
@client.debug_dev = @wiredump_dev
|
||||||
end
|
end
|
||||||
|
ssl_config = @options["ssl_config"] ||= ::SOAP::Property.new
|
||||||
|
set_ssl_config(ssl_config)
|
||||||
|
ssl_config.add_hook(true) do |key, value|
|
||||||
|
set_ssl_config(ssl_config)
|
||||||
|
end
|
||||||
basic_auth = @options["basic_auth"] ||= ::SOAP::Property.new
|
basic_auth = @options["basic_auth"] ||= ::SOAP::Property.new
|
||||||
set_basic_auth(basic_auth)
|
set_basic_auth(basic_auth)
|
||||||
basic_auth.add_hook do |key, value|
|
basic_auth.add_hook do |key, value|
|
||||||
set_basic_auth(basic_auth)
|
set_basic_auth(basic_auth)
|
||||||
end
|
end
|
||||||
@options.lock(true)
|
@options.lock(true)
|
||||||
|
ssl_config.unlock
|
||||||
basic_auth.unlock
|
basic_auth.unlock
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -147,13 +155,62 @@ private
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_cookie_store_file(value)
|
def set_cookie_store_file(value)
|
||||||
return unless value
|
@cookie_store = value
|
||||||
raise NotImplementedError.new
|
@client.set_cookie_store(@cookie_store) if @cookie_store
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_ssl_config(value)
|
def set_ssl_config(ssl_config)
|
||||||
return unless value
|
ssl_config.each do |key, value|
|
||||||
raise NotImplementedError.new
|
cfg = @client.ssl_config
|
||||||
|
case key
|
||||||
|
when 'client_cert'
|
||||||
|
cfg.client_cert = cert_from_file(value)
|
||||||
|
when 'client_key'
|
||||||
|
cfg.client_key = key_from_file(value)
|
||||||
|
when 'client_ca'
|
||||||
|
cfg.client_ca = value
|
||||||
|
when 'ca_path'
|
||||||
|
cfg.set_trust_ca(value)
|
||||||
|
when 'ca_file'
|
||||||
|
cfg.set_trust_ca(value)
|
||||||
|
when 'crl'
|
||||||
|
cfg.set_crl(value)
|
||||||
|
when 'verify_mode'
|
||||||
|
cfg.verify_mode = ssl_config_int(value)
|
||||||
|
when 'verify_depth'
|
||||||
|
cfg.verify_depth = ssl_config_int(value)
|
||||||
|
when 'options'
|
||||||
|
cfg.options = value
|
||||||
|
when 'ciphers'
|
||||||
|
cfg.ciphers = value
|
||||||
|
when 'verify_callback'
|
||||||
|
cfg.verify_callback = value
|
||||||
|
when 'cert_store'
|
||||||
|
cfg.cert_store = value
|
||||||
|
else
|
||||||
|
raise ArgumentError.new("unknown ssl_config property #{key}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def ssl_config_int(value)
|
||||||
|
if value.nil? or value.empty?
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
Integer(value)
|
||||||
|
rescue ArgumentError
|
||||||
|
::SOAP::Property::Util.const_from_name(value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def cert_from_file(filename)
|
||||||
|
OpenSSL::X509::Certificate.new(File.open(filename) { |f| f.read })
|
||||||
|
end
|
||||||
|
|
||||||
|
def key_from_file(filename)
|
||||||
|
OpenSSL::PKey::RSA.new(File.open(filename) { |f| f.read })
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_post(conn_data, soapaction, charset)
|
def send_post(conn_data, soapaction, charset)
|
||||||
|
@ -18,6 +18,7 @@ require 'soap/mapping/wsdlRegistry'
|
|||||||
require 'soap/rpc/rpc'
|
require 'soap/rpc/rpc'
|
||||||
require 'soap/rpc/element'
|
require 'soap/rpc/element'
|
||||||
require 'soap/processor'
|
require 'soap/processor'
|
||||||
|
require 'soap/header/handlerset'
|
||||||
require 'logger'
|
require 'logger'
|
||||||
|
|
||||||
|
|
||||||
@ -92,6 +93,8 @@ class WSDLDriver
|
|||||||
end
|
end
|
||||||
|
|
||||||
__attr_proxy :options
|
__attr_proxy :options
|
||||||
|
__attr_proxy :headerhandler
|
||||||
|
__attr_proxy :test_loopback_response
|
||||||
__attr_proxy :endpoint_url, true
|
__attr_proxy :endpoint_url, true
|
||||||
__attr_proxy :mapping_registry, true # for RPC unmarshal
|
__attr_proxy :mapping_registry, true # for RPC unmarshal
|
||||||
__attr_proxy :wsdl_mapping_registry, true # for RPC marshal
|
__attr_proxy :wsdl_mapping_registry, true # for RPC marshal
|
||||||
@ -152,6 +155,7 @@ class WSDLDriver
|
|||||||
|
|
||||||
attr_reader :options
|
attr_reader :options
|
||||||
attr_reader :streamhandler
|
attr_reader :streamhandler
|
||||||
|
attr_reader :headerhandler
|
||||||
attr_reader :port
|
attr_reader :port
|
||||||
|
|
||||||
attr_accessor :mapping_registry
|
attr_accessor :mapping_registry
|
||||||
@ -176,7 +180,7 @@ class WSDLDriver
|
|||||||
@mandatorycharset = nil
|
@mandatorycharset = nil
|
||||||
|
|
||||||
@wsdl_elements = @wsdl.collect_elements
|
@wsdl_elements = @wsdl.collect_elements
|
||||||
@wsdl_types = @wsdl.collect_complextypes
|
@wsdl_types = @wsdl.collect_complextypes + @wsdl.collect_simpletypes
|
||||||
@rpc_decode_typemap = @wsdl_types +
|
@rpc_decode_typemap = @wsdl_types +
|
||||||
@wsdl.soap_rpc_complextypes(port.find_binding)
|
@wsdl.soap_rpc_complextypes(port.find_binding)
|
||||||
@wsdl_mapping_registry = Mapping::WSDLRegistry.new(@rpc_decode_typemap)
|
@wsdl_mapping_registry = Mapping::WSDLRegistry.new(@rpc_decode_typemap)
|
||||||
@ -184,6 +188,7 @@ class WSDLDriver
|
|||||||
endpoint_url = @port.soap_address.location
|
endpoint_url = @port.soap_address.location
|
||||||
@streamhandler = HTTPPostStreamHandler.new(endpoint_url,
|
@streamhandler = HTTPPostStreamHandler.new(endpoint_url,
|
||||||
@options["protocol.http"] ||= Property.new)
|
@options["protocol.http"] ||= Property.new)
|
||||||
|
@headerhandler = Header::HandlerSet.new
|
||||||
# Convert a map which key is QName, to a Hash which key is String.
|
# Convert a map which key is QName, to a Hash which key is String.
|
||||||
@operations = {}
|
@operations = {}
|
||||||
@port.inputoperation_map.each do |op_name, op_info|
|
@port.inputoperation_map.each do |op_name, op_info|
|
||||||
@ -201,13 +206,17 @@ class WSDLDriver
|
|||||||
@streamhandler.reset
|
@streamhandler.reset
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_loopback_response
|
||||||
|
@streamhandler.test_loopback_response
|
||||||
|
end
|
||||||
|
|
||||||
def rpc_send(method_name, *params)
|
def rpc_send(method_name, *params)
|
||||||
log(INFO) { "call: calling method '#{ method_name }'." }
|
log(INFO) { "call: calling method '#{ method_name }'." }
|
||||||
log(DEBUG) { "call: parameters '#{ params.inspect }'." }
|
log(DEBUG) { "call: parameters '#{ params.inspect }'." }
|
||||||
|
|
||||||
op_info = @operations[method_name]
|
op_info = @operations[method_name]
|
||||||
method = create_method_struct(op_info, params)
|
method = create_method_struct(op_info, params)
|
||||||
req_header = nil
|
req_header = call_headers
|
||||||
req_body = SOAPBody.new(method)
|
req_body = SOAPBody.new(method)
|
||||||
req_env = SOAPEnvelope.new(req_header, req_body)
|
req_env = SOAPEnvelope.new(req_header, req_body)
|
||||||
|
|
||||||
@ -220,10 +229,11 @@ class WSDLDriver
|
|||||||
opt = create_options
|
opt = create_options
|
||||||
opt[:decode_typemap] = @rpc_decode_typemap
|
opt[:decode_typemap] = @rpc_decode_typemap
|
||||||
res_env = invoke(req_env, op_info, opt)
|
res_env = invoke(req_env, op_info, opt)
|
||||||
|
receive_headers(res_env.header)
|
||||||
if res_env.body.fault
|
if res_env.body.fault
|
||||||
raise SOAP::FaultError.new(res_env.body.fault)
|
raise ::SOAP::FaultError.new(res_env.body.fault)
|
||||||
end
|
end
|
||||||
rescue SOAP::FaultError => e
|
rescue ::SOAP::FaultError => e
|
||||||
Mapping.fault2exception(e)
|
Mapping.fault2exception(e)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -251,7 +261,7 @@ class WSDLDriver
|
|||||||
opt = create_options
|
opt = create_options
|
||||||
res_env = invoke(req_env, op_info, opt)
|
res_env = invoke(req_env, op_info, opt)
|
||||||
if res_env.body.fault
|
if res_env.body.fault
|
||||||
raise SOAP::FaultError.new(res_env.body.fault)
|
raise ::SOAP::FaultError.new(res_env.body.fault)
|
||||||
end
|
end
|
||||||
res_body_obj = res_env.body.response ?
|
res_body_obj = res_env.body.response ?
|
||||||
Mapping.soap2obj(res_env.body.response, @mapping_registry) : nil
|
Mapping.soap2obj(res_env.body.response, @mapping_registry) : nil
|
||||||
@ -260,6 +270,23 @@ class WSDLDriver
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def call_headers
|
||||||
|
headers = @headerhandler.on_outbound
|
||||||
|
if headers.empty?
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
h = ::SOAP::SOAPHeader.new
|
||||||
|
headers.each do |header|
|
||||||
|
h.add(header.elename.name, header)
|
||||||
|
end
|
||||||
|
h
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def receive_headers(headers)
|
||||||
|
@headerhandler.on_inbound(headers) if headers
|
||||||
|
end
|
||||||
|
|
||||||
def create_method_struct(op_info, params)
|
def create_method_struct(op_info, params)
|
||||||
parts_names = op_info.bodyparts.collect { |part| part.name }
|
parts_names = op_info.bodyparts.collect { |part| part.name }
|
||||||
obj = create_method_obj(parts_names, params)
|
obj = create_method_obj(parts_names, params)
|
||||||
@ -349,9 +376,9 @@ class WSDLDriver
|
|||||||
else
|
else
|
||||||
header = SOAPHeader.new()
|
header = SOAPHeader.new()
|
||||||
op_info.headerparts.each do |part|
|
op_info.headerparts.each do |part|
|
||||||
child = obj[part.elename.name]
|
child = Mapper.find_attribute(obj, part.name)
|
||||||
ele = headeritem_from_obj(child, part.element || part.eletype)
|
ele = headeritem_from_obj(child, part.element || part.eletype)
|
||||||
header.add(ele)
|
header.add(part.name, ele)
|
||||||
end
|
end
|
||||||
header
|
header
|
||||||
end
|
end
|
||||||
@ -383,7 +410,7 @@ class WSDLDriver
|
|||||||
else
|
else
|
||||||
body = SOAPBody.new
|
body = SOAPBody.new
|
||||||
op_info.bodyparts.each do |part|
|
op_info.bodyparts.each do |part|
|
||||||
child = obj[part.elename.name]
|
child = Mapper.find_attribute(obj, part.name)
|
||||||
ele = bodyitem_from_obj(child, part.element || part.type)
|
ele = bodyitem_from_obj(child, part.element || part.type)
|
||||||
body.add(ele.elename.name, ele)
|
body.add(ele.elename.name, ele)
|
||||||
end
|
end
|
||||||
@ -461,6 +488,7 @@ class WSDLDriver
|
|||||||
opt
|
opt
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class MappingError < StandardError; end
|
||||||
class Mapper
|
class Mapper
|
||||||
def initialize(elements, types)
|
def initialize(elements, types)
|
||||||
@elements = elements
|
@elements = elements
|
||||||
@ -473,7 +501,7 @@ class WSDLDriver
|
|||||||
elsif type = @types[name]
|
elsif type = @types[name]
|
||||||
obj2type(obj, type)
|
obj2type(obj, type)
|
||||||
else
|
else
|
||||||
raise RuntimeError.new("Cannot find name #{name} in schema.")
|
raise MappingError.new("Cannot find name #{name} in schema.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -481,6 +509,16 @@ class WSDLDriver
|
|||||||
raise NotImplementedError.new
|
raise NotImplementedError.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def Mapper.find_attribute(obj, attr_name)
|
||||||
|
if obj.respond_to?(attr_name)
|
||||||
|
obj.__send__(attr_name)
|
||||||
|
elsif obj.is_a?(Hash)
|
||||||
|
obj[attr_name] || obj[attr_name.intern]
|
||||||
|
else
|
||||||
|
obj.instance_eval("@#{ attr_name }")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def _obj2ele(obj, ele)
|
def _obj2ele(obj, ele)
|
||||||
@ -491,25 +529,47 @@ class WSDLDriver
|
|||||||
elsif type = TypeMap[ele.type]
|
elsif type = TypeMap[ele.type]
|
||||||
o = base2soap(obj, type)
|
o = base2soap(obj, type)
|
||||||
else
|
else
|
||||||
raise RuntimeError.new("Cannot find type #{ele.type}.")
|
raise MappingError.new("Cannot find type #{ele.type}.")
|
||||||
end
|
end
|
||||||
o.elename = ele.name
|
o.elename = ele.name
|
||||||
elsif ele.local_complextype
|
elsif ele.local_complextype
|
||||||
o = SOAPElement.new(ele.name)
|
o = SOAPElement.new(ele.name)
|
||||||
ele.local_complextype.each_element do |child_name, child_ele|
|
ele.local_complextype.each_element do |child_ele|
|
||||||
o.add(_obj2ele(find_attribute(obj, child_name.name), child_ele))
|
o.add(_obj2ele(Mapper.find_attribute(obj, child_ele.name.name),
|
||||||
|
child_ele))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
raise RuntimeError.new("Illegal schema?")
|
raise MappingError.new("Illegal schema?")
|
||||||
end
|
end
|
||||||
o
|
o
|
||||||
end
|
end
|
||||||
|
|
||||||
def obj2type(obj, type)
|
def obj2type(obj, type)
|
||||||
o = SOAPElement.new(type.name)
|
if type.is_a?(::WSDL::XMLSchema::SimpleType)
|
||||||
type.each_element do |child_name, child_ele|
|
simple2soap(obj, type)
|
||||||
o.add(_obj2ele(find_attribute(obj, child_name.name), child_ele))
|
else
|
||||||
end
|
complex2soap(obj, type)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def simple2soap(obj, type)
|
||||||
|
o = base2soap(obj, TypeMap[type.base])
|
||||||
|
if type.restriction.enumeration.empty?
|
||||||
|
STDERR.puts("#{type.name}: simpleType which is not enum type not supported.")
|
||||||
|
return o
|
||||||
|
end
|
||||||
|
if type.restriction.enumeration.include?(o)
|
||||||
|
raise MappingError.new("#{o} is not allowed for #{type.name}")
|
||||||
|
end
|
||||||
|
o
|
||||||
|
end
|
||||||
|
|
||||||
|
def complex2soap(obj, type)
|
||||||
|
o = SOAPElement.new(type.name)
|
||||||
|
type.each_element do |child_ele|
|
||||||
|
o.add(_obj2ele(Mapper.find_attribute(obj, child_ele.name.name),
|
||||||
|
child_ele))
|
||||||
|
end
|
||||||
o
|
o
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -521,22 +581,13 @@ class WSDLDriver
|
|||||||
soap_obj = nil
|
soap_obj = nil
|
||||||
if type <= XSD::XSDString
|
if type <= XSD::XSDString
|
||||||
soap_obj = type.new(XSD::Charset.is_ces(obj, $KCODE) ?
|
soap_obj = type.new(XSD::Charset.is_ces(obj, $KCODE) ?
|
||||||
XSD::Charset.encoding_conv(obj, $KCODE, XSD::Charset.encoding) : obj)
|
XSD::Charset.encoding_conv(obj, $KCODE, XSD::Charset.encoding) :
|
||||||
|
obj)
|
||||||
else
|
else
|
||||||
soap_obj = type.new(obj)
|
soap_obj = type.new(obj)
|
||||||
end
|
end
|
||||||
soap_obj
|
soap_obj
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_attribute(obj, attr_name)
|
|
||||||
if obj.respond_to?(attr_name)
|
|
||||||
obj.__send__(attr_name)
|
|
||||||
elsif obj.is_a?(Hash)
|
|
||||||
obj[attr_name] || obj[attr_name.intern]
|
|
||||||
else
|
|
||||||
obj.instance_eval("@#{ attr_name }")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
# either the dual license version in 2003, or any later version.
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'xsd/qname'
|
||||||
require 'wsdl/documentation'
|
require 'wsdl/documentation'
|
||||||
require 'wsdl/definitions'
|
require 'wsdl/definitions'
|
||||||
require 'wsdl/types'
|
require 'wsdl/types'
|
||||||
|
@ -43,8 +43,7 @@ class Definitions < Info
|
|||||||
end
|
end
|
||||||
|
|
||||||
def inspect
|
def inspect
|
||||||
name = @name || '(unnamed)'
|
sprintf("#<%s:0x%x %s>", self.class.name, __id__, @name || '(unnamed)')
|
||||||
"#<#{self.class}:#{name}>"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def targetnamespace=(targetnamespace)
|
def targetnamespace=(targetnamespace)
|
||||||
@ -58,7 +57,7 @@ class Definitions < Info
|
|||||||
result = XSD::NamedElements.new
|
result = XSD::NamedElements.new
|
||||||
if @types
|
if @types
|
||||||
@types.schemas.each do |schema|
|
@types.schemas.each do |schema|
|
||||||
result.concat(schema.elements)
|
result.concat(schema.collect_elements)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@imports.each do |import|
|
@imports.each do |import|
|
||||||
@ -71,7 +70,7 @@ class Definitions < Info
|
|||||||
result = @anontypes.dup
|
result = @anontypes.dup
|
||||||
if @types
|
if @types
|
||||||
@types.schemas.each do |schema|
|
@types.schemas.each do |schema|
|
||||||
result.concat(schema.complextypes)
|
result.concat(schema.collect_complextypes)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@imports.each do |import|
|
@imports.each do |import|
|
||||||
@ -80,6 +79,20 @@ class Definitions < Info
|
|||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def collect_simpletypes
|
||||||
|
result = XSD::NamedElements.new
|
||||||
|
if @types
|
||||||
|
@types.schemas.each do |schema|
|
||||||
|
result.concat(schema.collect_simpletypes)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@imports.each do |import|
|
||||||
|
result.concat(import.content.collect_simpletypes)
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
# ToDo: simpletype must be accepted...
|
||||||
def add_type(complextype)
|
def add_type(complextype)
|
||||||
@anontypes << complextype
|
@anontypes << complextype
|
||||||
end
|
end
|
||||||
|
@ -119,7 +119,7 @@ private
|
|||||||
return parts.dup
|
return parts.dup
|
||||||
end
|
end
|
||||||
if parts.length != result.length
|
if parts.length != result.length
|
||||||
raise RuntimeError.new("Incomplete parameter order list.")
|
raise RuntimeError.new("Incomplete prarmeterOrder list.")
|
||||||
end
|
end
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
@ -119,7 +119,8 @@ private
|
|||||||
STDERR.puts("Unknown element #{ element }.")
|
STDERR.puts("Unknown element #{ element }.")
|
||||||
o = Documentation.new # which accepts any element.
|
o = Documentation.new # which accepts any element.
|
||||||
end
|
end
|
||||||
o.parent = parent
|
# node could be a pseudo element. pseudo element has its own parent.
|
||||||
|
o.parent = parent if o.parent.nil?
|
||||||
end
|
end
|
||||||
attrs.each do |key, value|
|
attrs.each do |key, value|
|
||||||
attr = unless /:/ =~ key
|
attr = unless /:/ =~ key
|
||||||
|
73
lib/wsdl/soap/cgiStubCreator.rb
Normal file
73
lib/wsdl/soap/cgiStubCreator.rb
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
# WSDL4R - Creating CGI stub code from WSDL.
|
||||||
|
# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'wsdl/info'
|
||||||
|
require 'wsdl/soap/mappingRegistryCreator'
|
||||||
|
require 'wsdl/soap/methodDefCreator'
|
||||||
|
require 'wsdl/soap/classDefCreatorSupport'
|
||||||
|
|
||||||
|
|
||||||
|
module WSDL
|
||||||
|
module SOAP
|
||||||
|
|
||||||
|
|
||||||
|
class CGIStubCreator
|
||||||
|
include ClassDefCreatorSupport
|
||||||
|
|
||||||
|
attr_reader :definitions
|
||||||
|
|
||||||
|
def initialize(definitions)
|
||||||
|
@definitions = definitions
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump(service_name)
|
||||||
|
STDERR.puts "!!! IMPORTANT !!!"
|
||||||
|
STDERR.puts "- CGI stub can only 1 port. Creating stub for the first port... Rests are ignored."
|
||||||
|
STDERR.puts "!!! IMPORTANT !!!"
|
||||||
|
port = @definitions.service(service_name).ports[0]
|
||||||
|
dump_porttype(port.porttype.name)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def dump_porttype(name)
|
||||||
|
class_name = create_class_name(name)
|
||||||
|
methoddef, types = MethodDefCreator.new(@definitions).dump(name)
|
||||||
|
mr_creator = MappingRegistryCreator.new(@definitions)
|
||||||
|
c1 = ::XSD::CodeGen::ClassDef.new(class_name)
|
||||||
|
c1.def_require("soap/rpc/cgistub")
|
||||||
|
c1.def_require("soap/mapping/registry")
|
||||||
|
c1.def_const("MappingRegistry", "::SOAP::Mapping::Registry.new")
|
||||||
|
c1.def_code(mr_creator.dump(types))
|
||||||
|
c1.def_code <<-EOD
|
||||||
|
Methods = [
|
||||||
|
#{ methoddef.gsub(/^/, " ") }
|
||||||
|
]
|
||||||
|
EOD
|
||||||
|
c2 = ::XSD::CodeGen::ClassDef.new(class_name + "App",
|
||||||
|
"::SOAP::RPC::CGIStub")
|
||||||
|
c2.def_method("initialize", "*arg") do
|
||||||
|
<<-EOD
|
||||||
|
super(*arg)
|
||||||
|
servant = #{class_name}.new
|
||||||
|
#{class_name}::Methods.each do |name_as, name, params, soapaction, ns|
|
||||||
|
add_method_with_namespace_as(ns, servant, name, name_as, params, soapaction)
|
||||||
|
end
|
||||||
|
self.mapping_registry = #{class_name}::MappingRegistry
|
||||||
|
self.level = Logger::Severity::ERROR
|
||||||
|
EOD
|
||||||
|
end
|
||||||
|
c1.dump + "\n" + c2.dump + format(<<-EOD)
|
||||||
|
#{class_name}App.new('app', nil).start
|
||||||
|
EOD
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
112
lib/wsdl/soap/classDefCreator.rb
Normal file
112
lib/wsdl/soap/classDefCreator.rb
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
# WSDL4R - Creating class definition from WSDL
|
||||||
|
# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'wsdl/data'
|
||||||
|
require 'wsdl/soap/classDefCreatorSupport'
|
||||||
|
require 'xsd/codegen'
|
||||||
|
|
||||||
|
|
||||||
|
module WSDL
|
||||||
|
module SOAP
|
||||||
|
|
||||||
|
|
||||||
|
class ClassDefCreator
|
||||||
|
include ClassDefCreatorSupport
|
||||||
|
|
||||||
|
def initialize(definitions)
|
||||||
|
@simpletypes = definitions.collect_simpletypes
|
||||||
|
@complextypes = definitions.collect_complextypes
|
||||||
|
@faulttypes = definitions.collect_faulttypes
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump(class_name = nil)
|
||||||
|
result = ""
|
||||||
|
if class_name
|
||||||
|
result = dump_classdef(class_name)
|
||||||
|
else
|
||||||
|
@complextypes.each do |type|
|
||||||
|
case type.compoundtype
|
||||||
|
when :TYPE_STRUCT
|
||||||
|
result << dump_classdef(type)
|
||||||
|
when :TYPE_ARRAY
|
||||||
|
result << dump_arraydef(type)
|
||||||
|
else
|
||||||
|
raise RuntimeError.new("Unknown complexContent definition...")
|
||||||
|
end
|
||||||
|
result << "\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
result << @simpletypes.collect { |type|
|
||||||
|
dump_simpletypedef(type)
|
||||||
|
}.join("\n")
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def dump_simpletypedef(simpletype)
|
||||||
|
qname = simpletype.name
|
||||||
|
if simpletype.restriction.enumeration.empty?
|
||||||
|
STDERR.puts("#{qname}: simpleType which is not enum type not supported.")
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
c = XSD::CodeGen::ModuleDef.new(create_class_name(qname))
|
||||||
|
c.comment = "#{ qname.namespace }"
|
||||||
|
simpletype.restriction.enumeration.each do |value|
|
||||||
|
c.def_const(safeconstname(value), value.dump)
|
||||||
|
end
|
||||||
|
c.dump
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_classdef(complextype)
|
||||||
|
qname = complextype.name
|
||||||
|
if @faulttypes.index(qname)
|
||||||
|
c = XSD::CodeGen::ClassDef.new(create_class_name(qname),
|
||||||
|
"::StandardError")
|
||||||
|
else
|
||||||
|
c = XSD::CodeGen::ClassDef.new(create_class_name(qname))
|
||||||
|
end
|
||||||
|
c.comment = "#{ qname.namespace }"
|
||||||
|
c.def_classvar("schema_type", qname.name.dump)
|
||||||
|
c.def_classvar("schema_ns", qname.namespace.dump)
|
||||||
|
init_lines = ""
|
||||||
|
params = []
|
||||||
|
complextype.each_element do |element|
|
||||||
|
name = element.name.name
|
||||||
|
varname = safevarname(name)
|
||||||
|
c.def_attr(name, true, varname)
|
||||||
|
init_lines << "@#{ varname } = #{ varname }\n"
|
||||||
|
params << "#{ varname } = nil"
|
||||||
|
end
|
||||||
|
complextype.attributes.each do |attribute|
|
||||||
|
name = "attr_" + attribute.name
|
||||||
|
varname = safevarname(name)
|
||||||
|
c.def_attr(name, true, varname)
|
||||||
|
init_lines << "@#{ varname } = #{ varname }\n"
|
||||||
|
params << "#{ varname } = nil"
|
||||||
|
end
|
||||||
|
c.def_method("initialize", *params) do
|
||||||
|
init_lines
|
||||||
|
end
|
||||||
|
c.dump
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_arraydef(complextype)
|
||||||
|
qname = complextype.name
|
||||||
|
c = XSD::CodeGen::ClassDef.new(create_class_name(qname), "::Array")
|
||||||
|
c.comment = "#{ qname.namespace }"
|
||||||
|
c.def_classvar("schema_type", qname.name.dump)
|
||||||
|
c.def_classvar("schema_ns", qname.namespace.dump)
|
||||||
|
c.dump
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
106
lib/wsdl/soap/classDefCreatorSupport.rb
Normal file
106
lib/wsdl/soap/classDefCreatorSupport.rb
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
# WSDL4R - Creating class code support from WSDL.
|
||||||
|
# Copyright (C) 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'wsdl/info'
|
||||||
|
require 'soap/mapping'
|
||||||
|
require 'soap/mapping/typeMap'
|
||||||
|
require 'xsd/codegen/gensupport'
|
||||||
|
|
||||||
|
|
||||||
|
module WSDL
|
||||||
|
module SOAP
|
||||||
|
|
||||||
|
|
||||||
|
module ClassDefCreatorSupport
|
||||||
|
include XSD::CodeGen::GenSupport
|
||||||
|
|
||||||
|
def create_class_name(qname)
|
||||||
|
if klass = basetype_mapped_class(qname)
|
||||||
|
::SOAP::Mapping::DefaultRegistry.find_mapped_obj_class(klass.name)
|
||||||
|
else
|
||||||
|
safeconstname(qname.name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def basetype_mapped_class(name)
|
||||||
|
::SOAP::TypeMap[name]
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_method_signature(operation)
|
||||||
|
name = operation.name.name
|
||||||
|
input = operation.input
|
||||||
|
output = operation.output
|
||||||
|
fault = operation.fault
|
||||||
|
signature = "#{ name }#{ dump_inputparam(input) }"
|
||||||
|
str = <<__EOD__
|
||||||
|
# SYNOPSIS
|
||||||
|
# #{name}#{dump_inputparam(input)}
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
#{dump_inout_type(input).chomp}
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
#{dump_inout_type(output).chomp}
|
||||||
|
#
|
||||||
|
__EOD__
|
||||||
|
unless fault.empty?
|
||||||
|
faultstr = (fault.collect { |f| dump_inout_type(f).chomp }).join(', ')
|
||||||
|
str <<<<__EOD__
|
||||||
|
# RAISES
|
||||||
|
# #{faultstr}
|
||||||
|
#
|
||||||
|
__EOD__
|
||||||
|
end
|
||||||
|
str
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def dump_inout_type(param)
|
||||||
|
if param
|
||||||
|
message = param.find_message
|
||||||
|
params = ""
|
||||||
|
message.parts.each do |part|
|
||||||
|
next unless part.type
|
||||||
|
name = safevarname(part.name)
|
||||||
|
typename = safeconstname(part.type.name)
|
||||||
|
params << add_at("# #{name}", "#{typename} - #{part.type}\n", 20)
|
||||||
|
end
|
||||||
|
unless params.empty?
|
||||||
|
return params
|
||||||
|
end
|
||||||
|
end
|
||||||
|
"# N/A\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_inputparam(input)
|
||||||
|
message = input.find_message
|
||||||
|
params = ""
|
||||||
|
message.parts.each do |part|
|
||||||
|
params << ", " unless params.empty?
|
||||||
|
params << safevarname(part.name)
|
||||||
|
end
|
||||||
|
if params.empty?
|
||||||
|
""
|
||||||
|
else
|
||||||
|
"(#{ params })"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_at(base, str, pos)
|
||||||
|
if base.size >= pos
|
||||||
|
base + ' ' + str
|
||||||
|
else
|
||||||
|
base + ' ' * (pos - base.size) + str
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
78
lib/wsdl/soap/clientSkeltonCreator.rb
Normal file
78
lib/wsdl/soap/clientSkeltonCreator.rb
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
# WSDL4R - Creating client skelton code from WSDL.
|
||||||
|
# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'wsdl/info'
|
||||||
|
require 'wsdl/soap/classDefCreatorSupport'
|
||||||
|
|
||||||
|
|
||||||
|
module WSDL
|
||||||
|
module SOAP
|
||||||
|
|
||||||
|
|
||||||
|
class ClientSkeltonCreator
|
||||||
|
include ClassDefCreatorSupport
|
||||||
|
|
||||||
|
attr_reader :definitions
|
||||||
|
|
||||||
|
def initialize(definitions)
|
||||||
|
@definitions = definitions
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump(service_name)
|
||||||
|
result = ""
|
||||||
|
@definitions.service(service_name).ports.each do |port|
|
||||||
|
result << dump_porttype(port.porttype.name)
|
||||||
|
result << "\n"
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def dump_porttype(name)
|
||||||
|
drv_name = create_class_name(name)
|
||||||
|
|
||||||
|
result = ""
|
||||||
|
result << <<__EOD__
|
||||||
|
endpoint_url = ARGV.shift
|
||||||
|
obj = #{ drv_name }.new(endpoint_url)
|
||||||
|
|
||||||
|
# Uncomment the below line to see SOAP wiredumps.
|
||||||
|
# obj.wiredump_dev = STDERR
|
||||||
|
|
||||||
|
__EOD__
|
||||||
|
@definitions.porttype(name).operations.each do |operation|
|
||||||
|
result << dump_method_signature(operation)
|
||||||
|
result << dump_input_init(operation.input) << "\n"
|
||||||
|
result << dump_operation(operation) << "\n\n"
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_operation(operation)
|
||||||
|
name = operation.name
|
||||||
|
input = operation.input
|
||||||
|
"puts obj.#{ safemethodname(name.name) }#{ dump_inputparam(input) }"
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_input_init(input)
|
||||||
|
result = input.find_message.parts.collect { |part|
|
||||||
|
"#{ uncapitalize(part.name) }"
|
||||||
|
}.join(" = ")
|
||||||
|
if result.empty?
|
||||||
|
""
|
||||||
|
else
|
||||||
|
result << " = nil"
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
@ -75,8 +75,36 @@ class Definitions < Info
|
|||||||
types + self.class.soap_rpc_complextypes
|
types + self.class.soap_rpc_complextypes
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def collect_faulttypes
|
||||||
|
result = []
|
||||||
|
collect_fault_messages.each do |message|
|
||||||
|
parts = message(message).parts
|
||||||
|
if parts.size != 1
|
||||||
|
raise RuntimeError.new("Expecting fault message to have only 1 part.")
|
||||||
|
end
|
||||||
|
if result.index(parts[0].type).nil?
|
||||||
|
result << parts[0].type
|
||||||
|
end
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def collect_fault_messages
|
||||||
|
result = []
|
||||||
|
porttypes.each do |porttype|
|
||||||
|
porttype.operations.each do |operation|
|
||||||
|
operation.fault.each do |fault|
|
||||||
|
if result.index(fault.message).nil?
|
||||||
|
result << fault.message
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
def rpc_operation_complextypes(binding)
|
def rpc_operation_complextypes(binding)
|
||||||
types = XSD::NamedElements.new
|
types = XSD::NamedElements.new
|
||||||
binding.operations.each do |op_bind|
|
binding.operations.each do |op_bind|
|
||||||
|
84
lib/wsdl/soap/driverCreator.rb
Normal file
84
lib/wsdl/soap/driverCreator.rb
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
# WSDL4R - Creating driver code from WSDL.
|
||||||
|
# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'wsdl/info'
|
||||||
|
require 'wsdl/soap/mappingRegistryCreator'
|
||||||
|
require 'wsdl/soap/methodDefCreator'
|
||||||
|
require 'wsdl/soap/classDefCreatorSupport'
|
||||||
|
require 'xsd/codegen'
|
||||||
|
|
||||||
|
|
||||||
|
module WSDL
|
||||||
|
module SOAP
|
||||||
|
|
||||||
|
|
||||||
|
class DriverCreator
|
||||||
|
include ClassDefCreatorSupport
|
||||||
|
|
||||||
|
attr_reader :definitions
|
||||||
|
|
||||||
|
def initialize(definitions)
|
||||||
|
@definitions = definitions
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump(porttype = nil)
|
||||||
|
if porttype.nil?
|
||||||
|
result = ""
|
||||||
|
@definitions.porttypes.each do |type|
|
||||||
|
result << dump_porttype(type.name)
|
||||||
|
result << "\n"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
result = dump_porttype(porttype)
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def dump_porttype(name)
|
||||||
|
class_name = create_class_name(name)
|
||||||
|
methoddef, types = MethodDefCreator.new(@definitions).dump(name)
|
||||||
|
mr_creator = MappingRegistryCreator.new(@definitions)
|
||||||
|
binding = @definitions.bindings.find { |item| item.type == name }
|
||||||
|
addresses = @definitions.porttype(name).locations
|
||||||
|
|
||||||
|
c = ::XSD::CodeGen::ClassDef.new(class_name, "::SOAP::RPC::Driver")
|
||||||
|
c.def_require("soap/rpc/driver")
|
||||||
|
c.def_const("MappingRegistry", "::SOAP::Mapping::Registry.new")
|
||||||
|
c.def_const("DefaultEndpointUrl", addresses[0].dump)
|
||||||
|
c.def_code(mr_creator.dump(types))
|
||||||
|
c.def_code <<-EOD
|
||||||
|
Methods = [
|
||||||
|
#{ methoddef.gsub(/^/, " ") }
|
||||||
|
]
|
||||||
|
EOD
|
||||||
|
c.def_method("initialize", "endpoint_url = nil") do
|
||||||
|
<<-EOD
|
||||||
|
endpoint_url ||= DefaultEndpointUrl
|
||||||
|
super(endpoint_url, nil)
|
||||||
|
self.mapping_registry = MappingRegistry
|
||||||
|
init_methods
|
||||||
|
EOD
|
||||||
|
end
|
||||||
|
c.def_privatemethod("init_methods") do
|
||||||
|
<<-EOD
|
||||||
|
Methods.each do |name_as, name, params, soapaction, namespace|
|
||||||
|
qname = ::XSD::QName.new(namespace, name_as)
|
||||||
|
@proxy.add_method(qname, soapaction, name, params)
|
||||||
|
add_rpc_method_interface(name, params)
|
||||||
|
end
|
||||||
|
EOD
|
||||||
|
end
|
||||||
|
c.dump
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
90
lib/wsdl/soap/mappingRegistryCreator.rb
Normal file
90
lib/wsdl/soap/mappingRegistryCreator.rb
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
# WSDL4R - Creating MappingRegistry code from WSDL.
|
||||||
|
# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'wsdl/info'
|
||||||
|
require 'wsdl/soap/classDefCreatorSupport'
|
||||||
|
|
||||||
|
|
||||||
|
module WSDL
|
||||||
|
module SOAP
|
||||||
|
|
||||||
|
|
||||||
|
class MappingRegistryCreator
|
||||||
|
include ClassDefCreatorSupport
|
||||||
|
|
||||||
|
attr_reader :definitions
|
||||||
|
|
||||||
|
def initialize(definitions)
|
||||||
|
@definitions = definitions
|
||||||
|
@complextypes = @definitions.collect_complextypes
|
||||||
|
@types = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump(types)
|
||||||
|
@types = types
|
||||||
|
map_cache = []
|
||||||
|
map = ""
|
||||||
|
@types.each do |type|
|
||||||
|
if map_cache.index(type).nil?
|
||||||
|
map_cache << type
|
||||||
|
if type.namespace != XSD::Namespace
|
||||||
|
if typemap = dump_typemap(type)
|
||||||
|
map << typemap
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return map
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def dump_typemap(type)
|
||||||
|
if definedtype = @complextypes[type]
|
||||||
|
case definedtype.compoundtype
|
||||||
|
when :TYPE_STRUCT
|
||||||
|
dump_struct_typemap(definedtype)
|
||||||
|
when :TYPE_ARRAY
|
||||||
|
dump_array_typemap(definedtype)
|
||||||
|
else
|
||||||
|
raise NotImplementedError.new("Must not reach here.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_struct_typemap(definedtype)
|
||||||
|
ele = definedtype.name
|
||||||
|
return <<__EOD__
|
||||||
|
MappingRegistry.set(
|
||||||
|
#{ create_class_name(ele) },
|
||||||
|
::SOAP::SOAPStruct,
|
||||||
|
::SOAP::Mapping::Registry::TypedStructFactory,
|
||||||
|
{ :type => ::XSD::QName.new("#{ ele.namespace }", "#{ ele.name }") }
|
||||||
|
)
|
||||||
|
__EOD__
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_array_typemap(definedtype)
|
||||||
|
ele = definedtype.name
|
||||||
|
arytype = definedtype.find_arytype || XSD::AnyTypeName
|
||||||
|
type = XSD::QName.new(arytype.namespace, arytype.name.sub(/\[(?:,)*\]$/, ''))
|
||||||
|
@types << type
|
||||||
|
return <<__EOD__
|
||||||
|
MappingRegistry.set(
|
||||||
|
#{ create_class_name(ele) },
|
||||||
|
::SOAP::SOAPArray,
|
||||||
|
::SOAP::Mapping::Registry::TypedArrayFactory,
|
||||||
|
{ :type => ::XSD::QName.new("#{ type.namespace }", "#{ type.name }") }
|
||||||
|
)
|
||||||
|
__EOD__
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
148
lib/wsdl/soap/methodDefCreator.rb
Normal file
148
lib/wsdl/soap/methodDefCreator.rb
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
# WSDL4R - Creating driver code from WSDL.
|
||||||
|
# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'wsdl/info'
|
||||||
|
require 'wsdl/soap/classDefCreatorSupport'
|
||||||
|
|
||||||
|
|
||||||
|
module WSDL
|
||||||
|
module SOAP
|
||||||
|
|
||||||
|
|
||||||
|
class MethodDefCreator
|
||||||
|
include ClassDefCreatorSupport
|
||||||
|
|
||||||
|
attr_reader :definitions
|
||||||
|
|
||||||
|
def initialize(definitions)
|
||||||
|
@definitions = definitions
|
||||||
|
@simpletypes = @definitions.collect_simpletypes
|
||||||
|
@complextypes = @definitions.collect_complextypes
|
||||||
|
@elements = @definitions.collect_elements
|
||||||
|
@types = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump(porttype)
|
||||||
|
@types = []
|
||||||
|
result = ""
|
||||||
|
operations = @definitions.porttype(porttype).operations
|
||||||
|
binding = @definitions.porttype_binding(porttype)
|
||||||
|
operations.each do |operation|
|
||||||
|
op_bind = binding.operations[operation.name]
|
||||||
|
result << ",\n" unless result.empty?
|
||||||
|
result << dump_method(operation, op_bind).chomp
|
||||||
|
end
|
||||||
|
return result, @types
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def dump_method(operation, binding)
|
||||||
|
name = safemethodname(operation.name.name)
|
||||||
|
name_as = operation.name.name
|
||||||
|
params = collect_parameter(operation)
|
||||||
|
soapaction = binding.soapoperation.soapaction
|
||||||
|
namespace = binding.input.soapbody.namespace
|
||||||
|
paramstr = param2str(params)
|
||||||
|
if paramstr.empty?
|
||||||
|
paramstr = '[]'
|
||||||
|
else
|
||||||
|
paramstr = "[\n" << paramstr.gsub(/^/, ' ') << "\n ]"
|
||||||
|
end
|
||||||
|
return <<__EOD__
|
||||||
|
[#{ dq(name_as) }, #{ dq(name) },
|
||||||
|
#{ paramstr },
|
||||||
|
#{ soapaction ? dq(soapaction) : "nil" }, #{ dq(namespace) }
|
||||||
|
]
|
||||||
|
__EOD__
|
||||||
|
end
|
||||||
|
|
||||||
|
def collect_parameter(operation)
|
||||||
|
result = operation.inputparts.collect { |part|
|
||||||
|
collect_type(part.type)
|
||||||
|
param_set('in', definedtype(part), part.name)
|
||||||
|
}
|
||||||
|
outparts = operation.outputparts
|
||||||
|
if outparts.size > 0
|
||||||
|
retval = outparts[0]
|
||||||
|
collect_type(retval.type)
|
||||||
|
result << param_set('retval', definedtype(retval), retval.name)
|
||||||
|
cdr(outparts).each { |part|
|
||||||
|
collect_type(part.type)
|
||||||
|
result << param_set('out', definedtype(part), part.name)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
def definedtype(part)
|
||||||
|
if mapped = basetype_mapped_class(part.type)
|
||||||
|
['::' + mapped.name]
|
||||||
|
elsif definedelement = @elements[part.element]
|
||||||
|
raise RuntimeError.new("Part: #{part.name} should be typed for RPC service for now.")
|
||||||
|
elsif definedtype = @simpletypes[part.type]
|
||||||
|
['::' + basetype_mapped_class(definedtype.base).name]
|
||||||
|
elsif definedtype = @complextypes[part.type]
|
||||||
|
case definedtype.compoundtype
|
||||||
|
when :TYPE_STRUCT
|
||||||
|
['::SOAP::SOAPStruct', part.type.namespace, part.type.name]
|
||||||
|
when :TYPE_ARRAY
|
||||||
|
arytype = definedtype.find_arytype || XSD::AnyTypeName
|
||||||
|
ns = arytype.namespace
|
||||||
|
name = arytype.name.sub(/\[(?:,)*\]$/, '')
|
||||||
|
['::SOAP::SOAPArray', ns, name]
|
||||||
|
else
|
||||||
|
raise NotImplementedError.new("Must not reach here.")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
raise RuntimeError.new("Part: #{part.name} cannot be resolved.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def param_set(io_type, type, name)
|
||||||
|
[io_type, type, name]
|
||||||
|
end
|
||||||
|
|
||||||
|
def collect_type(type)
|
||||||
|
# ignore inline type definition.
|
||||||
|
return if type.nil?
|
||||||
|
@types << type
|
||||||
|
return unless @complextypes[type]
|
||||||
|
@complextypes[type].each_element do |element|
|
||||||
|
collect_type(element.type)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def param2str(params)
|
||||||
|
params.collect { |param|
|
||||||
|
"[#{ dq(param[0]) }, #{ dq(param[2]) }, #{ type2str(param[1]) }]"
|
||||||
|
}.join(",\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
def type2str(type)
|
||||||
|
if type.size == 1
|
||||||
|
"[#{ type[0] }]"
|
||||||
|
else
|
||||||
|
"[#{ type[0] }, #{ dq(type[1]) }, #{ dq(type[2]) }]"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def dq(ele)
|
||||||
|
"\"" << ele << "\""
|
||||||
|
end
|
||||||
|
|
||||||
|
def cdr(ary)
|
||||||
|
result = ary.dup
|
||||||
|
result.shift
|
||||||
|
result
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
65
lib/wsdl/soap/servantSkeltonCreator.rb
Normal file
65
lib/wsdl/soap/servantSkeltonCreator.rb
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
# WSDL4R - Creating servant skelton code from WSDL.
|
||||||
|
# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'wsdl/info'
|
||||||
|
require 'wsdl/soap/classDefCreatorSupport'
|
||||||
|
require 'xsd/codegen'
|
||||||
|
|
||||||
|
|
||||||
|
module WSDL
|
||||||
|
module SOAP
|
||||||
|
|
||||||
|
|
||||||
|
class ServantSkeltonCreator
|
||||||
|
include ClassDefCreatorSupport
|
||||||
|
include ::XSD::CodeGen::GenSupport
|
||||||
|
|
||||||
|
attr_reader :definitions
|
||||||
|
|
||||||
|
def initialize(definitions)
|
||||||
|
@definitions = definitions
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump(porttype = nil)
|
||||||
|
if porttype.nil?
|
||||||
|
result = ""
|
||||||
|
@definitions.porttypes.each do |type|
|
||||||
|
result << dump_porttype(type.name)
|
||||||
|
result << "\n"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
result = dump_porttype(porttype)
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def dump_porttype(name)
|
||||||
|
class_name = create_class_name(name)
|
||||||
|
c = ::XSD::CodeGen::ClassDef.new(class_name)
|
||||||
|
operations = @definitions.porttype(name).operations
|
||||||
|
operations.each do |operation|
|
||||||
|
name = operation.name.name
|
||||||
|
input = operation.input
|
||||||
|
m = ::XSD::CodeGen::MethodDef.new(name,
|
||||||
|
input.find_message.parts.collect { |part| safevarname(part.name) }) do
|
||||||
|
<<-EOD
|
||||||
|
raise NotImplementedError.new
|
||||||
|
EOD
|
||||||
|
end
|
||||||
|
m.comment = dump_method_signature(operation)
|
||||||
|
c.add_method(m)
|
||||||
|
end
|
||||||
|
c.dump
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
79
lib/wsdl/soap/standaloneServerStubCreator.rb
Normal file
79
lib/wsdl/soap/standaloneServerStubCreator.rb
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
# WSDL4R - Creating standalone server stub code from WSDL.
|
||||||
|
# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'wsdl/info'
|
||||||
|
require 'wsdl/soap/mappingRegistryCreator'
|
||||||
|
require 'wsdl/soap/methodDefCreator'
|
||||||
|
require 'wsdl/soap/classDefCreatorSupport'
|
||||||
|
|
||||||
|
|
||||||
|
module WSDL
|
||||||
|
module SOAP
|
||||||
|
|
||||||
|
|
||||||
|
class StandaloneServerStubCreator
|
||||||
|
include ClassDefCreatorSupport
|
||||||
|
|
||||||
|
attr_reader :definitions
|
||||||
|
|
||||||
|
def initialize(definitions)
|
||||||
|
@definitions = definitions
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump(service_name)
|
||||||
|
STDERR.puts "!!! IMPORTANT !!!"
|
||||||
|
STDERR.puts "- Standalone stub can have only 1 port for now. So creating stub for the first port and rests are ignored."
|
||||||
|
STDERR.puts "- Standalone server stub ignores port location defined in WSDL. Location is http://localhost:10080/ by default. Generated client from WSDL must be configured to point this endpoint by hand."
|
||||||
|
STDERR.puts "!!! IMPORTANT !!!"
|
||||||
|
port = @definitions.service(service_name).ports[0]
|
||||||
|
dump_porttype(port.porttype.name)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def dump_porttype(name)
|
||||||
|
class_name = create_class_name(name)
|
||||||
|
methoddef, types = MethodDefCreator.new(@definitions).dump(name)
|
||||||
|
mr_creator = MappingRegistryCreator.new(@definitions)
|
||||||
|
|
||||||
|
c1 = ::XSD::CodeGen::ClassDef.new(class_name)
|
||||||
|
c1.def_require("soap/rpc/standaloneServer")
|
||||||
|
c1.def_require("soap/mapping/registry")
|
||||||
|
c1.def_const("MappingRegistry", "::SOAP::Mapping::Registry.new")
|
||||||
|
c1.def_code(mr_creator.dump(types))
|
||||||
|
c1.def_code <<-EOD
|
||||||
|
Methods = [
|
||||||
|
#{ methoddef.gsub(/^/, " ") }
|
||||||
|
]
|
||||||
|
EOD
|
||||||
|
c2 = ::XSD::CodeGen::ClassDef.new(class_name + "App",
|
||||||
|
"::SOAP::RPC::StandaloneServer")
|
||||||
|
c2.def_method("initialize", "*arg") do
|
||||||
|
<<-EOD
|
||||||
|
super(*arg)
|
||||||
|
servant = #{class_name}.new
|
||||||
|
#{class_name}::Methods.each do |name_as, name, params, soapaction, ns|
|
||||||
|
qname = XSD::QName.new(ns, name_as)
|
||||||
|
@soaplet.app_scope_router.add_method(servant, qname, soapaction, name, params)
|
||||||
|
end
|
||||||
|
self.mapping_registry = #{class_name}::MappingRegistry
|
||||||
|
EOD
|
||||||
|
end
|
||||||
|
c1.dump + "\n" + c2.dump + format(<<-EOD)
|
||||||
|
|
||||||
|
if $0 == __FILE__
|
||||||
|
# Change listen port.
|
||||||
|
#{class_name}App.new('app', nil, '0.0.0.0', 10080).start
|
||||||
|
end
|
||||||
|
EOD
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
@ -28,6 +28,10 @@ class ComplexContent < Info
|
|||||||
@attributes = XSD::NamedElements.new
|
@attributes = XSD::NamedElements.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def targetnamespace
|
||||||
|
parent.targetnamespace
|
||||||
|
end
|
||||||
|
|
||||||
def parse_element(element)
|
def parse_element(element)
|
||||||
case element
|
case element
|
||||||
when RestrictionName, ExtensionName
|
when RestrictionName, ExtensionName
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
require 'wsdl/info'
|
require 'wsdl/info'
|
||||||
require 'wsdl/xmlSchema/content'
|
require 'wsdl/xmlSchema/content'
|
||||||
|
require 'wsdl/xmlSchema/element'
|
||||||
require 'xsd/namedelements'
|
require 'xsd/namedelements'
|
||||||
|
|
||||||
|
|
||||||
@ -36,11 +37,16 @@ class ComplexType < Info
|
|||||||
def targetnamespace
|
def targetnamespace
|
||||||
parent.targetnamespace
|
parent.targetnamespace
|
||||||
end
|
end
|
||||||
|
|
||||||
|
AnyAsElement = Element.new(XSD::QName.new(nil, 'any'), XSD::AnyTypeName)
|
||||||
def each_element
|
def each_element
|
||||||
if @content
|
if @content
|
||||||
@content.elements.each do |element|
|
@content.elements.each do |element|
|
||||||
yield(element.name, element)
|
if element.is_a?(Any)
|
||||||
|
yield(AnyAsElement)
|
||||||
|
else
|
||||||
|
yield(element)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -48,7 +54,11 @@ class ComplexType < Info
|
|||||||
def find_element(name)
|
def find_element(name)
|
||||||
if @content
|
if @content
|
||||||
@content.elements.each do |element|
|
@content.elements.each do |element|
|
||||||
return element if name == element.name
|
if element.is_a?(Any)
|
||||||
|
return AnyAsElement if name == AnyAsElement.name
|
||||||
|
else
|
||||||
|
return element if name == element.name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
nil
|
nil
|
||||||
@ -57,7 +67,11 @@ class ComplexType < Info
|
|||||||
def find_element_by_name(name)
|
def find_element_by_name(name)
|
||||||
if @content
|
if @content
|
||||||
@content.elements.each do |element|
|
@content.elements.each do |element|
|
||||||
return element if name == element.name.name
|
if element.is_a?(Any)
|
||||||
|
return AnyAsElement if name == AnyAsElement.name.name
|
||||||
|
else
|
||||||
|
return element if name == element.name.name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
nil
|
nil
|
||||||
|
@ -6,8 +6,11 @@
|
|||||||
# either the dual license version in 2003, or any later version.
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'xsd/datatypes'
|
||||||
require 'wsdl/xmlSchema/schema'
|
require 'wsdl/xmlSchema/schema'
|
||||||
require 'wsdl/xmlSchema/import'
|
require 'wsdl/xmlSchema/import'
|
||||||
|
require 'wsdl/xmlSchema/simpleType'
|
||||||
|
require 'wsdl/xmlSchema/simpleRestriction'
|
||||||
require 'wsdl/xmlSchema/complexType'
|
require 'wsdl/xmlSchema/complexType'
|
||||||
require 'wsdl/xmlSchema/complexContent'
|
require 'wsdl/xmlSchema/complexContent'
|
||||||
require 'wsdl/xmlSchema/any'
|
require 'wsdl/xmlSchema/any'
|
||||||
@ -17,7 +20,7 @@ require 'wsdl/xmlSchema/choice'
|
|||||||
require 'wsdl/xmlSchema/sequence'
|
require 'wsdl/xmlSchema/sequence'
|
||||||
require 'wsdl/xmlSchema/attribute'
|
require 'wsdl/xmlSchema/attribute'
|
||||||
require 'wsdl/xmlSchema/unique'
|
require 'wsdl/xmlSchema/unique'
|
||||||
|
require 'wsdl/xmlSchema/enumeration'
|
||||||
|
|
||||||
module WSDL
|
module WSDL
|
||||||
module XMLSchema
|
module XMLSchema
|
||||||
@ -30,6 +33,7 @@ ChoiceName = XSD::QName.new(XSD::Namespace, 'choice')
|
|||||||
ComplexContentName = XSD::QName.new(XSD::Namespace, 'complexContent')
|
ComplexContentName = XSD::QName.new(XSD::Namespace, 'complexContent')
|
||||||
ComplexTypeName = XSD::QName.new(XSD::Namespace, 'complexType')
|
ComplexTypeName = XSD::QName.new(XSD::Namespace, 'complexType')
|
||||||
ElementName = XSD::QName.new(XSD::Namespace, 'element')
|
ElementName = XSD::QName.new(XSD::Namespace, 'element')
|
||||||
|
EnumerationName = XSD::QName.new(XSD::Namespace, 'enumeration')
|
||||||
ExtensionName = XSD::QName.new(XSD::Namespace, 'extension')
|
ExtensionName = XSD::QName.new(XSD::Namespace, 'extension')
|
||||||
ImportName = XSD::QName.new(XSD::Namespace, 'import')
|
ImportName = XSD::QName.new(XSD::Namespace, 'import')
|
||||||
RestrictionName = XSD::QName.new(XSD::Namespace, 'restriction')
|
RestrictionName = XSD::QName.new(XSD::Namespace, 'restriction')
|
||||||
@ -57,6 +61,7 @@ SchemaLocationAttrName = XSD::QName.new(nil, 'schemaLocation')
|
|||||||
TargetNamespaceAttrName = XSD::QName.new(nil, 'targetNamespace')
|
TargetNamespaceAttrName = XSD::QName.new(nil, 'targetNamespace')
|
||||||
TypeAttrName = XSD::QName.new(nil, 'type')
|
TypeAttrName = XSD::QName.new(nil, 'type')
|
||||||
UseAttrName = XSD::QName.new(nil, 'use')
|
UseAttrName = XSD::QName.new(nil, 'use')
|
||||||
|
ValueAttrName = XSD::QName.new(nil, 'value')
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
36
lib/wsdl/xmlSchema/enumeration.rb
Normal file
36
lib/wsdl/xmlSchema/enumeration.rb
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# WSDL4R - XMLSchema enumeration definition for WSDL.
|
||||||
|
# Copyright (C) 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'wsdl/info'
|
||||||
|
|
||||||
|
|
||||||
|
module WSDL
|
||||||
|
module XMLSchema
|
||||||
|
|
||||||
|
|
||||||
|
class Enumeration < Info
|
||||||
|
def initialize
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
def parse_element(element)
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def parse_attr(attr, value)
|
||||||
|
case attr
|
||||||
|
when ValueAttrName
|
||||||
|
parent.enumeration << value
|
||||||
|
value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
@ -116,7 +116,8 @@ private
|
|||||||
unless o
|
unless o
|
||||||
raise UnknownElementError.new("Unknown element #{ element }.")
|
raise UnknownElementError.new("Unknown element #{ element }.")
|
||||||
end
|
end
|
||||||
o.parent = parent
|
# node could be a pseudo element. pseudo element has its own parent.
|
||||||
|
o.parent = parent if o.parent.nil?
|
||||||
end
|
end
|
||||||
attrs.each do |key, value|
|
attrs.each do |key, value|
|
||||||
attr = unless /:/ =~ key
|
attr = unless /:/ =~ key
|
||||||
|
@ -17,6 +17,7 @@ module XMLSchema
|
|||||||
class Schema < Info
|
class Schema < Info
|
||||||
attr_reader :targetnamespace # required
|
attr_reader :targetnamespace # required
|
||||||
attr_reader :complextypes
|
attr_reader :complextypes
|
||||||
|
attr_reader :simpletypes
|
||||||
attr_reader :elements
|
attr_reader :elements
|
||||||
attr_reader :attributes
|
attr_reader :attributes
|
||||||
attr_reader :imports
|
attr_reader :imports
|
||||||
@ -27,6 +28,7 @@ class Schema < Info
|
|||||||
super
|
super
|
||||||
@targetnamespace = nil
|
@targetnamespace = nil
|
||||||
@complextypes = XSD::NamedElements.new
|
@complextypes = XSD::NamedElements.new
|
||||||
|
@simpletypes = XSD::NamedElements.new
|
||||||
@elements = XSD::NamedElements.new
|
@elements = XSD::NamedElements.new
|
||||||
@attributes = XSD::NamedElements.new
|
@attributes = XSD::NamedElements.new
|
||||||
@imports = []
|
@imports = []
|
||||||
@ -44,8 +46,9 @@ class Schema < Info
|
|||||||
@complextypes << o
|
@complextypes << o
|
||||||
o
|
o
|
||||||
when SimpleTypeName
|
when SimpleTypeName
|
||||||
STDERR.puts("Restriction of basetype with simpleType definition is ignored for now.")
|
o = SimpleType.new
|
||||||
nil
|
@simpletypes << o
|
||||||
|
o
|
||||||
when ElementName
|
when ElementName
|
||||||
o = Element.new
|
o = Element.new
|
||||||
@elements << o
|
@elements << o
|
||||||
@ -83,6 +86,12 @@ class Schema < Info
|
|||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def collect_simpletypes
|
||||||
|
result = XSD::NamedElements.new
|
||||||
|
result.concat(@simpletypes)
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
def self.parse_element(element)
|
def self.parse_element(element)
|
||||||
if element == SchemaName
|
if element == SchemaName
|
||||||
Schema.new
|
Schema.new
|
||||||
|
48
lib/wsdl/xmlSchema/simpleRestriction.rb
Normal file
48
lib/wsdl/xmlSchema/simpleRestriction.rb
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# WSDL4R - XMLSchema simpleType definition for WSDL.
|
||||||
|
# Copyright (C) 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'wsdl/info'
|
||||||
|
require 'xsd/namedelements'
|
||||||
|
|
||||||
|
|
||||||
|
module WSDL
|
||||||
|
module XMLSchema
|
||||||
|
|
||||||
|
|
||||||
|
class SimpleRestriction < Info
|
||||||
|
attr_reader :base
|
||||||
|
attr_reader :enumeration
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
super
|
||||||
|
@base = nil
|
||||||
|
@enumeration = [] # NamedElements?
|
||||||
|
end
|
||||||
|
|
||||||
|
def valid?(value)
|
||||||
|
@enumeration.include?(value)
|
||||||
|
end
|
||||||
|
|
||||||
|
def parse_element(element)
|
||||||
|
case element
|
||||||
|
when EnumerationName
|
||||||
|
Enumeration.new # just a parsing handler
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def parse_attr(attr, value)
|
||||||
|
case attr
|
||||||
|
when BaseAttrName
|
||||||
|
@base = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
81
lib/wsdl/xmlSchema/simpleType.rb
Normal file
81
lib/wsdl/xmlSchema/simpleType.rb
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
# WSDL4R - XMLSchema simpleType definition for WSDL.
|
||||||
|
# Copyright (C) 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'wsdl/info'
|
||||||
|
require 'xsd/namedelements'
|
||||||
|
|
||||||
|
|
||||||
|
module WSDL
|
||||||
|
module XMLSchema
|
||||||
|
|
||||||
|
|
||||||
|
class SimpleType < Info
|
||||||
|
attr_accessor :name
|
||||||
|
attr_reader :derivetype
|
||||||
|
attr_reader :restriction
|
||||||
|
|
||||||
|
def check_lexical_format(value)
|
||||||
|
if @restriction
|
||||||
|
check_restriction(value)
|
||||||
|
elsif @extension
|
||||||
|
raise NotImplementedError
|
||||||
|
# ToDo
|
||||||
|
else
|
||||||
|
raise ArgumentError.new("incomplete simpleType")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def base
|
||||||
|
if @restriction
|
||||||
|
@restriction.base
|
||||||
|
elsif @extension
|
||||||
|
@extension.base
|
||||||
|
else
|
||||||
|
raise ArgumentError.new("incomplete simpleType")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(name = nil)
|
||||||
|
super()
|
||||||
|
@name = name
|
||||||
|
@derivetype = nil
|
||||||
|
@restriction = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def targetnamespace
|
||||||
|
parent.targetnamespace
|
||||||
|
end
|
||||||
|
|
||||||
|
def parse_element(element)
|
||||||
|
case element
|
||||||
|
when RestrictionName
|
||||||
|
@restriction = SimpleRestriction.new
|
||||||
|
@derivetype = element.name
|
||||||
|
@restriction
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def parse_attr(attr, value)
|
||||||
|
case attr
|
||||||
|
when NameAttrName
|
||||||
|
@name = XSD::QName.new(targetnamespace, value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def check_restriction(value)
|
||||||
|
unless @restriction.valid?(value)
|
||||||
|
raise ::XSD::ValueSpaceError.new("#{@name}: cannot accept '#{value}'.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
12
lib/xsd/codegen.rb
Normal file
12
lib/xsd/codegen.rb
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# XSD4R - Generating code library
|
||||||
|
# Copyright (C) 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'xsd/codegen/gensupport'
|
||||||
|
require 'xsd/codegen/moduledef'
|
||||||
|
require 'xsd/codegen/classdef'
|
||||||
|
require 'xsd/codegen/methoddef'
|
203
lib/xsd/codegen/classdef.rb
Normal file
203
lib/xsd/codegen/classdef.rb
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
# XSD4R - Generating class definition code
|
||||||
|
# Copyright (C) 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'xsd/codegen/gensupport'
|
||||||
|
require 'xsd/codegen/moduledef'
|
||||||
|
require 'xsd/codegen/methoddef'
|
||||||
|
|
||||||
|
|
||||||
|
module XSD
|
||||||
|
module CodeGen
|
||||||
|
|
||||||
|
|
||||||
|
class ClassDef < ModuleDef
|
||||||
|
include GenSupport
|
||||||
|
|
||||||
|
def initialize(name, baseclass = nil)
|
||||||
|
super(name)
|
||||||
|
@baseclass = baseclass
|
||||||
|
@classvar = []
|
||||||
|
@attrdef = []
|
||||||
|
end
|
||||||
|
|
||||||
|
def def_classvar(var, value)
|
||||||
|
var = var.sub(/\A@@/, "")
|
||||||
|
unless safevarname?(var)
|
||||||
|
raise ArgumentError.new("#{var} seems to be unsafe")
|
||||||
|
end
|
||||||
|
@classvar << [var, value]
|
||||||
|
end
|
||||||
|
|
||||||
|
def def_attr(attrname, writable = true, varname = nil)
|
||||||
|
unless safevarname?(varname || attrname)
|
||||||
|
raise ArgumentError.new("#{varname || attrname} seems to be unsafe")
|
||||||
|
end
|
||||||
|
@attrdef << [attrname, writable, varname]
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump
|
||||||
|
buf = ""
|
||||||
|
unless @requirepath.empty?
|
||||||
|
buf << dump_requirepath
|
||||||
|
end
|
||||||
|
buf << dump_emptyline unless buf.empty?
|
||||||
|
package = @name.split(/::/)[0..-2]
|
||||||
|
buf << dump_package_def(package) unless package.empty?
|
||||||
|
buf << dump_comment if @comment
|
||||||
|
buf << dump_class_def
|
||||||
|
spacer = false
|
||||||
|
unless @classvar.empty?
|
||||||
|
spacer = true
|
||||||
|
buf << dump_classvar
|
||||||
|
end
|
||||||
|
unless @const.empty?
|
||||||
|
buf << dump_emptyline if spacer
|
||||||
|
spacer = true
|
||||||
|
buf << dump_const
|
||||||
|
end
|
||||||
|
unless @code.empty?
|
||||||
|
buf << dump_emptyline if spacer
|
||||||
|
spacer = true
|
||||||
|
buf << dump_code
|
||||||
|
end
|
||||||
|
unless @attrdef.empty?
|
||||||
|
buf << dump_emptyline if spacer
|
||||||
|
spacer = true
|
||||||
|
buf << dump_attributes
|
||||||
|
end
|
||||||
|
unless @methoddef.empty?
|
||||||
|
buf << dump_emptyline if spacer
|
||||||
|
spacer = true
|
||||||
|
buf << dump_methods
|
||||||
|
end
|
||||||
|
buf << dump_class_def_end
|
||||||
|
buf << dump_package_def_end(package) unless package.empty?
|
||||||
|
buf
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def dump_class_def
|
||||||
|
name = @name.to_s.split(/::/)
|
||||||
|
if @baseclass
|
||||||
|
format("class #{name.last} < #{@baseclass}")
|
||||||
|
else
|
||||||
|
format("class #{name.last}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_class_def_end
|
||||||
|
str = format("end")
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_classvar
|
||||||
|
dump_static(
|
||||||
|
@classvar.collect { |var, value|
|
||||||
|
%Q(@@#{var.sub(/^@@/, "")} = #{dump_value(value)})
|
||||||
|
}.join("\n")
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_attributes
|
||||||
|
str = ""
|
||||||
|
@attrdef.each do |attrname, writable, varname|
|
||||||
|
varname ||= attrname
|
||||||
|
if attrname == varname
|
||||||
|
str << format(dump_accessor(attrname, writable), 2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@attrdef.each do |attrname, writable, varname|
|
||||||
|
varname ||= attrname
|
||||||
|
if attrname != varname
|
||||||
|
str << "\n" unless str.empty?
|
||||||
|
str << format(dump_attribute(attrname, writable, varname), 2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
str
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_accessor(attrname, writable)
|
||||||
|
if writable
|
||||||
|
"attr_accessor :#{attrname}"
|
||||||
|
else
|
||||||
|
"attr_reader :#{attrname}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_attribute(attrname, writable, varname)
|
||||||
|
str = nil
|
||||||
|
mr = MethodDef.new(attrname)
|
||||||
|
mr.definition = "@#{varname}"
|
||||||
|
str = mr.dump
|
||||||
|
if writable
|
||||||
|
mw = MethodDef.new(attrname + "=", 'value')
|
||||||
|
mw.definition = "@#{varname} = value"
|
||||||
|
str << "\n" + mw.dump
|
||||||
|
end
|
||||||
|
str
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if __FILE__ == $0
|
||||||
|
require 'xsd/codegen/classdef'
|
||||||
|
include XSD::CodeGen
|
||||||
|
c = ClassDef.new("Foo::Bar::HobbitName", String)
|
||||||
|
c.def_require("foo/bar")
|
||||||
|
c.comment = <<-EOD
|
||||||
|
foo
|
||||||
|
bar
|
||||||
|
baz
|
||||||
|
EOD
|
||||||
|
c.def_const("FOO", 1)
|
||||||
|
c.def_classvar("@@foo", "var".dump)
|
||||||
|
c.def_classvar("baz", "1".dump)
|
||||||
|
c.def_attr("Foo", true, "foo")
|
||||||
|
c.def_attr("bar")
|
||||||
|
c.def_attr("baz", true)
|
||||||
|
c.def_attr("Foo2", true, "foo2")
|
||||||
|
c.def_attr("foo3", false, "foo3")
|
||||||
|
c.def_method("foo") do
|
||||||
|
<<-EOD
|
||||||
|
foo.bar = 1
|
||||||
|
\tbaz.each do |ele|
|
||||||
|
\t ele
|
||||||
|
end
|
||||||
|
EOD
|
||||||
|
end
|
||||||
|
c.def_method("baz", "qux") do
|
||||||
|
<<-EOD
|
||||||
|
[1, 2, 3].each do |i|
|
||||||
|
p i
|
||||||
|
end
|
||||||
|
EOD
|
||||||
|
end
|
||||||
|
|
||||||
|
m = MethodDef.new("qux", "quxx", "quxxx") do
|
||||||
|
<<-EOD
|
||||||
|
p quxx + quxxx
|
||||||
|
EOD
|
||||||
|
end
|
||||||
|
m.comment = "hello world\n123"
|
||||||
|
c.add_method(m)
|
||||||
|
c.def_code <<-EOD
|
||||||
|
Foo.new
|
||||||
|
Bar.z
|
||||||
|
EOD
|
||||||
|
c.def_code <<-EOD
|
||||||
|
Foo.new
|
||||||
|
Bar.z
|
||||||
|
EOD
|
||||||
|
c.def_privatemethod("foo", "baz", "*arg", "&block")
|
||||||
|
|
||||||
|
puts c.dump
|
||||||
|
end
|
34
lib/xsd/codegen/commentdef.rb
Normal file
34
lib/xsd/codegen/commentdef.rb
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# XSD4R - Generating comment definition code
|
||||||
|
# Copyright (C) 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'xsd/codegen/gensupport'
|
||||||
|
|
||||||
|
|
||||||
|
module XSD
|
||||||
|
module CodeGen
|
||||||
|
|
||||||
|
|
||||||
|
module CommentDef
|
||||||
|
include GenSupport
|
||||||
|
|
||||||
|
attr_accessor :comment
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def dump_comment
|
||||||
|
if /^#/ =~ @comment
|
||||||
|
format(@comment)
|
||||||
|
else
|
||||||
|
format(@comment).gsub(/^/, "# ")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
112
lib/xsd/codegen/gensupport.rb
Normal file
112
lib/xsd/codegen/gensupport.rb
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
# XSD4R - Code generation support
|
||||||
|
# Copyright (C) 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
module XSD
|
||||||
|
module CodeGen
|
||||||
|
|
||||||
|
|
||||||
|
module GenSupport
|
||||||
|
def capitalize(target)
|
||||||
|
target.sub(/^([a-z])/) { $1.tr!('[a-z]', '[A-Z]') }
|
||||||
|
end
|
||||||
|
module_function :capitalize
|
||||||
|
|
||||||
|
def uncapitalize(target)
|
||||||
|
target.sub(/^([A-Z])/) { $1.tr!('[A-Z]', '[a-z]') }
|
||||||
|
end
|
||||||
|
module_function :uncapitalize
|
||||||
|
|
||||||
|
def safeconstname(name)
|
||||||
|
safename = name.scan(/[a-zA-Z0-9_]+/).collect { |ele|
|
||||||
|
GenSupport.capitalize(ele)
|
||||||
|
}.join
|
||||||
|
unless /^[A-Z]/ =~ safename
|
||||||
|
safename = "C_#{safename}"
|
||||||
|
end
|
||||||
|
safename
|
||||||
|
end
|
||||||
|
module_function :safeconstname
|
||||||
|
|
||||||
|
def safeconstname?(name)
|
||||||
|
/\A[A-Z][a-zA-Z0-9_]*\z/ =~ name
|
||||||
|
end
|
||||||
|
module_function :safeconstname?
|
||||||
|
|
||||||
|
def safemethodname(name)
|
||||||
|
safevarname(name)
|
||||||
|
end
|
||||||
|
module_function :safemethodname
|
||||||
|
|
||||||
|
def safemethodname?(name)
|
||||||
|
/\A[a-zA-Z_][a-zA-Z0-9_]*[=!?]?\z/ =~ name
|
||||||
|
end
|
||||||
|
module_function :safemethodname?
|
||||||
|
|
||||||
|
def safevarname(name)
|
||||||
|
safename = name.scan(/[a-zA-Z0-9_]+/).join('_')
|
||||||
|
safename = uncapitalize(safename)
|
||||||
|
unless /^[a-z]/ =~ safename
|
||||||
|
safename = "m_#{safename}"
|
||||||
|
end
|
||||||
|
safename
|
||||||
|
end
|
||||||
|
module_function :safevarname
|
||||||
|
|
||||||
|
def safevarname?(name)
|
||||||
|
/\A[a-z_][a-zA-Z0-9_]*\z/ =~ name
|
||||||
|
end
|
||||||
|
module_function :safevarname?
|
||||||
|
|
||||||
|
def format(str, indent = nil)
|
||||||
|
str = trim_eol(str)
|
||||||
|
str = trim_indent(str)
|
||||||
|
if indent
|
||||||
|
str.gsub(/^/, " " * indent)
|
||||||
|
else
|
||||||
|
str
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def trim_eol(str)
|
||||||
|
str.collect { |line|
|
||||||
|
line.sub(/\r?\n$/, "") + "\n"
|
||||||
|
}.join
|
||||||
|
end
|
||||||
|
|
||||||
|
def trim_indent(str)
|
||||||
|
indent = nil
|
||||||
|
str = str.collect { |line| untab(line) }.join
|
||||||
|
str.each do |line|
|
||||||
|
head = line.index(/\S/)
|
||||||
|
if !head.nil? and (indent.nil? or head < indent)
|
||||||
|
indent = head
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return str unless indent
|
||||||
|
str.collect { |line|
|
||||||
|
line.sub(/^ {0,#{indent}}/, "")
|
||||||
|
}.join
|
||||||
|
end
|
||||||
|
|
||||||
|
def untab(line, ts = 8)
|
||||||
|
while pos = line.index(/\t/)
|
||||||
|
line = line.sub(/\t/, " " * (ts - (pos % ts)))
|
||||||
|
end
|
||||||
|
line
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_emptyline
|
||||||
|
"\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
63
lib/xsd/codegen/methoddef.rb
Normal file
63
lib/xsd/codegen/methoddef.rb
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
# XSD4R - Generating method definition code
|
||||||
|
# Copyright (C) 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'xsd/codegen/gensupport'
|
||||||
|
require 'xsd/codegen/commentdef'
|
||||||
|
|
||||||
|
|
||||||
|
module XSD
|
||||||
|
module CodeGen
|
||||||
|
|
||||||
|
|
||||||
|
class MethodDef
|
||||||
|
include GenSupport
|
||||||
|
include CommentDef
|
||||||
|
|
||||||
|
attr_accessor :definition
|
||||||
|
|
||||||
|
def initialize(name, *params)
|
||||||
|
unless safemethodname?(name)
|
||||||
|
raise ArgumentError.new("#{name} seems to be unsafe")
|
||||||
|
end
|
||||||
|
@name = name
|
||||||
|
@params = params
|
||||||
|
@comment = nil
|
||||||
|
@definition = yield if block_given?
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump
|
||||||
|
buf = ""
|
||||||
|
buf << dump_comment if @comment
|
||||||
|
buf << dump_method_def
|
||||||
|
buf << dump_definition if @definition
|
||||||
|
buf << dump_method_def_end
|
||||||
|
buf
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def dump_method_def
|
||||||
|
if @params.empty?
|
||||||
|
format("def #{@name}")
|
||||||
|
else
|
||||||
|
format("def #{@name}(#{@params.join(", ")})")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_method_def_end
|
||||||
|
format("end")
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_definition
|
||||||
|
format(@definition, 2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
191
lib/xsd/codegen/moduledef.rb
Normal file
191
lib/xsd/codegen/moduledef.rb
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
# XSD4R - Generating module definition code
|
||||||
|
# Copyright (C) 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
|
# either the dual license version in 2003, or any later version.
|
||||||
|
|
||||||
|
|
||||||
|
require 'xsd/codegen/gensupport'
|
||||||
|
require 'xsd/codegen/methoddef'
|
||||||
|
require 'xsd/codegen/commentdef'
|
||||||
|
|
||||||
|
|
||||||
|
module XSD
|
||||||
|
module CodeGen
|
||||||
|
|
||||||
|
|
||||||
|
class ModuleDef
|
||||||
|
include GenSupport
|
||||||
|
include CommentDef
|
||||||
|
|
||||||
|
def initialize(name)
|
||||||
|
@name = name
|
||||||
|
@comment = nil
|
||||||
|
@const = []
|
||||||
|
@code = []
|
||||||
|
@requirepath = []
|
||||||
|
@methoddef = []
|
||||||
|
end
|
||||||
|
|
||||||
|
def def_require(path)
|
||||||
|
@requirepath << path
|
||||||
|
end
|
||||||
|
|
||||||
|
def def_const(const, value)
|
||||||
|
unless safeconstname?(const)
|
||||||
|
raise ArgumentError.new("#{const} seems to be unsafe")
|
||||||
|
end
|
||||||
|
@const << [const, value]
|
||||||
|
end
|
||||||
|
|
||||||
|
def def_code(code)
|
||||||
|
@code << code
|
||||||
|
end
|
||||||
|
|
||||||
|
def def_method(name, *params)
|
||||||
|
add_method(MethodDef.new(name, *params) { yield if block_given? }, :public)
|
||||||
|
end
|
||||||
|
alias def_publicmethod def_method
|
||||||
|
|
||||||
|
def def_protectedmethod(name, *params)
|
||||||
|
add_method(MethodDef.new(name, *params) { yield if block_given? },
|
||||||
|
:protected)
|
||||||
|
end
|
||||||
|
|
||||||
|
def def_privatemethod(name, *params)
|
||||||
|
add_method(MethodDef.new(name, *params) { yield if block_given? }, :private)
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_method(m, visibility = :public)
|
||||||
|
@methoddef << [visibility, m]
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump
|
||||||
|
buf = ""
|
||||||
|
unless @requirepath.empty?
|
||||||
|
buf << dump_requirepath
|
||||||
|
end
|
||||||
|
buf << dump_emptyline unless buf.empty?
|
||||||
|
package = @name.split(/::/)[0..-2]
|
||||||
|
buf << dump_package_def(package) unless package.empty?
|
||||||
|
buf << dump_comment if @comment
|
||||||
|
buf << dump_module_def
|
||||||
|
spacer = false
|
||||||
|
unless @const.empty?
|
||||||
|
buf << dump_emptyline if spacer
|
||||||
|
spacer = true
|
||||||
|
buf << dump_const
|
||||||
|
end
|
||||||
|
unless @code.empty?
|
||||||
|
buf << dump_emptyline if spacer
|
||||||
|
spacer = true
|
||||||
|
buf << dump_code
|
||||||
|
end
|
||||||
|
unless @methoddef.empty?
|
||||||
|
buf << dump_emptyline if spacer
|
||||||
|
spacer = true
|
||||||
|
buf << dump_methods
|
||||||
|
end
|
||||||
|
buf << dump_module_def_end
|
||||||
|
buf << dump_package_def_end(package) unless package.empty?
|
||||||
|
buf
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def dump_requirepath
|
||||||
|
format(
|
||||||
|
@requirepath.collect { |path|
|
||||||
|
%Q(require '#{path}')
|
||||||
|
}.join("\n")
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_const
|
||||||
|
dump_static(
|
||||||
|
@const.sort.collect { |var, value|
|
||||||
|
%Q(#{var} = #{dump_value(value)})
|
||||||
|
}.join("\n")
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_code
|
||||||
|
dump_static(@code.join("\n"))
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_static(str)
|
||||||
|
format(str, 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_methods
|
||||||
|
methods = {}
|
||||||
|
@methoddef.each do |visibility, method|
|
||||||
|
(methods[visibility] ||= []) << method
|
||||||
|
end
|
||||||
|
str = ""
|
||||||
|
[:public, :protected, :private].each do |visibility|
|
||||||
|
if methods[visibility]
|
||||||
|
str << "\n" unless str.empty?
|
||||||
|
str << visibility.to_s << "\n\n" unless visibility == :public
|
||||||
|
str << methods[visibility].collect { |m| format(m.dump, 2) }.join("\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
str
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_value(value)
|
||||||
|
if value.respond_to?(:to_src)
|
||||||
|
value.to_src
|
||||||
|
else
|
||||||
|
value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_package_def(package)
|
||||||
|
format(package.collect { |ele| "module #{ele}" }.join("; ")) + "\n\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_package_def_end(package)
|
||||||
|
"\n\n" + format(package.collect { |ele| "end" }.join("; "))
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_module_def
|
||||||
|
name = @name.to_s.split(/::/)
|
||||||
|
format("module #{name.last}")
|
||||||
|
end
|
||||||
|
|
||||||
|
def dump_module_def_end
|
||||||
|
format("end")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if __FILE__ == $0
|
||||||
|
require 'xsd/codegen/moduledef'
|
||||||
|
include XSD::CodeGen
|
||||||
|
m = ModuleDef.new("Foo::Bar::HobbitName")
|
||||||
|
m.def_require("foo/bar")
|
||||||
|
m.def_require("baz")
|
||||||
|
m.comment = <<-EOD
|
||||||
|
foo
|
||||||
|
bar
|
||||||
|
baz
|
||||||
|
EOD
|
||||||
|
m.def_method("foo") do
|
||||||
|
<<-EOD
|
||||||
|
foo.bar = 1
|
||||||
|
baz.each do |ele|
|
||||||
|
ele + 1
|
||||||
|
end
|
||||||
|
EOD
|
||||||
|
end
|
||||||
|
m.def_method("baz", "qux")
|
||||||
|
#m.def_protectedmethod("aaa")
|
||||||
|
m.def_privatemethod("bbb")
|
||||||
|
puts m.dump
|
||||||
|
end
|
@ -103,6 +103,12 @@ class XSDAnySimpleType < NSDBase
|
|||||||
set(value) if value
|
set(value) if value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# true or raise
|
||||||
|
def check_lexical_format(value)
|
||||||
|
screen_data(value)
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
# set accepts a string which follows lexical space (ex. String: "+123"), or
|
# set accepts a string which follows lexical space (ex. String: "+123"), or
|
||||||
# an object which follows canonical space (ex. Integer: 123).
|
# an object which follows canonical space (ex. Integer: 123).
|
||||||
def set(value)
|
def set(value)
|
||||||
@ -111,7 +117,7 @@ class XSDAnySimpleType < NSDBase
|
|||||||
@data = nil
|
@data = nil
|
||||||
else
|
else
|
||||||
@is_nil = false
|
@is_nil = false
|
||||||
_set(value)
|
_set(screen_data(value))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -126,6 +132,11 @@ class XSDAnySimpleType < NSDBase
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
# raises ValueSpaceError if check failed
|
||||||
|
def screen_data(value)
|
||||||
|
value
|
||||||
|
end
|
||||||
|
|
||||||
def _set(value)
|
def _set(value)
|
||||||
@data = value
|
@data = value
|
||||||
end
|
end
|
||||||
@ -144,12 +155,6 @@ class XSDNil < XSDAnySimpleType
|
|||||||
@type = Type
|
@type = Type
|
||||||
set(value)
|
set(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def _set(value)
|
|
||||||
@data = value
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -167,11 +172,11 @@ class XSDString < XSDAnySimpleType
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def _set(value)
|
def screen_data(value)
|
||||||
unless XSD::Charset.is_ces(value, XSD::Charset.encoding)
|
unless XSD::Charset.is_ces(value, XSD::Charset.encoding)
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
|
||||||
end
|
end
|
||||||
@data = value
|
value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -186,18 +191,18 @@ class XSDBoolean < XSDAnySimpleType
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def _set(value)
|
def screen_data(value)
|
||||||
if value.is_a?(String)
|
if value.is_a?(String)
|
||||||
str = value.strip
|
str = value.strip
|
||||||
if str == 'true' || str == '1'
|
if str == 'true' || str == '1'
|
||||||
@data = true
|
true
|
||||||
elsif str == 'false' || str == '0'
|
elsif str == 'false' || str == '0'
|
||||||
@data = false
|
false
|
||||||
else
|
else
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@data = value ? true : false
|
value ? true : false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -220,38 +225,39 @@ class XSDDecimal < XSDAnySimpleType
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def _set(d)
|
def screen_data(d)
|
||||||
if d.is_a?(String)
|
if d.is_a?(String)
|
||||||
# Integer("00012") => 10 in Ruby.
|
# Integer("00012") => 10 in Ruby.
|
||||||
d.sub!(/^([+\-]?)0*(?=\d)/, "\\1")
|
d.sub!(/^([+\-]?)0*(?=\d)/, "\\1")
|
||||||
end
|
end
|
||||||
set_str(d)
|
screen_data_str(d)
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_str(str)
|
def screen_data_str(str)
|
||||||
/^([+\-]?)(\d*)(?:\.(\d*)?)?$/ =~ str.to_s.strip
|
/^([+\-]?)(\d*)(?:\.(\d*)?)?$/ =~ str.to_s.strip
|
||||||
unless Regexp.last_match
|
unless Regexp.last_match
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
||||||
end
|
end
|
||||||
|
sign = $1 || '+'
|
||||||
@sign = $1 || '+'
|
|
||||||
int_part = $2
|
int_part = $2
|
||||||
frac_part = $3
|
frac_part = $3
|
||||||
|
|
||||||
int_part = '0' if int_part.empty?
|
int_part = '0' if int_part.empty?
|
||||||
frac_part = frac_part ? frac_part.sub(/0+$/, '') : ''
|
frac_part = frac_part ? frac_part.sub(/0+$/, '') : ''
|
||||||
@point = - frac_part.size
|
point = - frac_part.size
|
||||||
@number = int_part + frac_part
|
number = int_part + frac_part
|
||||||
|
|
||||||
# normalize
|
# normalize
|
||||||
if @sign == '+'
|
if sign == '+'
|
||||||
@sign = ''
|
sign = ''
|
||||||
elsif @sign == '-'
|
elsif sign == '-'
|
||||||
if @number == '0'
|
if number == '0'
|
||||||
@sign = ''
|
sign = ''
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
[sign, point, number]
|
||||||
|
end
|
||||||
|
|
||||||
|
def _set(pair)
|
||||||
|
@sign, @point, @number = pair
|
||||||
@data = _to_s
|
@data = _to_s
|
||||||
@data.freeze
|
@data.freeze
|
||||||
end
|
end
|
||||||
@ -272,7 +278,7 @@ module FloatConstants
|
|||||||
NEGATIVE_INF = -1.0/0.0
|
NEGATIVE_INF = -1.0/0.0
|
||||||
POSITIVE_ZERO = +1.0/POSITIVE_INF
|
POSITIVE_ZERO = +1.0/POSITIVE_INF
|
||||||
NEGATIVE_ZERO = -1.0/POSITIVE_INF
|
NEGATIVE_ZERO = -1.0/POSITIVE_INF
|
||||||
MIN_POSITIVE_SINGLE = 2 ** -149
|
MIN_POSITIVE_SINGLE = 2.0 ** -149
|
||||||
end
|
end
|
||||||
|
|
||||||
class XSDFloat < XSDAnySimpleType
|
class XSDFloat < XSDAnySimpleType
|
||||||
@ -287,20 +293,18 @@ class XSDFloat < XSDAnySimpleType
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def _set(value)
|
def screen_data(value)
|
||||||
# "NaN".to_f => 0 in some environment. libc?
|
# "NaN".to_f => 0 in some environment. libc?
|
||||||
if value.is_a?(Float)
|
if value.is_a?(Float)
|
||||||
@data = narrow32bit(value)
|
return narrow32bit(value)
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
str = value.to_s.strip
|
str = value.to_s.strip
|
||||||
if str == 'NaN'
|
if str == 'NaN'
|
||||||
@data = NaN
|
NaN
|
||||||
elsif str == 'INF'
|
elsif str == 'INF'
|
||||||
@data = POSITIVE_INF
|
POSITIVE_INF
|
||||||
elsif str == '-INF'
|
elsif str == '-INF'
|
||||||
@data = NEGATIVE_INF
|
NEGATIVE_INF
|
||||||
else
|
else
|
||||||
if /^[+\-\.\deE]+$/ !~ str
|
if /^[+\-\.\deE]+$/ !~ str
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
||||||
@ -308,7 +312,7 @@ private
|
|||||||
# Float("-1.4E") might fail on some system.
|
# Float("-1.4E") might fail on some system.
|
||||||
str << '0' if /e$/i =~ str
|
str << '0' if /e$/i =~ str
|
||||||
begin
|
begin
|
||||||
@data = narrow32bit(Float(str))
|
return narrow32bit(Float(str))
|
||||||
rescue ArgumentError
|
rescue ArgumentError
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
||||||
end
|
end
|
||||||
@ -357,28 +361,26 @@ class XSDDouble < XSDAnySimpleType
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def _set(value)
|
def screen_data(value)
|
||||||
# "NaN".to_f => 0 in some environment. libc?
|
# "NaN".to_f => 0 in some environment. libc?
|
||||||
if value.is_a?(Float)
|
if value.is_a?(Float)
|
||||||
@data = value
|
return value
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
str = value.to_s.strip
|
str = value.to_s.strip
|
||||||
if str == 'NaN'
|
if str == 'NaN'
|
||||||
@data = NaN
|
NaN
|
||||||
elsif str == 'INF'
|
elsif str == 'INF'
|
||||||
@data = POSITIVE_INF
|
POSITIVE_INF
|
||||||
elsif str == '-INF'
|
elsif str == '-INF'
|
||||||
@data = NEGATIVE_INF
|
NEGATIVE_INF
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
@data = Float(str)
|
return Float(str)
|
||||||
rescue ArgumentError
|
rescue ArgumentError
|
||||||
# '1.4e' cannot be parsed on some architecture.
|
# '1.4e' cannot be parsed on some architecture.
|
||||||
if /e\z/i =~ str
|
if /e\z/i =~ str
|
||||||
begin
|
begin
|
||||||
@data = Float(str + '0')
|
return Float(str + '0')
|
||||||
rescue ArgumentError
|
rescue ArgumentError
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
||||||
end
|
end
|
||||||
@ -429,24 +431,27 @@ class XSDDuration < XSDAnySimpleType
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def _set(value)
|
def screen_data(value)
|
||||||
/^([+\-]?)P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/ =~ value.to_s.strip
|
/^([+\-]?)P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/ =~ value.to_s.strip
|
||||||
unless Regexp.last_match
|
unless Regexp.last_match
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
|
||||||
end
|
end
|
||||||
|
|
||||||
if ($5 and ((!$2 and !$3 and !$4) or (!$6 and !$7 and !$8)))
|
if ($5 and ((!$2 and !$3 and !$4) or (!$6 and !$7 and !$8)))
|
||||||
# Should we allow 'PT5S' here?
|
# Should we allow 'PT5S' here?
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
|
||||||
end
|
end
|
||||||
|
sign = $1
|
||||||
|
year = $2.to_i
|
||||||
|
month = $3.to_i
|
||||||
|
day = $4.to_i
|
||||||
|
hour = $6.to_i
|
||||||
|
min = $7.to_i
|
||||||
|
sec = $8 ? XSDDecimal.new($8) : 0
|
||||||
|
[sign, year, month, day, hour, min, sec]
|
||||||
|
end
|
||||||
|
|
||||||
@sign = $1
|
def _set(ary)
|
||||||
@year = $2.to_i
|
@sign, @year, @month, @day, @hour, @min, @sec = ary
|
||||||
@month = $3.to_i
|
|
||||||
@day = $4.to_i
|
|
||||||
@hour = $6.to_i
|
|
||||||
@min = $7.to_i
|
|
||||||
@sec = $8 ? XSDDecimal.new($8) : 0
|
|
||||||
@data = _to_s
|
@data = _to_s
|
||||||
@data.freeze
|
@data.freeze
|
||||||
end
|
end
|
||||||
@ -524,18 +529,18 @@ module XSDDateTimeImpl
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def _set(t)
|
def screen_data(t)
|
||||||
set_datetime_init(t)
|
|
||||||
if (t.is_a?(Date))
|
if (t.is_a?(Date))
|
||||||
@data = t
|
t
|
||||||
elsif (t.is_a?(Time))
|
elsif (t.is_a?(Time))
|
||||||
sec, min, hour, mday, month, year = t.to_a[0..5]
|
sec, min, hour, mday, month, year = t.to_a[0..5]
|
||||||
diffday = t.usec.to_r / 1000000 / SecInDay
|
diffday = t.usec.to_r / 1000000 / SecInDay
|
||||||
of = t.utc_offset.to_r / SecInDay
|
of = t.utc_offset.to_r / SecInDay
|
||||||
@data = DateTime.civil(year, month, mday, hour, min, sec, of)
|
data = DateTime.civil(year, month, mday, hour, min, sec, of)
|
||||||
@data += diffday
|
data += diffday
|
||||||
|
data
|
||||||
else
|
else
|
||||||
set_str(t)
|
screen_data_str(t)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -557,11 +562,7 @@ class XSDDateTime < XSDAnySimpleType
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_datetime_init(t)
|
def screen_data_str(t)
|
||||||
@secfrac = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_str(t)
|
|
||||||
/^([+\-]?\d{4,})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d(?:\.(\d*))?)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
|
/^([+\-]?\d{4,})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d(?:\.(\d*))?)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
|
||||||
unless Regexp.last_match
|
unless Regexp.last_match
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
||||||
@ -569,7 +570,6 @@ private
|
|||||||
if $1 == '0000'
|
if $1 == '0000'
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
||||||
end
|
end
|
||||||
|
|
||||||
year = $1.to_i
|
year = $1.to_i
|
||||||
if year < 0
|
if year < 0
|
||||||
year += 1
|
year += 1
|
||||||
@ -581,22 +581,18 @@ private
|
|||||||
sec = $6.to_i
|
sec = $6.to_i
|
||||||
secfrac = $7
|
secfrac = $7
|
||||||
zonestr = $8
|
zonestr = $8
|
||||||
|
data = DateTime.civil(year, mon, mday, hour, min, sec, tz2of(zonestr))
|
||||||
@data = DateTime.civil(year, mon, mday, hour, min, sec, tz2of(zonestr))
|
|
||||||
@secfrac = secfrac
|
|
||||||
|
|
||||||
if secfrac
|
if secfrac
|
||||||
diffday = secfrac.to_i.to_r / (10 ** secfrac.size) / SecInDay
|
diffday = secfrac.to_i.to_r / (10 ** secfrac.size) / SecInDay
|
||||||
# jd = @data.jd
|
data += diffday
|
||||||
# day_fraction = @data.day_fraction + diffday
|
|
||||||
# @data = DateTime.new0(DateTime.jd_to_rjd(jd, day_fraction,
|
|
||||||
# @data.offset), @data.offset)
|
|
||||||
#
|
|
||||||
# Thanks to Funaba-san, above code can be simply written as below.
|
|
||||||
@data += diffday
|
|
||||||
# FYI: new0 and jd_to_rjd are not necessary to use if you don't have
|
# FYI: new0 and jd_to_rjd are not necessary to use if you don't have
|
||||||
# exceptional reason.
|
# exceptional reason.
|
||||||
end
|
end
|
||||||
|
[data, secfrac]
|
||||||
|
end
|
||||||
|
|
||||||
|
def _set(pair)
|
||||||
|
@data, @secfrac = pair
|
||||||
end
|
end
|
||||||
|
|
||||||
def _to_s
|
def _to_s
|
||||||
@ -607,7 +603,8 @@ private
|
|||||||
if @secfrac
|
if @secfrac
|
||||||
s << ".#{ @secfrac }"
|
s << ".#{ @secfrac }"
|
||||||
else
|
else
|
||||||
s << sprintf("%.16f", (@data.sec_fraction * SecInDay).to_f).sub(/^0/, '').sub(/0*$/, '')
|
s << sprintf("%.16f",
|
||||||
|
(@data.sec_fraction * SecInDay).to_f).sub(/^0/, '').sub(/0*$/, '')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
add_tz(s)
|
add_tz(s)
|
||||||
@ -627,29 +624,26 @@ class XSDTime < XSDAnySimpleType
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_datetime_init(t)
|
def screen_data_str(t)
|
||||||
@secfrac = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_str(t)
|
|
||||||
/^(\d\d):(\d\d):(\d\d(?:\.(\d*))?)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
|
/^(\d\d):(\d\d):(\d\d(?:\.(\d*))?)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
|
||||||
unless Regexp.last_match
|
unless Regexp.last_match
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
||||||
end
|
end
|
||||||
|
|
||||||
hour = $1.to_i
|
hour = $1.to_i
|
||||||
min = $2.to_i
|
min = $2.to_i
|
||||||
sec = $3.to_i
|
sec = $3.to_i
|
||||||
secfrac = $4
|
secfrac = $4
|
||||||
zonestr = $5
|
zonestr = $5
|
||||||
|
data = DateTime.civil(1, 1, 1, hour, min, sec, tz2of(zonestr))
|
||||||
@data = DateTime.civil(1, 1, 1, hour, min, sec, tz2of(zonestr))
|
|
||||||
@secfrac = secfrac
|
|
||||||
|
|
||||||
if secfrac
|
if secfrac
|
||||||
diffday = secfrac.to_i.to_r / (10 ** secfrac.size) / SecInDay
|
diffday = secfrac.to_i.to_r / (10 ** secfrac.size) / SecInDay
|
||||||
@data += diffday
|
data += diffday
|
||||||
end
|
end
|
||||||
|
[data, secfrac]
|
||||||
|
end
|
||||||
|
|
||||||
|
def _set(pair)
|
||||||
|
@data, @secfrac = pair
|
||||||
end
|
end
|
||||||
|
|
||||||
def _to_s
|
def _to_s
|
||||||
@ -658,7 +652,8 @@ private
|
|||||||
if @secfrac
|
if @secfrac
|
||||||
s << ".#{ @secfrac }"
|
s << ".#{ @secfrac }"
|
||||||
else
|
else
|
||||||
s << sprintf("%.16f", (@data.sec_fraction * SecInDay).to_f).sub(/^0/, '').sub(/0*$/, '')
|
s << sprintf("%.16f",
|
||||||
|
(@data.sec_fraction * SecInDay).to_f).sub(/^0/, '').sub(/0*$/, '')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
add_tz(s)
|
add_tz(s)
|
||||||
@ -677,15 +672,11 @@ class XSDDate < XSDAnySimpleType
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_datetime_init(t)
|
def screen_data_str(t)
|
||||||
end
|
|
||||||
|
|
||||||
def set_str(t)
|
|
||||||
/^([+\-]?\d{4,})-(\d\d)-(\d\d)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
|
/^([+\-]?\d{4,})-(\d\d)-(\d\d)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
|
||||||
unless Regexp.last_match
|
unless Regexp.last_match
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
||||||
end
|
end
|
||||||
|
|
||||||
year = $1.to_i
|
year = $1.to_i
|
||||||
if year < 0
|
if year < 0
|
||||||
year += 1
|
year += 1
|
||||||
@ -693,8 +684,7 @@ private
|
|||||||
mon = $2.to_i
|
mon = $2.to_i
|
||||||
mday = $3.to_i
|
mday = $3.to_i
|
||||||
zonestr = $4
|
zonestr = $4
|
||||||
|
DateTime.civil(year, mon, mday, 0, 0, 0, tz2of(zonestr))
|
||||||
@data = DateTime.civil(year, mon, mday, 0, 0, 0, tz2of(zonestr))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def _to_s
|
def _to_s
|
||||||
@ -716,23 +706,18 @@ class XSDGYearMonth < XSDAnySimpleType
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_datetime_init(t)
|
def screen_data_str(t)
|
||||||
end
|
|
||||||
|
|
||||||
def set_str(t)
|
|
||||||
/^([+\-]?\d{4,})-(\d\d)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
|
/^([+\-]?\d{4,})-(\d\d)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
|
||||||
unless Regexp.last_match
|
unless Regexp.last_match
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
||||||
end
|
end
|
||||||
|
|
||||||
year = $1.to_i
|
year = $1.to_i
|
||||||
if year < 0
|
if year < 0
|
||||||
year += 1
|
year += 1
|
||||||
end
|
end
|
||||||
mon = $2.to_i
|
mon = $2.to_i
|
||||||
zonestr = $3
|
zonestr = $3
|
||||||
|
DateTime.civil(year, mon, 1, 0, 0, 0, tz2of(zonestr))
|
||||||
@data = DateTime.civil(year, mon, 1, 0, 0, 0, tz2of(zonestr))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def _to_s
|
def _to_s
|
||||||
@ -754,22 +739,17 @@ class XSDGYear < XSDAnySimpleType
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_datetime_init(t)
|
def screen_data_str(t)
|
||||||
end
|
|
||||||
|
|
||||||
def set_str(t)
|
|
||||||
/^([+\-]?\d{4,})(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
|
/^([+\-]?\d{4,})(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
|
||||||
unless Regexp.last_match
|
unless Regexp.last_match
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
||||||
end
|
end
|
||||||
|
|
||||||
year = $1.to_i
|
year = $1.to_i
|
||||||
if year < 0
|
if year < 0
|
||||||
year += 1
|
year += 1
|
||||||
end
|
end
|
||||||
zonestr = $2
|
zonestr = $2
|
||||||
|
DateTime.civil(year, 1, 1, 0, 0, 0, tz2of(zonestr))
|
||||||
@data = DateTime.civil(year, 1, 1, 0, 0, 0, tz2of(zonestr))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def _to_s
|
def _to_s
|
||||||
@ -791,20 +771,15 @@ class XSDGMonthDay < XSDAnySimpleType
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_datetime_init(t)
|
def screen_data_str(t)
|
||||||
end
|
|
||||||
|
|
||||||
def set_str(t)
|
|
||||||
/^(\d\d)-(\d\d)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
|
/^(\d\d)-(\d\d)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
|
||||||
unless Regexp.last_match
|
unless Regexp.last_match
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
||||||
end
|
end
|
||||||
|
|
||||||
mon = $1.to_i
|
mon = $1.to_i
|
||||||
mday = $2.to_i
|
mday = $2.to_i
|
||||||
zonestr = $3
|
zonestr = $3
|
||||||
|
DateTime.civil(1, mon, mday, 0, 0, 0, tz2of(zonestr))
|
||||||
@data = DateTime.civil(1, mon, mday, 0, 0, 0, tz2of(zonestr))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def _to_s
|
def _to_s
|
||||||
@ -825,19 +800,14 @@ class XSDGDay < XSDAnySimpleType
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_datetime_init(t)
|
def screen_data_str(t)
|
||||||
end
|
|
||||||
|
|
||||||
def set_str(t)
|
|
||||||
/^(\d\d)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
|
/^(\d\d)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
|
||||||
unless Regexp.last_match
|
unless Regexp.last_match
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
||||||
end
|
end
|
||||||
|
|
||||||
mday = $1.to_i
|
mday = $1.to_i
|
||||||
zonestr = $2
|
zonestr = $2
|
||||||
|
DateTime.civil(1, 1, mday, 0, 0, 0, tz2of(zonestr))
|
||||||
@data = DateTime.civil(1, 1, mday, 0, 0, 0, tz2of(zonestr))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def _to_s
|
def _to_s
|
||||||
@ -858,19 +828,14 @@ class XSDGMonth < XSDAnySimpleType
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_datetime_init(t)
|
def screen_data_str(t)
|
||||||
end
|
|
||||||
|
|
||||||
def set_str(t)
|
|
||||||
/^(\d\d)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
|
/^(\d\d)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
|
||||||
unless Regexp.last_match
|
unless Regexp.last_match
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
|
||||||
end
|
end
|
||||||
|
|
||||||
mon = $1.to_i
|
mon = $1.to_i
|
||||||
zonestr = $2
|
zonestr = $2
|
||||||
|
DateTime.civil(1, mon, 1, 0, 0, 0, tz2of(zonestr))
|
||||||
@data = DateTime.civil(1, mon, 1, 0, 0, 0, tz2of(zonestr))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def _to_s
|
def _to_s
|
||||||
@ -903,9 +868,8 @@ class XSDHexBinary < XSDAnySimpleType
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def _set(value)
|
def screen_data(value)
|
||||||
@data = value.unpack("H*")[0]
|
value.unpack("H*")[0].tr('a-f', 'A-F')
|
||||||
@data.tr!('a-f', 'A-F')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -933,8 +897,8 @@ class XSDBase64Binary < XSDAnySimpleType
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def _set(value)
|
def screen_data(value)
|
||||||
@data = [value].pack("m").strip
|
[value].pack("m").strip
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -949,9 +913,9 @@ class XSDAnyURI < XSDAnySimpleType
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def _set(value)
|
def screen_data(value)
|
||||||
begin
|
begin
|
||||||
@data = URI.parse(value.to_s.strip)
|
URI.parse(value.to_s.strip)
|
||||||
rescue URI::InvalidURIError
|
rescue URI::InvalidURIError
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
|
||||||
end
|
end
|
||||||
@ -969,14 +933,18 @@ class XSDQName < XSDAnySimpleType
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def _set(value)
|
def screen_data(value)
|
||||||
/^(?:([^:]+):)?([^:]+)$/ =~ value.to_s.strip
|
/^(?:([^:]+):)?([^:]+)$/ =~ value.to_s.strip
|
||||||
unless Regexp.last_match
|
unless Regexp.last_match
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
|
||||||
end
|
end
|
||||||
|
prefix = $1
|
||||||
|
localpart = $2
|
||||||
|
[prefix, localpart]
|
||||||
|
end
|
||||||
|
|
||||||
@prefix = $1
|
def _set(pair)
|
||||||
@localpart = $2
|
@prefix, @localpart = pair
|
||||||
@data = _to_s
|
@data = _to_s
|
||||||
@data.freeze
|
@data.freeze
|
||||||
end
|
end
|
||||||
@ -1005,7 +973,7 @@ class XSDNormalizedString < XSDString
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def _set(value)
|
def screen_data(value)
|
||||||
if /[\t\r\n]/ =~ value
|
if /[\t\r\n]/ =~ value
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
|
||||||
end
|
end
|
||||||
@ -1024,12 +992,17 @@ class XSDInteger < XSDDecimal
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_str(str)
|
def screen_data_str(str)
|
||||||
begin
|
begin
|
||||||
@data = Integer(str)
|
data = Integer(str)
|
||||||
rescue ArgumentError
|
rescue ArgumentError
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
||||||
end
|
end
|
||||||
|
data
|
||||||
|
end
|
||||||
|
|
||||||
|
def _set(value)
|
||||||
|
@data = value
|
||||||
end
|
end
|
||||||
|
|
||||||
def _to_s()
|
def _to_s()
|
||||||
@ -1048,15 +1021,20 @@ class XSDLong < XSDInteger
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_str(str)
|
def screen_data_str(str)
|
||||||
begin
|
begin
|
||||||
@data = Integer(str)
|
data = Integer(str)
|
||||||
rescue ArgumentError
|
rescue ArgumentError
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
||||||
end
|
end
|
||||||
unless validate(@data)
|
unless validate(data)
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
||||||
end
|
end
|
||||||
|
data
|
||||||
|
end
|
||||||
|
|
||||||
|
def _set(value)
|
||||||
|
@data = value
|
||||||
end
|
end
|
||||||
|
|
||||||
MaxInclusive = +9223372036854775807
|
MaxInclusive = +9223372036854775807
|
||||||
@ -1077,15 +1055,20 @@ class XSDInt < XSDLong
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_str(str)
|
def screen_data_str(str)
|
||||||
begin
|
begin
|
||||||
@data = Integer(str)
|
data = Integer(str)
|
||||||
rescue ArgumentError
|
rescue ArgumentError
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
||||||
end
|
end
|
||||||
unless validate(@data)
|
unless validate(data)
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
||||||
end
|
end
|
||||||
|
data
|
||||||
|
end
|
||||||
|
|
||||||
|
def _set(value)
|
||||||
|
@data = value
|
||||||
end
|
end
|
||||||
|
|
||||||
MaxInclusive = +2147483647
|
MaxInclusive = +2147483647
|
||||||
@ -1106,15 +1089,20 @@ class XSDShort < XSDInt
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_str(str)
|
def screen_data_str(str)
|
||||||
begin
|
begin
|
||||||
@data = Integer(str)
|
data = Integer(str)
|
||||||
rescue ArgumentError
|
rescue ArgumentError
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
||||||
end
|
end
|
||||||
unless validate(@data)
|
unless validate(data)
|
||||||
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
|
||||||
end
|
end
|
||||||
|
data
|
||||||
|
end
|
||||||
|
|
||||||
|
def _set(value)
|
||||||
|
@data = value
|
||||||
end
|
end
|
||||||
|
|
||||||
MaxInclusive = +32767
|
MaxInclusive = +32767
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# XSD4R - XML QName definition.
|
# XSD4R - XML QName definition.
|
||||||
# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
# Copyright (C) 2002, 2003, 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
||||||
|
|
||||||
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
||||||
# redistribute it and/or modify it under the same terms of Ruby's license;
|
# redistribute it and/or modify it under the same terms of Ruby's license;
|
||||||
@ -19,7 +19,7 @@ class QName
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dup_name(name)
|
def dup_name(name)
|
||||||
self.class.new(@namespace, name)
|
::XSD::QName.new(@namespace, name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def match(rhs)
|
def match(rhs)
|
||||||
@ -55,6 +55,11 @@ class QName
|
|||||||
"{#{ namespace }}#{ name }"
|
"{#{ namespace }}#{ name }"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def inspect
|
||||||
|
sprintf("#<%s:0x%x %s>", self.class.name, __id__,
|
||||||
|
"{#{ namespace }}#{ name }")
|
||||||
|
end
|
||||||
|
|
||||||
NormalizedNameRegexp = /^\{([^}]*)\}(.*)$/
|
NormalizedNameRegexp = /^\{([^}]*)\}(.*)$/
|
||||||
def parse(str)
|
def parse(str)
|
||||||
NormalizedNameRegexp =~ str
|
NormalizedNameRegexp =~ str
|
||||||
|
41
sample/soap/authheader/authmgr.rb
Normal file
41
sample/soap/authheader/authmgr.rb
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
class Authmgr
|
||||||
|
def initialize
|
||||||
|
@users = {
|
||||||
|
'NaHi' => 'passwd',
|
||||||
|
'HiNa' => 'wspass'
|
||||||
|
}
|
||||||
|
@sessions = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
def login(userid, passwd)
|
||||||
|
userid and passwd and @users[userid] == passwd
|
||||||
|
end
|
||||||
|
|
||||||
|
# returns userid
|
||||||
|
def auth(sessionid)
|
||||||
|
@sessions[sessionid]
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_session(userid)
|
||||||
|
while true
|
||||||
|
key = create_sessionkey
|
||||||
|
break unless @sessions[key]
|
||||||
|
end
|
||||||
|
@sessions[key] = userid
|
||||||
|
key
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_session(userid)
|
||||||
|
@sessions.index(userid)
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy_session(sessionkey)
|
||||||
|
@sessions.delete(sessionkey)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def create_sessionkey
|
||||||
|
Time.now.usec.to_s
|
||||||
|
end
|
||||||
|
end
|
40
sample/soap/authheader/client.rb
Normal file
40
sample/soap/authheader/client.rb
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
require 'soap/rpc/driver'
|
||||||
|
require 'soap/header/simplehandler'
|
||||||
|
|
||||||
|
server = ARGV.shift || 'http://localhost:7000/'
|
||||||
|
|
||||||
|
class ClientAuthHeaderHandler < SOAP::Header::SimpleHandler
|
||||||
|
MyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "auth")
|
||||||
|
|
||||||
|
def initialize(userid, passwd)
|
||||||
|
super(MyHeaderName)
|
||||||
|
@sessionid = nil
|
||||||
|
@userid = userid
|
||||||
|
@passwd = passwd
|
||||||
|
@mustunderstand = true
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_simple_outbound
|
||||||
|
if @sessionid
|
||||||
|
{ "sessionid" => @sessionid }
|
||||||
|
else
|
||||||
|
{ "userid" => @userid, "passwd" => @passwd }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_simple_inbound(my_header, mustunderstand)
|
||||||
|
@sessionid = my_header["sessionid"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
ns = 'http://tempuri.org/authHeaderPort'
|
||||||
|
serv = SOAP::RPC::Driver.new(server, ns)
|
||||||
|
serv.add_method('deposit', 'amt')
|
||||||
|
serv.add_method('withdrawal', 'amt')
|
||||||
|
|
||||||
|
serv.headerhandler << ClientAuthHeaderHandler.new('NaHi', 'passwd')
|
||||||
|
|
||||||
|
serv.wiredump_dev = STDOUT
|
||||||
|
|
||||||
|
p serv.deposit(150)
|
||||||
|
p serv.withdrawal(120)
|
39
sample/soap/authheader/client2.rb
Normal file
39
sample/soap/authheader/client2.rb
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
require 'soap/rpc/driver'
|
||||||
|
require 'soap/header/simplehandler'
|
||||||
|
|
||||||
|
server = ARGV.shift || 'http://localhost:7000/'
|
||||||
|
|
||||||
|
class ClientAuthHeaderHandler < SOAP::Header::SimpleHandler
|
||||||
|
MyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "auth")
|
||||||
|
|
||||||
|
def initialize(userid, passwd)
|
||||||
|
super(MyHeaderName)
|
||||||
|
@sessionid = nil
|
||||||
|
@userid = userid
|
||||||
|
@passwd = passwd
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_simple_outbound
|
||||||
|
if @sessionid
|
||||||
|
{ "sessionid" => @sessionid }
|
||||||
|
else
|
||||||
|
{ "userid" => @userid, "passwd" => @passwd }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_simple_inbound(my_header, mustunderstand)
|
||||||
|
@sessionid = my_header["sessionid"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
ns = 'http://tempuri.org/authHeaderPort'
|
||||||
|
serv = SOAP::RPC::Driver.new(server, ns)
|
||||||
|
serv.add_method('deposit', 'amt')
|
||||||
|
serv.add_method('withdrawal', 'amt')
|
||||||
|
|
||||||
|
serv.headerhandler << ClientAuthHeaderHandler.new('NaHi', 'passwd')
|
||||||
|
|
||||||
|
serv.wiredump_dev = STDOUT
|
||||||
|
|
||||||
|
p serv.deposit(150)
|
||||||
|
p serv.withdrawal(120)
|
72
sample/soap/authheader/server.rb
Normal file
72
sample/soap/authheader/server.rb
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require 'soap/rpc/standaloneServer'
|
||||||
|
require 'soap/header/simplehandler'
|
||||||
|
require 'authmgr'
|
||||||
|
|
||||||
|
class AuthHeaderPortServer < SOAP::RPC::StandaloneServer
|
||||||
|
class AuthHeaderService
|
||||||
|
def self.create
|
||||||
|
new
|
||||||
|
end
|
||||||
|
|
||||||
|
def deposit(amt)
|
||||||
|
"deposit #{amt} OK"
|
||||||
|
end
|
||||||
|
|
||||||
|
def withdrawal(amt)
|
||||||
|
"withdrawal #{amt} OK"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Name = 'http://tempuri.org/authHeaderPort'
|
||||||
|
def initialize(*arg)
|
||||||
|
super
|
||||||
|
add_rpc_servant(AuthHeaderService.new, Name)
|
||||||
|
add_rpc_request_headerhandler(ServerAuthHeaderHandler)
|
||||||
|
end
|
||||||
|
|
||||||
|
class ServerAuthHeaderHandler < SOAP::Header::SimpleHandler
|
||||||
|
MyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "auth")
|
||||||
|
|
||||||
|
@authmgr = Authmgr.new
|
||||||
|
def self.create
|
||||||
|
new(@authmgr)
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(authmgr)
|
||||||
|
super(MyHeaderName)
|
||||||
|
@authmgr = authmgr
|
||||||
|
@userid = @sessionid = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_simple_outbound
|
||||||
|
{ "sessionid" => @sessionid }
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_simple_inbound(my_header, mu)
|
||||||
|
auth = false
|
||||||
|
userid = my_header["userid"]
|
||||||
|
passwd = my_header["passwd"]
|
||||||
|
if @authmgr.login(userid, passwd)
|
||||||
|
auth = true
|
||||||
|
elsif sessionid = my_header["sessionid"]
|
||||||
|
if userid = @authmgr.auth(sessionid)
|
||||||
|
@authmgr.destroy_session(sessionid)
|
||||||
|
auth = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
raise RuntimeError.new("authentication failed") unless auth
|
||||||
|
@userid = userid
|
||||||
|
@sessionid = @authmgr.create_session(userid)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if $0 == __FILE__
|
||||||
|
svr = AuthHeaderPortServer.new('AuthHeaderPortServer', nil, '0.0.0.0', 7000)
|
||||||
|
trap(:INT) do
|
||||||
|
svr.shutdown
|
||||||
|
end
|
||||||
|
status = svr.start
|
||||||
|
end
|
77
sample/soap/authheader/server2.rb
Normal file
77
sample/soap/authheader/server2.rb
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require 'soap/rpc/standaloneServer'
|
||||||
|
require 'soap/header/simplehandler'
|
||||||
|
require 'authmgr'
|
||||||
|
|
||||||
|
class AuthHeaderPortServer < SOAP::RPC::StandaloneServer
|
||||||
|
class AuthHeaderService
|
||||||
|
def self.create
|
||||||
|
new
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(authmgr)
|
||||||
|
@authmgr = authmgr
|
||||||
|
end
|
||||||
|
|
||||||
|
def login(userid, passwd)
|
||||||
|
if @authmgr.login(userid, passwd)
|
||||||
|
@authmgr.create_session(userid)
|
||||||
|
else
|
||||||
|
raise RuntimeError.new("authentication failed")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def deposit(amt)
|
||||||
|
"deposit #{amt} OK"
|
||||||
|
end
|
||||||
|
|
||||||
|
def withdrawal(amt)
|
||||||
|
"withdrawal #{amt} OK"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Name = 'http://tempuri.org/authHeaderPort'
|
||||||
|
def initialize(*arg)
|
||||||
|
super
|
||||||
|
add_rpc_servant(AuthHeaderService.new, Name)
|
||||||
|
ServerAuthHeaderHandler.init
|
||||||
|
add_rpc_request_headerhandler(ServerAuthHeaderHandler)
|
||||||
|
end
|
||||||
|
|
||||||
|
class ServerAuthHeaderHandler < SOAP::Header::SimpleHandler
|
||||||
|
MyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "auth")
|
||||||
|
|
||||||
|
def self.create
|
||||||
|
new(@authmgr)
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(authmgr)
|
||||||
|
super(MyHeaderName)
|
||||||
|
@authmgr = authmgr
|
||||||
|
@sessionid = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_simple_outbound
|
||||||
|
if @sessionid
|
||||||
|
{ "sessionid" => @sessionid }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_simple_inbound(my_header, mu)
|
||||||
|
auth = false
|
||||||
|
if sessionid = my_header["sessionid"]
|
||||||
|
if userid = @authmgr.auth(sessionid)
|
||||||
|
@authmgr.destroy_session(sessionid)
|
||||||
|
@session_id = @authmgr.create_session(userid)
|
||||||
|
auth = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
raise RuntimeError.new("authentication failed") unless auth
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if $0 == __FILE__
|
||||||
|
status = AuthHeaderPortServer.new('AuthHeaderPortServer', nil, '0.0.0.0', 7000).start
|
||||||
|
end
|
332
sample/soap/raa2.4/raa.rb
Normal file
332
sample/soap/raa2.4/raa.rb
Normal file
@ -0,0 +1,332 @@
|
|||||||
|
# http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/
|
||||||
|
class Gem
|
||||||
|
@@schema_type = "Gem"
|
||||||
|
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/"
|
||||||
|
|
||||||
|
def id
|
||||||
|
@id
|
||||||
|
end
|
||||||
|
|
||||||
|
def id=(value)
|
||||||
|
@id = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def category
|
||||||
|
@category
|
||||||
|
end
|
||||||
|
|
||||||
|
def category=(value)
|
||||||
|
@category = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def owner
|
||||||
|
@owner
|
||||||
|
end
|
||||||
|
|
||||||
|
def owner=(value)
|
||||||
|
@owner = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def project
|
||||||
|
@project
|
||||||
|
end
|
||||||
|
|
||||||
|
def project=(value)
|
||||||
|
@project = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def updated
|
||||||
|
@updated
|
||||||
|
end
|
||||||
|
|
||||||
|
def updated=(value)
|
||||||
|
@updated = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def created
|
||||||
|
@created
|
||||||
|
end
|
||||||
|
|
||||||
|
def created=(value)
|
||||||
|
@created = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(id = nil,
|
||||||
|
category = nil,
|
||||||
|
owner = nil,
|
||||||
|
project = nil,
|
||||||
|
updated = nil,
|
||||||
|
created = nil)
|
||||||
|
@id = id
|
||||||
|
@category = category
|
||||||
|
@owner = owner
|
||||||
|
@project = project
|
||||||
|
@updated = updated
|
||||||
|
@created = created
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/
|
||||||
|
class Category
|
||||||
|
@@schema_type = "Category"
|
||||||
|
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/"
|
||||||
|
|
||||||
|
def major
|
||||||
|
@major
|
||||||
|
end
|
||||||
|
|
||||||
|
def major=(value)
|
||||||
|
@major = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def minor
|
||||||
|
@minor
|
||||||
|
end
|
||||||
|
|
||||||
|
def minor=(value)
|
||||||
|
@minor = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(major = nil,
|
||||||
|
minor = nil)
|
||||||
|
@major = major
|
||||||
|
@minor = minor
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/
|
||||||
|
class Owner
|
||||||
|
@@schema_type = "Owner"
|
||||||
|
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/"
|
||||||
|
|
||||||
|
def id
|
||||||
|
@id
|
||||||
|
end
|
||||||
|
|
||||||
|
def id=(value)
|
||||||
|
@id = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def email
|
||||||
|
@email
|
||||||
|
end
|
||||||
|
|
||||||
|
def email=(value)
|
||||||
|
@email = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def name
|
||||||
|
@name
|
||||||
|
end
|
||||||
|
|
||||||
|
def name=(value)
|
||||||
|
@name = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(id = nil,
|
||||||
|
email = nil,
|
||||||
|
name = nil)
|
||||||
|
@id = id
|
||||||
|
@email = email
|
||||||
|
@name = name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/
|
||||||
|
class Project
|
||||||
|
@@schema_type = "Project"
|
||||||
|
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/"
|
||||||
|
|
||||||
|
def name
|
||||||
|
@name
|
||||||
|
end
|
||||||
|
|
||||||
|
def name=(value)
|
||||||
|
@name = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def short_description
|
||||||
|
@short_description
|
||||||
|
end
|
||||||
|
|
||||||
|
def short_description=(value)
|
||||||
|
@short_description = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def version
|
||||||
|
@version
|
||||||
|
end
|
||||||
|
|
||||||
|
def version=(value)
|
||||||
|
@version = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def status
|
||||||
|
@status
|
||||||
|
end
|
||||||
|
|
||||||
|
def status=(value)
|
||||||
|
@status = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def url
|
||||||
|
@url
|
||||||
|
end
|
||||||
|
|
||||||
|
def url=(value)
|
||||||
|
@url = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def download
|
||||||
|
@download
|
||||||
|
end
|
||||||
|
|
||||||
|
def download=(value)
|
||||||
|
@download = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def license
|
||||||
|
@license
|
||||||
|
end
|
||||||
|
|
||||||
|
def license=(value)
|
||||||
|
@license = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def description
|
||||||
|
@description
|
||||||
|
end
|
||||||
|
|
||||||
|
def description=(value)
|
||||||
|
@description = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def updated
|
||||||
|
@updated
|
||||||
|
end
|
||||||
|
|
||||||
|
def updated=(value)
|
||||||
|
@updated = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def history
|
||||||
|
@history
|
||||||
|
end
|
||||||
|
|
||||||
|
def history=(value)
|
||||||
|
@history = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def dependency
|
||||||
|
@dependency
|
||||||
|
end
|
||||||
|
|
||||||
|
def dependency=(value)
|
||||||
|
@dependency = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(name = nil,
|
||||||
|
short_description = nil,
|
||||||
|
version = nil,
|
||||||
|
status = nil,
|
||||||
|
url = nil,
|
||||||
|
download = nil,
|
||||||
|
license = nil,
|
||||||
|
description = nil,
|
||||||
|
updated = nil,
|
||||||
|
history = nil,
|
||||||
|
dependency = nil)
|
||||||
|
@name = name
|
||||||
|
@short_description = short_description
|
||||||
|
@version = version
|
||||||
|
@status = status
|
||||||
|
@url = url
|
||||||
|
@download = download
|
||||||
|
@license = license
|
||||||
|
@description = description
|
||||||
|
@updated = updated
|
||||||
|
@history = history
|
||||||
|
@dependency = dependency
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/
|
||||||
|
class ProjectDependency
|
||||||
|
@@schema_type = "ProjectDependency"
|
||||||
|
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/"
|
||||||
|
|
||||||
|
def project
|
||||||
|
@project
|
||||||
|
end
|
||||||
|
|
||||||
|
def project=(value)
|
||||||
|
@project = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def version
|
||||||
|
@version
|
||||||
|
end
|
||||||
|
|
||||||
|
def version=(value)
|
||||||
|
@version = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def description
|
||||||
|
@description
|
||||||
|
end
|
||||||
|
|
||||||
|
def description=(value)
|
||||||
|
@description = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(project = nil,
|
||||||
|
version = nil,
|
||||||
|
description = nil)
|
||||||
|
@project = project
|
||||||
|
@version = version
|
||||||
|
@description = description
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/
|
||||||
|
class GemArray < Array
|
||||||
|
# Contents type should be dumped here...
|
||||||
|
@@schema_type = "GemArray"
|
||||||
|
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/"
|
||||||
|
end
|
||||||
|
|
||||||
|
# http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/
|
||||||
|
class OwnerArray < Array
|
||||||
|
# Contents type should be dumped here...
|
||||||
|
@@schema_type = "OwnerArray"
|
||||||
|
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/"
|
||||||
|
end
|
||||||
|
|
||||||
|
# http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/
|
||||||
|
class ProjectArray < Array
|
||||||
|
# Contents type should be dumped here...
|
||||||
|
@@schema_type = "ProjectArray"
|
||||||
|
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/"
|
||||||
|
end
|
||||||
|
|
||||||
|
# http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/
|
||||||
|
class ProjectDependencyArray < Array
|
||||||
|
# Contents type should be dumped here...
|
||||||
|
@@schema_type = "ProjectDependencyArray"
|
||||||
|
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/"
|
||||||
|
end
|
||||||
|
|
||||||
|
# http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/
|
||||||
|
class StringArray < Array
|
||||||
|
# Contents type should be dumped here...
|
||||||
|
@@schema_type = "StringArray"
|
||||||
|
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/"
|
||||||
|
end
|
||||||
|
|
||||||
|
# http://xml.apache.org/xml-soap
|
||||||
|
class Map < Array
|
||||||
|
# Contents type should be dumped here...
|
||||||
|
@@schema_type = "Map"
|
||||||
|
@@schema_ns = "http://xml.apache.org/xml-soap"
|
||||||
|
end
|
||||||
|
|
255
sample/soap/raa2.4/raaDriver.rb
Normal file
255
sample/soap/raa2.4/raaDriver.rb
Normal file
@ -0,0 +1,255 @@
|
|||||||
|
require 'raa.rb'
|
||||||
|
|
||||||
|
require 'soap/rpc/driver'
|
||||||
|
|
||||||
|
class RaaServicePortType < SOAP::RPC::Driver
|
||||||
|
TargetNamespace = "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
MappingRegistry = ::SOAP::Mapping::Registry.new
|
||||||
|
|
||||||
|
MappingRegistry.set(
|
||||||
|
Gem,
|
||||||
|
::SOAP::SOAPStruct,
|
||||||
|
::SOAP::Mapping::Registry::TypedStructFactory,
|
||||||
|
{ :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/", "Gem") }
|
||||||
|
)
|
||||||
|
MappingRegistry.set(
|
||||||
|
Category,
|
||||||
|
::SOAP::SOAPStruct,
|
||||||
|
::SOAP::Mapping::Registry::TypedStructFactory,
|
||||||
|
{ :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/", "Category") }
|
||||||
|
)
|
||||||
|
MappingRegistry.set(
|
||||||
|
Owner,
|
||||||
|
::SOAP::SOAPStruct,
|
||||||
|
::SOAP::Mapping::Registry::TypedStructFactory,
|
||||||
|
{ :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/", "Owner") }
|
||||||
|
)
|
||||||
|
MappingRegistry.set(
|
||||||
|
Project,
|
||||||
|
::SOAP::SOAPStruct,
|
||||||
|
::SOAP::Mapping::Registry::TypedStructFactory,
|
||||||
|
{ :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/", "Project") }
|
||||||
|
)
|
||||||
|
MappingRegistry.set(
|
||||||
|
ProjectArray,
|
||||||
|
::SOAP::SOAPArray,
|
||||||
|
::SOAP::Mapping::Registry::TypedArrayFactory,
|
||||||
|
{ :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/", "Project") }
|
||||||
|
)
|
||||||
|
MappingRegistry.set(
|
||||||
|
ProjectDependencyArray,
|
||||||
|
::SOAP::SOAPArray,
|
||||||
|
::SOAP::Mapping::Registry::TypedArrayFactory,
|
||||||
|
{ :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/", "ProjectDependency") }
|
||||||
|
)
|
||||||
|
MappingRegistry.set(
|
||||||
|
StringArray,
|
||||||
|
::SOAP::SOAPArray,
|
||||||
|
::SOAP::Mapping::Registry::TypedArrayFactory,
|
||||||
|
{ :type => XSD::QName.new("http://www.w3.org/2001/XMLSchema", "string") }
|
||||||
|
)
|
||||||
|
MappingRegistry.set(
|
||||||
|
Map,
|
||||||
|
::SOAP::SOAPArray,
|
||||||
|
::SOAP::Mapping::Registry::TypedArrayFactory,
|
||||||
|
{ :type => XSD::QName.new("http://www.w3.org/2001/XMLSchema", "anyType") }
|
||||||
|
)
|
||||||
|
MappingRegistry.set(
|
||||||
|
OwnerArray,
|
||||||
|
::SOAP::SOAPArray,
|
||||||
|
::SOAP::Mapping::Registry::TypedArrayFactory,
|
||||||
|
{ :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/", "Owner") }
|
||||||
|
)
|
||||||
|
MappingRegistry.set(
|
||||||
|
ProjectDependency,
|
||||||
|
::SOAP::SOAPStruct,
|
||||||
|
::SOAP::Mapping::Registry::TypedStructFactory,
|
||||||
|
{ :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/", "ProjectDependency") }
|
||||||
|
)
|
||||||
|
Methods = [
|
||||||
|
["gem", "gem",
|
||||||
|
[
|
||||||
|
["in", "name", [SOAP::SOAPString]],
|
||||||
|
["retval", "return", [::SOAP::SOAPStruct, "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/", "Gem"]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
],
|
||||||
|
["dependents", "dependents",
|
||||||
|
[
|
||||||
|
["in", "name", [SOAP::SOAPString]],
|
||||||
|
["in", "version", [SOAP::SOAPString]],
|
||||||
|
["retval", "return", [::SOAP::SOAPArray, "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/", "ProjectDependency"]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
],
|
||||||
|
["names", "names",
|
||||||
|
[
|
||||||
|
["retval", "return", [::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "string"]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
],
|
||||||
|
["size", "size",
|
||||||
|
[
|
||||||
|
["retval", "return", [SOAP::SOAPInt]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
],
|
||||||
|
["list_by_category", "list_by_category",
|
||||||
|
[
|
||||||
|
["in", "major", [SOAP::SOAPString]],
|
||||||
|
["in", "minor", [SOAP::SOAPString]],
|
||||||
|
["retval", "return", [::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "string"]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
],
|
||||||
|
["tree_by_category", "tree_by_category",
|
||||||
|
[
|
||||||
|
["retval", "return", [::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "anyType"]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
],
|
||||||
|
["list_recent_updated", "list_recent_updated",
|
||||||
|
[
|
||||||
|
["in", "idx", [SOAP::SOAPInt]],
|
||||||
|
["retval", "return", [::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "string"]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
],
|
||||||
|
["list_recent_created", "list_recent_created",
|
||||||
|
[
|
||||||
|
["in", "idx", [SOAP::SOAPInt]],
|
||||||
|
["retval", "return", [::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "string"]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
],
|
||||||
|
["list_updated_since", "list_updated_since",
|
||||||
|
[
|
||||||
|
["in", "date", [SOAP::SOAPDateTime]],
|
||||||
|
["in", "idx", [SOAP::SOAPInt]],
|
||||||
|
["retval", "return", [::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "string"]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
],
|
||||||
|
["list_created_since", "list_created_since",
|
||||||
|
[
|
||||||
|
["in", "date", [SOAP::SOAPDateTime]],
|
||||||
|
["in", "idx", [SOAP::SOAPInt]],
|
||||||
|
["retval", "return", [::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "string"]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
],
|
||||||
|
["list_by_owner", "list_by_owner",
|
||||||
|
[
|
||||||
|
["in", "owner_id", [SOAP::SOAPInt]],
|
||||||
|
["retval", "return", [::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "string"]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
],
|
||||||
|
["search_name", "search_name",
|
||||||
|
[
|
||||||
|
["in", "substring", [SOAP::SOAPString]],
|
||||||
|
["in", "idx", [SOAP::SOAPInt]],
|
||||||
|
["retval", "return", [::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "string"]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
],
|
||||||
|
["search_short_description", "search_short_description",
|
||||||
|
[
|
||||||
|
["in", "substring", [SOAP::SOAPString]],
|
||||||
|
["in", "idx", [SOAP::SOAPInt]],
|
||||||
|
["retval", "return", [::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "string"]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
],
|
||||||
|
["search_owner", "search_owner",
|
||||||
|
[
|
||||||
|
["in", "substring", [SOAP::SOAPString]],
|
||||||
|
["in", "idx", [SOAP::SOAPInt]],
|
||||||
|
["retval", "return", [::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "string"]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
],
|
||||||
|
["search_version", "search_version",
|
||||||
|
[
|
||||||
|
["in", "substring", [SOAP::SOAPString]],
|
||||||
|
["in", "idx", [SOAP::SOAPInt]],
|
||||||
|
["retval", "return", [::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "string"]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
],
|
||||||
|
["search_status", "search_status",
|
||||||
|
[
|
||||||
|
["in", "substring", [SOAP::SOAPString]],
|
||||||
|
["in", "idx", [SOAP::SOAPInt]],
|
||||||
|
["retval", "return", [::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "string"]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
],
|
||||||
|
["search_description", "search_description",
|
||||||
|
[
|
||||||
|
["in", "substring", [SOAP::SOAPString]],
|
||||||
|
["in", "idx", [SOAP::SOAPInt]],
|
||||||
|
["retval", "return", [::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "string"]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
],
|
||||||
|
["search", "search",
|
||||||
|
[
|
||||||
|
["in", "substring", [SOAP::SOAPString]],
|
||||||
|
["retval", "return", [::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "anyType"]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
],
|
||||||
|
["owner", "owner",
|
||||||
|
[
|
||||||
|
["in", "owner_id", [SOAP::SOAPInt]],
|
||||||
|
["retval", "return", [::SOAP::SOAPStruct, "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/", "Owner"]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
],
|
||||||
|
["list_owner", "list_owner",
|
||||||
|
[
|
||||||
|
["in", "idx", [SOAP::SOAPInt]],
|
||||||
|
["retval", "return", [::SOAP::SOAPArray, "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/", "Owner"]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
],
|
||||||
|
["update", "update",
|
||||||
|
[
|
||||||
|
["in", "name", [SOAP::SOAPString]],
|
||||||
|
["in", "pass", [SOAP::SOAPString]],
|
||||||
|
["in", "gem", [::SOAP::SOAPStruct, "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/", "Gem"]],
|
||||||
|
["retval", "return", [::SOAP::SOAPStruct, "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/", "Gem"]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
],
|
||||||
|
["update_pass", "update_pass",
|
||||||
|
[
|
||||||
|
["in", "name", [SOAP::SOAPString]],
|
||||||
|
["in", "oldpass", [SOAP::SOAPString]],
|
||||||
|
["in", "newpass", [SOAP::SOAPString]]
|
||||||
|
],
|
||||||
|
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
DefaultEndpointUrl = "http://raa.ruby-lang.org/soapsrv"
|
||||||
|
|
||||||
|
def initialize(endpoint_url = nil)
|
||||||
|
endpoint_url ||= DefaultEndpointUrl
|
||||||
|
super(endpoint_url, nil)
|
||||||
|
self.mapping_registry = MappingRegistry
|
||||||
|
init_methods
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def init_methods
|
||||||
|
Methods.each do |name_as, name, params, soapaction, namespace|
|
||||||
|
qname = XSD::QName.new(namespace, name_as)
|
||||||
|
@proxy.add_method(qname, soapaction, name, params)
|
||||||
|
add_rpc_method_interface(name, params)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
354
sample/soap/raa2.4/raaServiceClient.rb
Normal file
354
sample/soap/raa2.4/raaServiceClient.rb
Normal file
@ -0,0 +1,354 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
require 'raaDriver.rb'
|
||||||
|
|
||||||
|
endpoint_url = ARGV.shift
|
||||||
|
obj = RaaServicePortType.new(endpoint_url)
|
||||||
|
|
||||||
|
# Uncomment the below line to see SOAP wiredumps.
|
||||||
|
# obj.wiredump_dev = STDERR
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# gem(name)
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# name - {http://www.w3.org/2001/XMLSchema}string
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# return Gem - {http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/}Gem
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
name = nil
|
||||||
|
puts obj.gem(name)
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# dependents(name, version)
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# name - {http://www.w3.org/2001/XMLSchema}string
|
||||||
|
# version - {http://www.w3.org/2001/XMLSchema}string
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# return ProjectDependencyArray - {http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/}ProjectDependencyArray
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
name = version = nil
|
||||||
|
puts obj.dependents(name, version)
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# names
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# N/A
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# return StringArray - {http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/}StringArray
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
|
||||||
|
puts obj.names
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# size
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# N/A
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# return - {http://www.w3.org/2001/XMLSchema}int
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
|
||||||
|
puts obj.size
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# list_by_category(major, minor)
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# major - {http://www.w3.org/2001/XMLSchema}string
|
||||||
|
# minor - {http://www.w3.org/2001/XMLSchema}string
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# return StringArray - {http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/}StringArray
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
major = minor = nil
|
||||||
|
puts obj.list_by_category(major, minor)
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# tree_by_category
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# N/A
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# return Map - {http://xml.apache.org/xml-soap}Map
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
|
||||||
|
puts obj.tree_by_category
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# list_recent_updated(idx)
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# idx - {http://www.w3.org/2001/XMLSchema}int
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# return StringArray - {http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/}StringArray
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
idx = nil
|
||||||
|
puts obj.list_recent_updated(idx)
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# list_recent_created(idx)
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# idx - {http://www.w3.org/2001/XMLSchema}int
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# return StringArray - {http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/}StringArray
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
idx = nil
|
||||||
|
puts obj.list_recent_created(idx)
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# list_updated_since(date, idx)
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# date - {http://www.w3.org/2001/XMLSchema}dateTime
|
||||||
|
# idx - {http://www.w3.org/2001/XMLSchema}int
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# return StringArray - {http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/}StringArray
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
date = idx = nil
|
||||||
|
puts obj.list_updated_since(date, idx)
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# list_created_since(date, idx)
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# date - {http://www.w3.org/2001/XMLSchema}dateTime
|
||||||
|
# idx - {http://www.w3.org/2001/XMLSchema}int
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# return StringArray - {http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/}StringArray
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
date = idx = nil
|
||||||
|
puts obj.list_created_since(date, idx)
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# list_by_owner(owner_id)
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# owner_id - {http://www.w3.org/2001/XMLSchema}int
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# return StringArray - {http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/}StringArray
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
owner_id = nil
|
||||||
|
puts obj.list_by_owner(owner_id)
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# search_name(substring, idx)
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# substring - {http://www.w3.org/2001/XMLSchema}string
|
||||||
|
# idx - {http://www.w3.org/2001/XMLSchema}int
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# return StringArray - {http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/}StringArray
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
substring = idx = nil
|
||||||
|
puts obj.search_name(substring, idx)
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# search_short_description(substring, idx)
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# substring - {http://www.w3.org/2001/XMLSchema}string
|
||||||
|
# idx - {http://www.w3.org/2001/XMLSchema}int
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# return StringArray - {http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/}StringArray
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
substring = idx = nil
|
||||||
|
puts obj.search_short_description(substring, idx)
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# search_owner(substring, idx)
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# substring - {http://www.w3.org/2001/XMLSchema}string
|
||||||
|
# idx - {http://www.w3.org/2001/XMLSchema}int
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# return StringArray - {http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/}StringArray
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
substring = idx = nil
|
||||||
|
puts obj.search_owner(substring, idx)
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# search_version(substring, idx)
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# substring - {http://www.w3.org/2001/XMLSchema}string
|
||||||
|
# idx - {http://www.w3.org/2001/XMLSchema}int
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# return StringArray - {http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/}StringArray
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
substring = idx = nil
|
||||||
|
puts obj.search_version(substring, idx)
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# search_status(substring, idx)
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# substring - {http://www.w3.org/2001/XMLSchema}string
|
||||||
|
# idx - {http://www.w3.org/2001/XMLSchema}int
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# return StringArray - {http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/}StringArray
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
substring = idx = nil
|
||||||
|
puts obj.search_status(substring, idx)
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# search_description(substring, idx)
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# substring - {http://www.w3.org/2001/XMLSchema}string
|
||||||
|
# idx - {http://www.w3.org/2001/XMLSchema}int
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# return StringArray - {http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/}StringArray
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
substring = idx = nil
|
||||||
|
puts obj.search_description(substring, idx)
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# search(substring)
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# substring - {http://www.w3.org/2001/XMLSchema}string
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# return Map - {http://xml.apache.org/xml-soap}Map
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
substring = nil
|
||||||
|
puts obj.search(substring)
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# owner(owner_id)
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# owner_id - {http://www.w3.org/2001/XMLSchema}int
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# return Owner - {http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/}Owner
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
owner_id = nil
|
||||||
|
puts obj.owner(owner_id)
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# list_owner(idx)
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# idx - {http://www.w3.org/2001/XMLSchema}int
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# return OwnerArray - {http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/}OwnerArray
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
idx = nil
|
||||||
|
puts obj.list_owner(idx)
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# update(name, pass, gem)
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# name - {http://www.w3.org/2001/XMLSchema}string
|
||||||
|
# pass - {http://www.w3.org/2001/XMLSchema}string
|
||||||
|
# gem Gem - {http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/}Gem
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# return Gem - {http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/}Gem
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
name = pass = gem = nil
|
||||||
|
puts obj.update(name, pass, gem)
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
# update_pass(name, oldpass, newpass)
|
||||||
|
#
|
||||||
|
# ARGS
|
||||||
|
# name - {http://www.w3.org/2001/XMLSchema}string
|
||||||
|
# oldpass - {http://www.w3.org/2001/XMLSchema}string
|
||||||
|
# newpass - {http://www.w3.org/2001/XMLSchema}string
|
||||||
|
#
|
||||||
|
# RETURNS
|
||||||
|
# N/A
|
||||||
|
#
|
||||||
|
# RAISES
|
||||||
|
# (undefined)
|
||||||
|
#
|
||||||
|
name = oldpass = newpass = nil
|
||||||
|
puts obj.update_pass(name, oldpass, newpass)
|
||||||
|
|
||||||
|
|
115
sample/soap/raa2.4/sample.rb
Normal file
115
sample/soap/raa2.4/sample.rb
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
# This is a sample client based on raaServiceClient.rb.
|
||||||
|
# You can generate raaServiceClient.rb and related files with
|
||||||
|
# wsdl2ruby.rb --wsdl http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/ --type client
|
||||||
|
|
||||||
|
require 'pp'
|
||||||
|
require 'raaDriver.rb'
|
||||||
|
|
||||||
|
raa = RaaServicePortType.new
|
||||||
|
# raa.wiredump_dev = STDERR
|
||||||
|
|
||||||
|
def sec(msg)
|
||||||
|
puts
|
||||||
|
puts "--------"
|
||||||
|
puts "-- " + msg
|
||||||
|
puts
|
||||||
|
end
|
||||||
|
|
||||||
|
def subsec(msg)
|
||||||
|
puts "-- " + msg
|
||||||
|
end
|
||||||
|
|
||||||
|
sec("retrieve a gem (RAA Information) which has specified name")
|
||||||
|
name = 'soap4r'
|
||||||
|
pp raa.gem(name)
|
||||||
|
|
||||||
|
sec("retrieve dependents of the project")
|
||||||
|
name = 'http-access2'; version = nil
|
||||||
|
pp raa.dependents(name, version)
|
||||||
|
|
||||||
|
sec("number of registered gems")
|
||||||
|
puts raa.size
|
||||||
|
|
||||||
|
sec("retrieve all registered gem names")
|
||||||
|
p raa.names
|
||||||
|
|
||||||
|
sec("retrieve gems of specified category")
|
||||||
|
major = 'Library'; minor = 'XML'
|
||||||
|
p raa.list_by_category(major, minor)
|
||||||
|
|
||||||
|
sec("retrieve category tree")
|
||||||
|
pp raa.tree_by_category
|
||||||
|
|
||||||
|
sec("retrieve gems which is updated recently")
|
||||||
|
idx = 0
|
||||||
|
p raa.list_recent_updated(idx)
|
||||||
|
subsec("next 10 gems")
|
||||||
|
idx += 1
|
||||||
|
p raa.list_recent_updated(idx)
|
||||||
|
subsec("next 10 gems")
|
||||||
|
idx += 1
|
||||||
|
p raa.list_recent_updated(idx)
|
||||||
|
|
||||||
|
sec("retrieve gems which is created recently")
|
||||||
|
p raa.list_recent_created(idx)
|
||||||
|
|
||||||
|
sec("retrieve gems which is updated in 7 days")
|
||||||
|
date = Time.now - 7 * 24 * 60 * 60; idx = 0
|
||||||
|
p raa.list_updated_since(date, idx)
|
||||||
|
|
||||||
|
sec("retrieve gems which is created in 7 days")
|
||||||
|
p raa.list_created_since(date, idx)
|
||||||
|
|
||||||
|
sec("retrieve gems of specified owner")
|
||||||
|
owner_id = 8 # NaHi
|
||||||
|
p raa.list_by_owner(owner_id)
|
||||||
|
|
||||||
|
sec("search gems with keyword")
|
||||||
|
substring = 'soap'
|
||||||
|
pp raa.search(substring)
|
||||||
|
|
||||||
|
# There are several search interface to search a field explicitly.
|
||||||
|
# puts raa.search_name(substring, idx)
|
||||||
|
# puts raa.search_short_description(substring, idx)
|
||||||
|
# puts raa.search_owner(substring, idx)
|
||||||
|
# puts raa.search_version(substring, idx)
|
||||||
|
# puts raa.search_status(substring, idx)
|
||||||
|
# puts raa.search_description(substring, idx)
|
||||||
|
|
||||||
|
sec("retrieve owner info")
|
||||||
|
owner_id = 8
|
||||||
|
pp raa.owner(owner_id)
|
||||||
|
|
||||||
|
sec("retrieve owners")
|
||||||
|
idx = 0
|
||||||
|
p raa.list_owner(idx)
|
||||||
|
|
||||||
|
sec("update 'sampleproject'")
|
||||||
|
name = 'sampleproject'
|
||||||
|
pass = 'sampleproject'
|
||||||
|
gem = raa.gem(name)
|
||||||
|
p gem.project.version
|
||||||
|
gem.project.version.succ!
|
||||||
|
gem.updated = Time.now
|
||||||
|
raa.update(name, pass, gem)
|
||||||
|
p raa.gem(name).project.version
|
||||||
|
|
||||||
|
sec("update pass phrase")
|
||||||
|
raa.update_pass(name, 'sampleproject', 'foo')
|
||||||
|
subsec("update check")
|
||||||
|
gem = raa.gem(name)
|
||||||
|
gem.project.description = 'Current pass phrase is "foo"'
|
||||||
|
gem.updated = Time.now
|
||||||
|
raa.update(name, 'foo', gem)
|
||||||
|
#
|
||||||
|
subsec("recover pass phrase")
|
||||||
|
raa.update_pass(name, 'foo', 'sampleproject')
|
||||||
|
subsec("update check")
|
||||||
|
gem = raa.gem(name)
|
||||||
|
gem.project.description = 'Current pass phrase is "sampleproject"'
|
||||||
|
gem.updated = Time.now
|
||||||
|
raa.update(name, 'sampleproject', gem)
|
||||||
|
|
||||||
|
sec("done")
|
@ -12,5 +12,9 @@ class SampleStructServer < SOAP::RPC::StandaloneServer
|
|||||||
end
|
end
|
||||||
|
|
||||||
if $0 == __FILE__
|
if $0 == __FILE__
|
||||||
status = SampleStructServer.new('SampleStructServer', SampleStructServiceNamespace, '0.0.0.0', 7000).start
|
server = SampleStructServer.new('SampleStructServer', SampleStructServiceNamespace, '0.0.0.0', 7000)
|
||||||
|
trap(:INT) do
|
||||||
|
server.shutdown
|
||||||
|
end
|
||||||
|
server.start
|
||||||
end
|
end
|
||||||
|
1
sample/soap/ssl/files/README
Normal file
1
sample/soap/ssl/files/README
Normal file
@ -0,0 +1 @@
|
|||||||
|
* certificates and keys in this directory is copied from http-access2 test.
|
23
sample/soap/ssl/files/ca.cert
Normal file
23
sample/soap/ssl/files/ca.cert
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIID0DCCArigAwIBAgIBADANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGDAJKUDES
|
||||||
|
MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxCzAJBgNVBAMMAkNBMB4X
|
||||||
|
DTA0MDEzMDAwNDIzMloXDTM2MDEyMjAwNDIzMlowPDELMAkGA1UEBgwCSlAxEjAQ
|
||||||
|
BgNVBAoMCUpJTi5HUi5KUDEMMAoGA1UECwwDUlJSMQswCQYDVQQDDAJDQTCCASIw
|
||||||
|
DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANbv0x42BTKFEQOE+KJ2XmiSdZpR
|
||||||
|
wjzQLAkPLRnLB98tlzs4xo+y4RyY/rd5TT9UzBJTIhP8CJi5GbS1oXEerQXB3P0d
|
||||||
|
L5oSSMwGGyuIzgZe5+vZ1kgzQxMEKMMKlzA73rbMd4Jx3u5+jdbP0EDrPYfXSvLY
|
||||||
|
bS04n2aX7zrN3x5KdDrNBfwBio2/qeaaj4+9OxnwRvYP3WOvqdW0h329eMfHw0pi
|
||||||
|
JI0drIVdsEqClUV4pebT/F+CPUPkEh/weySgo9wANockkYu5ujw2GbLFcO5LXxxm
|
||||||
|
dEfcVr3r6t6zOA4bJwL0W/e6LBcrwiG/qPDFErhwtgTLYf6Er67SzLyA66UCAwEA
|
||||||
|
AaOB3DCB2TAPBgNVHRMBAf8EBTADAQH/MDEGCWCGSAGG+EIBDQQkFiJSdWJ5L09w
|
||||||
|
ZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRlMB0GA1UdDgQWBBRJ7Xd380KzBV7f
|
||||||
|
USKIQ+O/vKbhDzAOBgNVHQ8BAf8EBAMCAQYwZAYDVR0jBF0wW4AUSe13d/NCswVe
|
||||||
|
31EiiEPjv7ym4Q+hQKQ+MDwxCzAJBgNVBAYMAkpQMRIwEAYDVQQKDAlKSU4uR1Iu
|
||||||
|
SlAxDDAKBgNVBAsMA1JSUjELMAkGA1UEAwwCQ0GCAQAwDQYJKoZIhvcNAQEFBQAD
|
||||||
|
ggEBAIu/mfiez5XN5tn2jScgShPgHEFJBR0BTJBZF6xCk0jyqNx/g9HMj2ELCuK+
|
||||||
|
r/Y7KFW5c5M3AQ+xWW0ZSc4kvzyTcV7yTVIwj2jZ9ddYMN3nupZFgBK1GB4Y05GY
|
||||||
|
MJJFRkSu6d/Ph5ypzBVw2YMT/nsOo5VwMUGLgS7YVjU+u/HNWz80J3oO17mNZllj
|
||||||
|
PvORJcnjwlroDnS58KoJ7GDgejv3ESWADvX1OHLE4cRkiQGeLoEU4pxdCxXRqX0U
|
||||||
|
PbwIkZN9mXVcrmPHq8MWi4eC/V7hnbZETMHuWhUoiNdOEfsAXr3iP4KjyyRdwc7a
|
||||||
|
d/xgcK06UVQRL/HbEYGiQL056mc=
|
||||||
|
-----END CERTIFICATE-----
|
19
sample/soap/ssl/files/client.cert
Normal file
19
sample/soap/ssl/files/client.cert
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIDKDCCAhCgAwIBAgIBAjANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGDAJKUDES
|
||||||
|
MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxCzAJBgNVBAMMAkNBMB4X
|
||||||
|
DTA0MDEzMTAzMTQ1OFoXDTM1MDEyMzAzMTQ1OFowZTELMAkGA1UEBgwCSlAxEjAQ
|
||||||
|
BgNVBAoMCUpJTi5HUi5KUDEMMAoGA1UECwwDUlJSMRAwDgYDVQQDDAdleGFtcGxl
|
||||||
|
MSIwIAYJKoZIhvcNAQkBDBNleGFtcGxlQGV4YW1wbGUub3JnMIGfMA0GCSqGSIb3
|
||||||
|
DQEBAQUAA4GNADCBiQKBgQDRWssrK8Gyr+500hpLjCGR3+AHL8/hEJM5zKi/MgLW
|
||||||
|
jTkvsgOwbYwXOiNtAbR9y4/ucDq7EY+cMUMHES4uFaPTcOaAV0aZRmk8AgslN1tQ
|
||||||
|
gNS6ew7/Luq3DcVeWkX8PYgR9VG0mD1MPfJ6+IFA5d3vKpdBkBgN4l46jjO0/2Xf
|
||||||
|
ewIDAQABo4GPMIGMMAwGA1UdEwEB/wQCMAAwMQYJYIZIAYb4QgENBCQWIlJ1Ynkv
|
||||||
|
T3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFOFvay0H7lr2
|
||||||
|
xUx6waYEV2bVDYQhMAsGA1UdDwQEAwIF4DAdBgNVHSUEFjAUBggrBgEFBQcDAgYI
|
||||||
|
KwYBBQUHAwQwDQYJKoZIhvcNAQEFBQADggEBABd2dYWqbDIWf5sWFvslezxJv8gI
|
||||||
|
w64KCJBuyJAiDuf+oazr3016kMzAlt97KecLZDusGNagPrq02UX7YMoQFsWJBans
|
||||||
|
cDtHrkM0al5r6/WGexNMgtYbNTYzt/IwodISGBgZ6dsOuhznwms+IBsTNDAvWeLP
|
||||||
|
lt2tOqD8kEmjwMgn0GDRuKjs4EoboA3kMULb1p9akDV9ZESU3eOtpS5/G5J5msLI
|
||||||
|
9WXbYBjcjvkLuJH9VsJhb+R58Vl0ViemvAHhPilSl1SPWVunGhv6FcIkdBEi1k9F
|
||||||
|
e8BNMmsEjFiANiIRvpdLRbiGBt0KrKTndVfsmoKCvY48oCOvnzxtahFxfs8=
|
||||||
|
-----END CERTIFICATE-----
|
15
sample/soap/ssl/files/client.key
Normal file
15
sample/soap/ssl/files/client.key
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIICWwIBAAKBgQDRWssrK8Gyr+500hpLjCGR3+AHL8/hEJM5zKi/MgLWjTkvsgOw
|
||||||
|
bYwXOiNtAbR9y4/ucDq7EY+cMUMHES4uFaPTcOaAV0aZRmk8AgslN1tQgNS6ew7/
|
||||||
|
Luq3DcVeWkX8PYgR9VG0mD1MPfJ6+IFA5d3vKpdBkBgN4l46jjO0/2XfewIDAQAB
|
||||||
|
AoGAZcz8llWErtsV3QB9gNb3S/PNADGjqBFjReva8n3jG2k4sZSibpwWTwUaTNtT
|
||||||
|
ZQgjSRKRvH1hk9XwffNAvXAQZNNkuj/16gO2oO45nyLj4dO365ujLptWnVIWDHOE
|
||||||
|
uN0GeiZO+VzcCisT0WCq4tvtLeH8svrxzA8cbXIEyOK7NiECQQDwo2zPFyKAZ/Cu
|
||||||
|
lDJ6zKT+RjfWwW7DgWzirAlTrt4ViMaW+IaDH29TmQpb4V4NuR3Xi+2Xl4oicu6S
|
||||||
|
36TW9+/FAkEA3rgfOQJuLlWSnw1RTGwvnC816a/W7iYYY7B+0U4cDbfWl7IoXT4y
|
||||||
|
M8nV/HESooviZLqBwzAYSoj3fFKYBKpGPwJAUO8GN5iWWA2dW3ooiDiv/X1sZmRk
|
||||||
|
dojfMFWgRW747tEzya8Ivq0h6kH8w+5GjeMG8Gn1nRiwsulo6Ckj7dEx6QJACyui
|
||||||
|
7UIQ8qP6GZ4aYMHgVW4Mvy7Bkeo5OO7GPYs0Xv/EdJFL8vlGnVBXOjUVoS9w6Gpu
|
||||||
|
TbLg1QQvnX2rADjmEwJANxZO2GUkaWGsEif8aGW0x5g/IdaMGG27pTWk5zqix7P3
|
||||||
|
1UDrdo/JOXhptovhRi06EppIxAxYmbh9vd9VN8Itlw==
|
||||||
|
-----END RSA PRIVATE KEY-----
|
19
sample/soap/ssl/files/server.cert
Normal file
19
sample/soap/ssl/files/server.cert
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIC/zCCAeegAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MQswCQYDVQQGDAJKUDES
|
||||||
|
MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxDjAMBgNVBAMMBVN1YkNB
|
||||||
|
MB4XDTA0MDEzMTAzMTMxNloXDTMzMDEyMzAzMTMxNlowQzELMAkGA1UEBgwCSlAx
|
||||||
|
EjAQBgNVBAoMCUpJTi5HUi5KUDEMMAoGA1UECwwDUlJSMRIwEAYDVQQDDAlsb2Nh
|
||||||
|
bGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANFJTxWqup3nV9dsJAku
|
||||||
|
p+WaXnPNIzcpAA3qMGZDJTJsfa8Du7ZxTP0XJK5mETttBrn711cJxAuP3KjqnW9S
|
||||||
|
vtZ9lY2sXJ6Zj62sN5LwG3VVe25dI28yR1EsbHjJ5Zjf9tmggMC6am52dxuHbt5/
|
||||||
|
vHo4ngJuKE/U+eeGRivMn6gFAgMBAAGjgYUwgYIwDAYDVR0TAQH/BAIwADAxBglg
|
||||||
|
hkgBhvhCAQ0EJBYiUnVieS9PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAd
|
||||||
|
BgNVHQ4EFgQUpZIyygD9JxFYHHOTEuWOLbCKfckwCwYDVR0PBAQDAgWgMBMGA1Ud
|
||||||
|
JQQMMAoGCCsGAQUFBwMBMA0GCSqGSIb3DQEBBQUAA4IBAQBwAIj5SaBHaA5X31IP
|
||||||
|
CFCJiep96awfp7RANO0cuUj+ZpGoFn9d6FXY0g+Eg5wAkCNIzZU5NHN9xsdOpnUo
|
||||||
|
zIBbyTfQEPrge1CMWMvL6uGaoEXytq84VTitF/xBTky4KtTn6+es4/e7jrrzeUXQ
|
||||||
|
RC46gkHObmDT91RkOEGjHLyld2328jo3DIN/VTHIryDeVHDWjY5dENwpwdkhhm60
|
||||||
|
DR9IrNBbXWEe9emtguNXeN0iu1ux0lG1Hc6pWGQxMlRKNvGh0yZB9u5EVe38tOV0
|
||||||
|
jQaoNyL7qzcQoXD3Dmbi1p0iRmg/+HngISsz8K7k7MBNVsSclztwgCzTZOBiVtkM
|
||||||
|
rRlQ
|
||||||
|
-----END CERTIFICATE-----
|
15
sample/soap/ssl/files/server.key
Normal file
15
sample/soap/ssl/files/server.key
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIICXQIBAAKBgQDRSU8Vqrqd51fXbCQJLqflml5zzSM3KQAN6jBmQyUybH2vA7u2
|
||||||
|
cUz9FySuZhE7bQa5+9dXCcQLj9yo6p1vUr7WfZWNrFyemY+trDeS8Bt1VXtuXSNv
|
||||||
|
MkdRLGx4yeWY3/bZoIDAumpudncbh27ef7x6OJ4CbihP1PnnhkYrzJ+oBQIDAQAB
|
||||||
|
AoGBAIf4CstW2ltQO7+XYGoex7Hh8s9lTSW/G2vu5Hbr1LTHy3fzAvdq8MvVR12O
|
||||||
|
rk9fa+lU9vhzPc0NMB0GIDZ9GcHuhW5hD1Wg9OSCbTOkZDoH3CAFqonjh4Qfwv5W
|
||||||
|
IPAFn9KHukdqGXkwEMdErsUaPTy9A1V/aROVEaAY+HJgq/eZAkEA/BP1QMV04WEZ
|
||||||
|
Oynzz7/lLizJGGxp2AOvEVtqMoycA/Qk+zdKP8ufE0wbmCE3Qd6GoynavsHb6aGK
|
||||||
|
gQobb8zDZwJBANSK6MrXlrZTtEaeZuyOB4mAmRzGzOUVkUyULUjEx2GDT93ujAma
|
||||||
|
qm/2d3E+wXAkNSeRpjUmlQXy/2oSqnGvYbMCQQDRM+cYyEcGPUVpWpnj0shrF/QU
|
||||||
|
9vSot/X1G775EMTyaw6+BtbyNxVgOIu2J+rqGbn3c+b85XqTXOPL0A2RLYkFAkAm
|
||||||
|
syhSDtE9X55aoWsCNZY/vi+i4rvaFoQ/WleogVQAeGVpdo7/DK9t9YWoFBIqth0L
|
||||||
|
mGSYFu9ZhvZkvQNV8eYrAkBJ+rOIaLDsmbrgkeDruH+B/9yrm4McDtQ/rgnOGYnH
|
||||||
|
LjLpLLOrgUxqpzLWe++EwSLwK2//dHO+SPsQJ4xsyQJy
|
||||||
|
-----END RSA PRIVATE KEY-----
|
5
sample/soap/ssl/files/sslclient.properties
Normal file
5
sample/soap/ssl/files/sslclient.properties
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# verify server's certificate
|
||||||
|
protocol.http.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
||||||
|
# certificates for verification
|
||||||
|
protocol.http.ssl_config.ca_file = files/ca.cert
|
||||||
|
protocol.http.ssl_config.ca_file = files/subca.cert
|
@ -0,0 +1,2 @@
|
|||||||
|
# no verify server's certificate
|
||||||
|
protocol.http.ssl_config.verify_mode =
|
@ -0,0 +1,9 @@
|
|||||||
|
# verify server's certificate
|
||||||
|
protocol.http.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
||||||
|
# certificates for verification
|
||||||
|
protocol.http.ssl_config.ca_file = files/ca.cert
|
||||||
|
protocol.http.ssl_config.ca_file = files/subca.cert
|
||||||
|
|
||||||
|
# key and certificate for client identity
|
||||||
|
protocol.http.ssl_config.client_cert = files/client.cert
|
||||||
|
protocol.http.ssl_config.client_key = files/client.key
|
21
sample/soap/ssl/files/subca.cert
Normal file
21
sample/soap/ssl/files/subca.cert
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIDaDCCAlCgAwIBAgIBATANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGDAJKUDES
|
||||||
|
MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxCzAJBgNVBAMMAkNBMB4X
|
||||||
|
DTA0MDEzMDAwNDMyN1oXDTM1MDEyMjAwNDMyN1owPzELMAkGA1UEBgwCSlAxEjAQ
|
||||||
|
BgNVBAoMCUpJTi5HUi5KUDEMMAoGA1UECwwDUlJSMQ4wDAYDVQQDDAVTdWJDQTCC
|
||||||
|
ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ0Ou7AyRcRXnB/kVHv/6kwe
|
||||||
|
ANzgg/DyJfsAUqW90m7Lu1nqyug8gK0RBd77yU0w5HOAMHTVSdpjZK0g2sgx4Mb1
|
||||||
|
d/213eL9TTl5MRVEChTvQr8q5DVG/8fxPPE7fMI8eOAzd98/NOAChk+80r4Sx7fC
|
||||||
|
kGVEE1bKwY1MrUsUNjOY2d6t3M4HHV3HX1V8ShuKfsHxgCmLzdI8U+5CnQedFgkm
|
||||||
|
3e+8tr8IX5RR1wA1Ifw9VadF7OdI/bGMzog/Q8XCLf+WPFjnK7Gcx6JFtzF6Gi4x
|
||||||
|
4dp1Xl45JYiVvi9zQ132wu8A1pDHhiNgQviyzbP+UjcB/tsOpzBQF8abYzgEkWEC
|
||||||
|
AwEAAaNyMHAwDwYDVR0TAQH/BAUwAwEB/zAxBglghkgBhvhCAQ0EJBYiUnVieS9P
|
||||||
|
cGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUlCjXWLsReYzH
|
||||||
|
LzsxwVnCXmKoB/owCwYDVR0PBAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQCJ/OyN
|
||||||
|
rT8Cq2Y+G2yA/L1EMRvvxwFBqxavqaqHl/6rwsIBFlB3zbqGA/0oec6MAVnYynq4
|
||||||
|
c4AcHTjx3bQ/S4r2sNTZq0DH4SYbQzIobx/YW8PjQUJt8KQdKMcwwi7arHP7A/Ha
|
||||||
|
LKu8eIC2nsUBnP4NhkYSGhbmpJK+PFD0FVtD0ZIRlY/wsnaZNjWWcnWF1/FNuQ4H
|
||||||
|
ySjIblqVQkPuzebv3Ror6ZnVDukn96Mg7kP4u6zgxOeqlJGRe1M949SS9Vudjl8X
|
||||||
|
SF4aZUUB9pQGhsqQJVqaz2OlhGOp9D0q54xko/rekjAIcuDjl1mdX4F2WRrzpUmZ
|
||||||
|
uY/bPeOBYiVsOYVe
|
||||||
|
-----END CERTIFICATE-----
|
12
sample/soap/ssl/sslclient.rb
Normal file
12
sample/soap/ssl/sslclient.rb
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
require 'http-access2'
|
||||||
|
require 'soap/rpc/driver'
|
||||||
|
|
||||||
|
# setup driver
|
||||||
|
url = "https://localhost:17443/"
|
||||||
|
client = SOAP::RPC::Driver.new(url, 'urn:sslhelloworld')
|
||||||
|
client.add_method("hello_world", "from")
|
||||||
|
# load SSL properties
|
||||||
|
client.loadproperty('files/sslclient.properties')
|
||||||
|
|
||||||
|
# SOAP over SSL
|
||||||
|
p client.hello_world(__FILE__)
|
12
sample/soap/ssl/sslclient_require_noserverauth.rb
Normal file
12
sample/soap/ssl/sslclient_require_noserverauth.rb
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
require 'http-access2'
|
||||||
|
require 'soap/rpc/driver'
|
||||||
|
|
||||||
|
# setup driver
|
||||||
|
url = "https://localhost:17443/"
|
||||||
|
client = SOAP::RPC::Driver.new(url, 'urn:sslhelloworld')
|
||||||
|
client.add_method("hello_world", "from")
|
||||||
|
# load SSL properties
|
||||||
|
client.loadproperty('files/sslclient_require_noserverauth.properties')
|
||||||
|
|
||||||
|
# SOAP over SSL
|
||||||
|
p client.hello_world(__FILE__)
|
12
sample/soap/ssl/sslclient_with_clientauth.rb
Normal file
12
sample/soap/ssl/sslclient_with_clientauth.rb
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
require 'http-access2'
|
||||||
|
require 'soap/rpc/driver'
|
||||||
|
|
||||||
|
# setup driver
|
||||||
|
url = "https://localhost:17443/"
|
||||||
|
client = SOAP::RPC::Driver.new(url, 'urn:sslhelloworld')
|
||||||
|
client.add_method("hello_world", "from")
|
||||||
|
# load SSL properties
|
||||||
|
client.loadproperty('files/sslclient_with_clientauth.properties')
|
||||||
|
|
||||||
|
# SOAP over SSL
|
||||||
|
p client.hello_world(__FILE__)
|
49
sample/soap/ssl/sslserver.rb
Normal file
49
sample/soap/ssl/sslserver.rb
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
require 'soap/rpc/httpserver'
|
||||||
|
require 'webrick/https'
|
||||||
|
require 'logger'
|
||||||
|
|
||||||
|
class HelloWorldServer < SOAP::RPC::HTTPServer
|
||||||
|
private
|
||||||
|
|
||||||
|
def on_init
|
||||||
|
@default_namespace = 'urn:sslhelloworld'
|
||||||
|
add_method(self, 'hello_world', 'from')
|
||||||
|
end
|
||||||
|
|
||||||
|
def hello_world(from)
|
||||||
|
"Hello World, from #{ from }"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if $0 == __FILE__
|
||||||
|
DIR = File.dirname(File.expand_path(__FILE__))
|
||||||
|
|
||||||
|
def cert(filename)
|
||||||
|
OpenSSL::X509::Certificate.new(File.open(File.join(DIR, filename)) { |f|
|
||||||
|
f.read
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
def key(filename)
|
||||||
|
OpenSSL::PKey::RSA.new(File.open(File.join(DIR, filename)) { |f|
|
||||||
|
f.read
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
$server = HelloWorldServer.new(
|
||||||
|
:BindAddress => "0.0.0.0",
|
||||||
|
:Port => 17443,
|
||||||
|
:AccessLog => [],
|
||||||
|
:SSLEnable => true,
|
||||||
|
:SSLCACertificateFile => File.join(DIR, 'files/ca.cert'),
|
||||||
|
:SSLCertificate => cert('files/server.cert'),
|
||||||
|
:SSLPrivateKey => key('files/server.key'),
|
||||||
|
:SSLVerifyClient => nil,
|
||||||
|
:SSLCertName => nil
|
||||||
|
)
|
||||||
|
trap(:INT) do
|
||||||
|
$server.shutdown
|
||||||
|
end
|
||||||
|
$server.start
|
||||||
|
end
|
45
sample/soap/ssl/sslserver_noauth.rb
Normal file
45
sample/soap/ssl/sslserver_noauth.rb
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
require 'soap/rpc/httpserver'
|
||||||
|
require 'webrick/https'
|
||||||
|
require 'logger'
|
||||||
|
|
||||||
|
class HelloWorldServer < SOAP::RPC::HTTPServer
|
||||||
|
private
|
||||||
|
|
||||||
|
def on_init
|
||||||
|
@default_namespace = 'urn:sslhelloworld'
|
||||||
|
add_method(self, 'hello_world', 'from')
|
||||||
|
end
|
||||||
|
|
||||||
|
def hello_world(from)
|
||||||
|
"Hello World, from #{ from }"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if $0 == __FILE__
|
||||||
|
DIR = File.dirname(File.expand_path(__FILE__))
|
||||||
|
|
||||||
|
def cert(filename)
|
||||||
|
OpenSSL::X509::Certificate.new(File.open(File.join(DIR, filename)) { |f|
|
||||||
|
f.read
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
def key(filename)
|
||||||
|
OpenSSL::PKey::RSA.new(File.open(File.join(DIR, filename)) { |f|
|
||||||
|
f.read
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
$server = HelloWorldServer.new(
|
||||||
|
:BindAddress => "0.0.0.0",
|
||||||
|
:Port => 17443,
|
||||||
|
:AccessLog => [],
|
||||||
|
:SSLEnable => true,
|
||||||
|
:SSLCertName => [['OU', 'example'], ['CN', 'localhost']] # creates dummy certificate
|
||||||
|
)
|
||||||
|
trap(:INT) do
|
||||||
|
$server.shutdown
|
||||||
|
end
|
||||||
|
$server.start
|
||||||
|
end
|
50
sample/soap/ssl/sslserver_require_clientauth.rb
Normal file
50
sample/soap/ssl/sslserver_require_clientauth.rb
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
require 'soap/rpc/httpserver'
|
||||||
|
require 'webrick/https'
|
||||||
|
require 'logger'
|
||||||
|
|
||||||
|
class HelloWorldServer < SOAP::RPC::HTTPServer
|
||||||
|
private
|
||||||
|
|
||||||
|
def on_init
|
||||||
|
@default_namespace = 'urn:sslhelloworld'
|
||||||
|
add_method(self, 'hello_world', 'from')
|
||||||
|
end
|
||||||
|
|
||||||
|
def hello_world(from)
|
||||||
|
"Hello World, from #{ from }"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if $0 == __FILE__
|
||||||
|
DIR = File.dirname(File.expand_path(__FILE__))
|
||||||
|
|
||||||
|
def cert(filename)
|
||||||
|
OpenSSL::X509::Certificate.new(File.open(File.join(DIR, filename)) { |f|
|
||||||
|
f.read
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
def key(filename)
|
||||||
|
OpenSSL::PKey::RSA.new(File.open(File.join(DIR, filename)) { |f|
|
||||||
|
f.read
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
$server = HelloWorldServer.new(
|
||||||
|
:BindAddress => "0.0.0.0",
|
||||||
|
:Port => 17443,
|
||||||
|
:AccessLog => [],
|
||||||
|
:SSLEnable => true,
|
||||||
|
:SSLCACertificateFile => File.join(DIR, 'files/ca.cert'),
|
||||||
|
:SSLCertificate => cert('files/server.cert'),
|
||||||
|
:SSLPrivateKey => key('files/server.key'),
|
||||||
|
:SSLVerifyClient =>
|
||||||
|
OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT|OpenSSL::SSL::VERIFY_PEER,
|
||||||
|
:SSLClientCA => cert('files/ca.cert')
|
||||||
|
)
|
||||||
|
trap(:INT) do
|
||||||
|
$server.shutdown
|
||||||
|
end
|
||||||
|
$server.start
|
||||||
|
end
|
13
sample/soap/swa/client.rb
Normal file
13
sample/soap/swa/client.rb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
require 'soap/rpc/driver'
|
||||||
|
require 'soap/attachment'
|
||||||
|
|
||||||
|
server = 'http://localhost:7000/'
|
||||||
|
driver = SOAP::RPC::Driver.new(server, 'http://www.acmetron.com/soap')
|
||||||
|
driver.wiredump_dev = STDERR
|
||||||
|
driver.add_method('get_file')
|
||||||
|
driver.add_method('put_file', 'name', 'file')
|
||||||
|
|
||||||
|
p driver.get_file
|
||||||
|
file = File.open($0)
|
||||||
|
attach = SOAP::Attachment.new(file)
|
||||||
|
p driver.put_file($0, attach)
|
23
sample/soap/swa/server.rb
Normal file
23
sample/soap/swa/server.rb
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
require 'soap/rpc/standaloneServer'
|
||||||
|
require 'soap/attachment'
|
||||||
|
|
||||||
|
class SwAService
|
||||||
|
def get_file
|
||||||
|
return {
|
||||||
|
'name' => $0,
|
||||||
|
'file' => SOAP::Attachment.new(File.open($0))
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def put_file(name, file)
|
||||||
|
"File '#{name}' was received ok."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
server = SOAP::RPC::StandaloneServer.new('SwAServer',
|
||||||
|
'http://www.acmetron.com/soap', '0.0.0.0', 7000)
|
||||||
|
server.add_servant(SwAService.new)
|
||||||
|
trap(:INT) do
|
||||||
|
server.shutdown
|
||||||
|
end
|
||||||
|
server.start
|
14
sample/soap/whois.rb
Normal file
14
sample/soap/whois.rb
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
key = ARGV.shift
|
||||||
|
|
||||||
|
require 'soap/rpc/driver'
|
||||||
|
|
||||||
|
server = 'http://www.SoapClient.com/xml/SQLDataSoap.WSDL'
|
||||||
|
interface = 'http://www.SoapClient.com/xml/SQLDataSoap.xsd'
|
||||||
|
|
||||||
|
whois = SOAP::RPC::Driver.new(server, interface)
|
||||||
|
whois.wiredump_dev = STDERR
|
||||||
|
whois.add_method('ProcessSRL', 'SRLFile', 'RequestName', 'key')
|
||||||
|
|
||||||
|
p whois.ProcessSRL('WHOIS.SRI', 'whois', key)
|
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,8 @@ require 'AmazonSearch.rb'
|
|||||||
|
|
||||||
require 'soap/rpc/driver'
|
require 'soap/rpc/driver'
|
||||||
|
|
||||||
class AmazonSearchPort < SOAP::RPC::Driver
|
class AmazonSearchPort < ::SOAP::RPC::Driver
|
||||||
|
DefaultEndpointUrl = "http://soap.amazon.com/onca/soap3"
|
||||||
MappingRegistry = ::SOAP::Mapping::Registry.new
|
MappingRegistry = ::SOAP::Mapping::Registry.new
|
||||||
|
|
||||||
MappingRegistry.set(
|
MappingRegistry.set(
|
||||||
@ -331,166 +332,190 @@ class AmazonSearchPort < SOAP::RPC::Driver
|
|||||||
)
|
)
|
||||||
|
|
||||||
Methods = [
|
Methods = [
|
||||||
["KeywordSearchRequest", "keywordSearchRequest", [
|
["KeywordSearchRequest", "keywordSearchRequest",
|
||||||
["in", "KeywordSearchRequest",
|
[
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "KeywordRequest"]],
|
["in", "KeywordSearchRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "KeywordRequest"]],
|
||||||
["retval", "return",
|
["retval", "return", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]],
|
],
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
["TextStreamSearchRequest", "textStreamSearchRequest", [
|
],
|
||||||
["in", "TextStreamSearchRequest",
|
["TextStreamSearchRequest", "textStreamSearchRequest",
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "TextStreamRequest"]],
|
[
|
||||||
["retval", "return",
|
["in", "TextStreamSearchRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "TextStreamRequest"]],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]],
|
["retval", "return", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
],
|
||||||
["PowerSearchRequest", "powerSearchRequest", [
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
["in", "PowerSearchRequest",
|
],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "PowerRequest"]],
|
["PowerSearchRequest", "powerSearchRequest",
|
||||||
["retval", "return",
|
[
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]],
|
["in", "PowerSearchRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "PowerRequest"]],
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
["retval", "return", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]
|
||||||
["BrowseNodeSearchRequest", "browseNodeSearchRequest", [
|
],
|
||||||
["in", "BrowseNodeSearchRequest",
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "BrowseNodeRequest"]],
|
],
|
||||||
["retval", "return",
|
["BrowseNodeSearchRequest", "browseNodeSearchRequest",
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]],
|
[
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
["in", "BrowseNodeSearchRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "BrowseNodeRequest"]],
|
||||||
["AsinSearchRequest", "asinSearchRequest", [
|
["retval", "return", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]
|
||||||
["in", "AsinSearchRequest",
|
],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "AsinRequest"]],
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
["retval", "return",
|
],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]],
|
["AsinSearchRequest", "asinSearchRequest",
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
[
|
||||||
["BlendedSearchRequest", "blendedSearchRequest", [
|
["in", "AsinSearchRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "AsinRequest"]],
|
||||||
["in", "BlendedSearchRequest",
|
["retval", "return", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "BlendedRequest"]],
|
],
|
||||||
["retval", "return",
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
[::SOAP::SOAPArray, "http://soap.amazon.com", "ProductLine"]]],
|
],
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
["BlendedSearchRequest", "blendedSearchRequest",
|
||||||
["UpcSearchRequest", "upcSearchRequest", [
|
[
|
||||||
["in", "UpcSearchRequest",
|
["in", "BlendedSearchRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "BlendedRequest"]],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "UpcRequest"]],
|
["retval", "return", [::SOAP::SOAPArray, "http://soap.amazon.com", "ProductLine"]]
|
||||||
["retval", "return",
|
],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]],
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
],
|
||||||
["SkuSearchRequest", "skuSearchRequest", [
|
["UpcSearchRequest", "upcSearchRequest",
|
||||||
["in", "SkuSearchRequest",
|
[
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "SkuRequest"]],
|
["in", "UpcSearchRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "UpcRequest"]],
|
||||||
["retval", "return",
|
["retval", "return", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]],
|
],
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
["AuthorSearchRequest", "authorSearchRequest", [
|
],
|
||||||
["in", "AuthorSearchRequest",
|
["SkuSearchRequest", "skuSearchRequest",
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "AuthorRequest"]],
|
[
|
||||||
["retval", "return",
|
["in", "SkuSearchRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "SkuRequest"]],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]],
|
["retval", "return", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
],
|
||||||
["ArtistSearchRequest", "artistSearchRequest", [
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
["in", "ArtistSearchRequest",
|
],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ArtistRequest"]],
|
["AuthorSearchRequest", "authorSearchRequest",
|
||||||
["retval", "return",
|
[
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]],
|
["in", "AuthorSearchRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "AuthorRequest"]],
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
["retval", "return", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]
|
||||||
["ActorSearchRequest", "actorSearchRequest", [
|
],
|
||||||
["in", "ActorSearchRequest",
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ActorRequest"]],
|
],
|
||||||
["retval", "return",
|
["ArtistSearchRequest", "artistSearchRequest",
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]],
|
[
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
["in", "ArtistSearchRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ArtistRequest"]],
|
||||||
["ManufacturerSearchRequest", "manufacturerSearchRequest", [
|
["retval", "return", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]
|
||||||
["in", "ManufacturerSearchRequest",
|
],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ManufacturerRequest"]],
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
["retval", "return",
|
],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]],
|
["ActorSearchRequest", "actorSearchRequest",
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
[
|
||||||
["DirectorSearchRequest", "directorSearchRequest", [
|
["in", "ActorSearchRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ActorRequest"]],
|
||||||
["in", "DirectorSearchRequest",
|
["retval", "return", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "DirectorRequest"]],
|
],
|
||||||
["retval", "return",
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]],
|
],
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
["ManufacturerSearchRequest", "manufacturerSearchRequest",
|
||||||
["ListManiaSearchRequest", "listManiaSearchRequest", [
|
[
|
||||||
["in", "ListManiaSearchRequest",
|
["in", "ManufacturerSearchRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ManufacturerRequest"]],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ListManiaRequest"]],
|
["retval", "return", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]
|
||||||
["retval", "return",
|
],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]],
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
],
|
||||||
["WishlistSearchRequest", "wishlistSearchRequest", [
|
["DirectorSearchRequest", "directorSearchRequest",
|
||||||
["in", "WishlistSearchRequest",
|
[
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "WishlistRequest"]],
|
["in", "DirectorSearchRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "DirectorRequest"]],
|
||||||
["retval", "return",
|
["retval", "return", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]],
|
],
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
["ExchangeSearchRequest", "exchangeSearchRequest", [
|
],
|
||||||
["in", "ExchangeSearchRequest",
|
["ListManiaSearchRequest", "listManiaSearchRequest",
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ExchangeRequest"]],
|
[
|
||||||
["retval", "return",
|
["in", "ListManiaSearchRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ListManiaRequest"]],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ListingProductDetails"]]],
|
["retval", "return", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
],
|
||||||
["MarketplaceSearchRequest", "marketplaceSearchRequest", [
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
["in", "MarketplaceSearchRequest",
|
],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "MarketplaceRequest"]],
|
["WishlistSearchRequest", "wishlistSearchRequest",
|
||||||
["retval", "return",
|
[
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "MarketplaceSearch"]]],
|
["in", "WishlistSearchRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "WishlistRequest"]],
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
["retval", "return", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]
|
||||||
["SellerProfileSearchRequest", "sellerProfileSearchRequest", [
|
],
|
||||||
["in", "SellerProfileSearchRequest",
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "SellerProfileRequest"]],
|
],
|
||||||
["retval", "return",
|
["ExchangeSearchRequest", "exchangeSearchRequest",
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "SellerProfile"]]],
|
[
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
["in", "ExchangeSearchRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ExchangeRequest"]],
|
||||||
["SellerSearchRequest", "sellerSearchRequest", [
|
["retval", "return", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ListingProductDetails"]]
|
||||||
["in", "SellerSearchRequest",
|
],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "SellerRequest"]],
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
["retval", "return",
|
],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "SellerSearch"]]],
|
["MarketplaceSearchRequest", "marketplaceSearchRequest",
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
[
|
||||||
["SimilaritySearchRequest", "similaritySearchRequest", [
|
["in", "MarketplaceSearchRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "MarketplaceRequest"]],
|
||||||
["in", "SimilaritySearchRequest",
|
["retval", "return", [::SOAP::SOAPStruct, "http://soap.amazon.com", "MarketplaceSearch"]]
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "SimilarityRequest"]],
|
],
|
||||||
["retval", "return",
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]],
|
],
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
["SellerProfileSearchRequest", "sellerProfileSearchRequest",
|
||||||
["GetShoppingCartRequest", "getShoppingCartRequest", [
|
[
|
||||||
["in", "GetShoppingCartRequest",
|
["in", "SellerProfileSearchRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "SellerProfileRequest"]],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "GetShoppingCartRequest"]],
|
["retval", "return", [::SOAP::SOAPStruct, "http://soap.amazon.com", "SellerProfile"]]
|
||||||
["retval", "ShoppingCart",
|
],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ShoppingCart"]]],
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
],
|
||||||
["ClearShoppingCartRequest", "clearShoppingCartRequest", [
|
["SellerSearchRequest", "sellerSearchRequest",
|
||||||
["in", "ClearShoppingCartRequest",
|
[
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ClearShoppingCartRequest"]],
|
["in", "SellerSearchRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "SellerRequest"]],
|
||||||
["retval", "ShoppingCart",
|
["retval", "return", [::SOAP::SOAPStruct, "http://soap.amazon.com", "SellerSearch"]]
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ShoppingCart"]]],
|
],
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
["AddShoppingCartItemsRequest", "addShoppingCartItemsRequest", [
|
],
|
||||||
["in", "AddShoppingCartItemsRequest",
|
["SimilaritySearchRequest", "similaritySearchRequest",
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "AddShoppingCartItemsRequest"]],
|
[
|
||||||
["retval", "ShoppingCart",
|
["in", "SimilaritySearchRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "SimilarityRequest"]],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ShoppingCart"]]],
|
["retval", "return", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ProductInfo"]]
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
],
|
||||||
["RemoveShoppingCartItemsRequest", "removeShoppingCartItemsRequest", [
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
["in", "RemoveShoppingCartItemsRequest",
|
],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "RemoveShoppingCartItemsRequest"]],
|
["GetShoppingCartRequest", "getShoppingCartRequest",
|
||||||
["retval", "ShoppingCart",
|
[
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ShoppingCart"]]],
|
["in", "GetShoppingCartRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "GetShoppingCartRequest"]],
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
["retval", "ShoppingCart", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ShoppingCart"]]
|
||||||
["ModifyShoppingCartItemsRequest", "modifyShoppingCartItemsRequest", [
|
],
|
||||||
["in", "ModifyShoppingCartItemsRequest",
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ModifyShoppingCartItemsRequest"]],
|
],
|
||||||
["retval", "ShoppingCart",
|
["ClearShoppingCartRequest", "clearShoppingCartRequest",
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "ShoppingCart"]]],
|
[
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"],
|
["in", "ClearShoppingCartRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ClearShoppingCartRequest"]],
|
||||||
["GetTransactionDetailsRequest", "getTransactionDetailsRequest", [
|
["retval", "ShoppingCart", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ShoppingCart"]]
|
||||||
["in", "GetTransactionDetailsRequest",
|
],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "GetTransactionDetailsRequest"]],
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
["retval", "GetTransactionDetailsResponse",
|
],
|
||||||
[::SOAP::SOAPStruct, "http://soap.amazon.com", "GetTransactionDetailsResponse"]]],
|
["AddShoppingCartItemsRequest", "addShoppingCartItemsRequest",
|
||||||
"http://soap.amazon.com", "http://soap.amazon.com"]
|
[
|
||||||
|
["in", "AddShoppingCartItemsRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "AddShoppingCartItemsRequest"]],
|
||||||
|
["retval", "ShoppingCart", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ShoppingCart"]]
|
||||||
|
],
|
||||||
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
|
],
|
||||||
|
["RemoveShoppingCartItemsRequest", "removeShoppingCartItemsRequest",
|
||||||
|
[
|
||||||
|
["in", "RemoveShoppingCartItemsRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "RemoveShoppingCartItemsRequest"]],
|
||||||
|
["retval", "ShoppingCart", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ShoppingCart"]]
|
||||||
|
],
|
||||||
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
|
],
|
||||||
|
["ModifyShoppingCartItemsRequest", "modifyShoppingCartItemsRequest",
|
||||||
|
[
|
||||||
|
["in", "ModifyShoppingCartItemsRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ModifyShoppingCartItemsRequest"]],
|
||||||
|
["retval", "ShoppingCart", [::SOAP::SOAPStruct, "http://soap.amazon.com", "ShoppingCart"]]
|
||||||
|
],
|
||||||
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
|
],
|
||||||
|
["GetTransactionDetailsRequest", "getTransactionDetailsRequest",
|
||||||
|
[
|
||||||
|
["in", "GetTransactionDetailsRequest", [::SOAP::SOAPStruct, "http://soap.amazon.com", "GetTransactionDetailsRequest"]],
|
||||||
|
["retval", "GetTransactionDetailsResponse", [::SOAP::SOAPStruct, "http://soap.amazon.com", "GetTransactionDetailsResponse"]]
|
||||||
|
],
|
||||||
|
"http://soap.amazon.com", "http://soap.amazon.com"
|
||||||
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
DefaultEndpointUrl = "http://soap.amazon.com/onca/soap3"
|
|
||||||
|
|
||||||
def initialize(endpoint_url = nil)
|
def initialize(endpoint_url = nil)
|
||||||
endpoint_url ||= DefaultEndpointUrl
|
endpoint_url ||= DefaultEndpointUrl
|
||||||
super(endpoint_url, nil)
|
super(endpoint_url, nil)
|
||||||
@ -498,7 +523,7 @@ class AmazonSearchPort < SOAP::RPC::Driver
|
|||||||
init_methods
|
init_methods
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def init_methods
|
def init_methods
|
||||||
Methods.each do |name_as, name, params, soapaction, namespace|
|
Methods.each do |name_as, name, params, soapaction, namespace|
|
||||||
|
332
sample/wsdl/raa2.4/raa.rb
Normal file
332
sample/wsdl/raa2.4/raa.rb
Normal file
@ -0,0 +1,332 @@
|
|||||||
|
# http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/
|
||||||
|
class Gem
|
||||||
|
@@schema_type = "Gem"
|
||||||
|
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/"
|
||||||
|
|
||||||
|
def id
|
||||||
|
@id
|
||||||
|
end
|
||||||
|
|
||||||
|
def id=(value)
|
||||||
|
@id = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def category
|
||||||
|
@category
|
||||||
|
end
|
||||||
|
|
||||||
|
def category=(value)
|
||||||
|
@category = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def owner
|
||||||
|
@owner
|
||||||
|
end
|
||||||
|
|
||||||
|
def owner=(value)
|
||||||
|
@owner = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def project
|
||||||
|
@project
|
||||||
|
end
|
||||||
|
|
||||||
|
def project=(value)
|
||||||
|
@project = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def updated
|
||||||
|
@updated
|
||||||
|
end
|
||||||
|
|
||||||
|
def updated=(value)
|
||||||
|
@updated = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def created
|
||||||
|
@created
|
||||||
|
end
|
||||||
|
|
||||||
|
def created=(value)
|
||||||
|
@created = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(id = nil,
|
||||||
|
category = nil,
|
||||||
|
owner = nil,
|
||||||
|
project = nil,
|
||||||
|
updated = nil,
|
||||||
|
created = nil)
|
||||||
|
@id = id
|
||||||
|
@category = category
|
||||||
|
@owner = owner
|
||||||
|
@project = project
|
||||||
|
@updated = updated
|
||||||
|
@created = created
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/
|
||||||
|
class Category
|
||||||
|
@@schema_type = "Category"
|
||||||
|
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/"
|
||||||
|
|
||||||
|
def major
|
||||||
|
@major
|
||||||
|
end
|
||||||
|
|
||||||
|
def major=(value)
|
||||||
|
@major = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def minor
|
||||||
|
@minor
|
||||||
|
end
|
||||||
|
|
||||||
|
def minor=(value)
|
||||||
|
@minor = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(major = nil,
|
||||||
|
minor = nil)
|
||||||
|
@major = major
|
||||||
|
@minor = minor
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/
|
||||||
|
class Owner
|
||||||
|
@@schema_type = "Owner"
|
||||||
|
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/"
|
||||||
|
|
||||||
|
def id
|
||||||
|
@id
|
||||||
|
end
|
||||||
|
|
||||||
|
def id=(value)
|
||||||
|
@id = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def email
|
||||||
|
@email
|
||||||
|
end
|
||||||
|
|
||||||
|
def email=(value)
|
||||||
|
@email = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def name
|
||||||
|
@name
|
||||||
|
end
|
||||||
|
|
||||||
|
def name=(value)
|
||||||
|
@name = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(id = nil,
|
||||||
|
email = nil,
|
||||||
|
name = nil)
|
||||||
|
@id = id
|
||||||
|
@email = email
|
||||||
|
@name = name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/
|
||||||
|
class Project
|
||||||
|
@@schema_type = "Project"
|
||||||
|
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/"
|
||||||
|
|
||||||
|
def name
|
||||||
|
@name
|
||||||
|
end
|
||||||
|
|
||||||
|
def name=(value)
|
||||||
|
@name = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def short_description
|
||||||
|
@short_description
|
||||||
|
end
|
||||||
|
|
||||||
|
def short_description=(value)
|
||||||
|
@short_description = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def version
|
||||||
|
@version
|
||||||
|
end
|
||||||
|
|
||||||
|
def version=(value)
|
||||||
|
@version = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def status
|
||||||
|
@status
|
||||||
|
end
|
||||||
|
|
||||||
|
def status=(value)
|
||||||
|
@status = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def url
|
||||||
|
@url
|
||||||
|
end
|
||||||
|
|
||||||
|
def url=(value)
|
||||||
|
@url = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def download
|
||||||
|
@download
|
||||||
|
end
|
||||||
|
|
||||||
|
def download=(value)
|
||||||
|
@download = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def license
|
||||||
|
@license
|
||||||
|
end
|
||||||
|
|
||||||
|
def license=(value)
|
||||||
|
@license = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def description
|
||||||
|
@description
|
||||||
|
end
|
||||||
|
|
||||||
|
def description=(value)
|
||||||
|
@description = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def updated
|
||||||
|
@updated
|
||||||
|
end
|
||||||
|
|
||||||
|
def updated=(value)
|
||||||
|
@updated = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def history
|
||||||
|
@history
|
||||||
|
end
|
||||||
|
|
||||||
|
def history=(value)
|
||||||
|
@history = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def dependency
|
||||||
|
@dependency
|
||||||
|
end
|
||||||
|
|
||||||
|
def dependency=(value)
|
||||||
|
@dependency = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(name = nil,
|
||||||
|
short_description = nil,
|
||||||
|
version = nil,
|
||||||
|
status = nil,
|
||||||
|
url = nil,
|
||||||
|
download = nil,
|
||||||
|
license = nil,
|
||||||
|
description = nil,
|
||||||
|
updated = nil,
|
||||||
|
history = nil,
|
||||||
|
dependency = nil)
|
||||||
|
@name = name
|
||||||
|
@short_description = short_description
|
||||||
|
@version = version
|
||||||
|
@status = status
|
||||||
|
@url = url
|
||||||
|
@download = download
|
||||||
|
@license = license
|
||||||
|
@description = description
|
||||||
|
@updated = updated
|
||||||
|
@history = history
|
||||||
|
@dependency = dependency
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/
|
||||||
|
class ProjectDependency
|
||||||
|
@@schema_type = "ProjectDependency"
|
||||||
|
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/"
|
||||||
|
|
||||||
|
def project
|
||||||
|
@project
|
||||||
|
end
|
||||||
|
|
||||||
|
def project=(value)
|
||||||
|
@project = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def version
|
||||||
|
@version
|
||||||
|
end
|
||||||
|
|
||||||
|
def version=(value)
|
||||||
|
@version = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def description
|
||||||
|
@description
|
||||||
|
end
|
||||||
|
|
||||||
|
def description=(value)
|
||||||
|
@description = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(project = nil,
|
||||||
|
version = nil,
|
||||||
|
description = nil)
|
||||||
|
@project = project
|
||||||
|
@version = version
|
||||||
|
@description = description
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/
|
||||||
|
class GemArray < Array
|
||||||
|
# Contents type should be dumped here...
|
||||||
|
@@schema_type = "GemArray"
|
||||||
|
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/"
|
||||||
|
end
|
||||||
|
|
||||||
|
# http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/
|
||||||
|
class OwnerArray < Array
|
||||||
|
# Contents type should be dumped here...
|
||||||
|
@@schema_type = "OwnerArray"
|
||||||
|
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/"
|
||||||
|
end
|
||||||
|
|
||||||
|
# http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/
|
||||||
|
class ProjectArray < Array
|
||||||
|
# Contents type should be dumped here...
|
||||||
|
@@schema_type = "ProjectArray"
|
||||||
|
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/"
|
||||||
|
end
|
||||||
|
|
||||||
|
# http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/
|
||||||
|
class ProjectDependencyArray < Array
|
||||||
|
# Contents type should be dumped here...
|
||||||
|
@@schema_type = "ProjectDependencyArray"
|
||||||
|
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/"
|
||||||
|
end
|
||||||
|
|
||||||
|
# http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/
|
||||||
|
class StringArray < Array
|
||||||
|
# Contents type should be dumped here...
|
||||||
|
@@schema_type = "StringArray"
|
||||||
|
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/type/RAA/0.0.3/"
|
||||||
|
end
|
||||||
|
|
||||||
|
# http://xml.apache.org/xml-soap
|
||||||
|
class Map < Array
|
||||||
|
# Contents type should be dumped here...
|
||||||
|
@@schema_type = "Map"
|
||||||
|
@@schema_ns = "http://xml.apache.org/xml-soap"
|
||||||
|
end
|
||||||
|
|
117
sample/wsdl/raa2.4/wsdlDriver.rb
Normal file
117
sample/wsdl/raa2.4/wsdlDriver.rb
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
# You can generate raa.rb required here with the command;
|
||||||
|
# wsdl2ruby.rb --wsdl http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/ --classdef
|
||||||
|
require 'raa'
|
||||||
|
require 'soap/wsdlDriver'
|
||||||
|
require 'pp'
|
||||||
|
|
||||||
|
RAA_WSDL = 'http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.4/'
|
||||||
|
|
||||||
|
raa = SOAP::WSDLDriverFactory.new(RAA_WSDL).create_driver
|
||||||
|
raa.generate_explicit_type = true
|
||||||
|
# raa.wiredump_dev = STDERR
|
||||||
|
|
||||||
|
def sec(msg)
|
||||||
|
puts
|
||||||
|
puts "--------"
|
||||||
|
puts "-- " + msg
|
||||||
|
puts
|
||||||
|
end
|
||||||
|
|
||||||
|
def subsec(msg)
|
||||||
|
puts "-- " + msg
|
||||||
|
end
|
||||||
|
|
||||||
|
sec("retrieve a gem (RAA Information) which has specified name")
|
||||||
|
name = 'soap4r'
|
||||||
|
pp raa.gem(name)
|
||||||
|
|
||||||
|
sec("retrieve dependents of the project")
|
||||||
|
name = 'http-access2'; version = nil
|
||||||
|
pp raa.dependents(name, version)
|
||||||
|
|
||||||
|
sec("number of registered gems")
|
||||||
|
puts raa.size
|
||||||
|
|
||||||
|
sec("retrieve all registered gem names")
|
||||||
|
p raa.names
|
||||||
|
|
||||||
|
sec("retrieve gems of specified category")
|
||||||
|
major = 'Library'; minor = 'XML'
|
||||||
|
p raa.list_by_category(major, minor)
|
||||||
|
|
||||||
|
sec("retrieve category tree")
|
||||||
|
pp raa.tree_by_category
|
||||||
|
|
||||||
|
sec("retrieve gems which is updated recently")
|
||||||
|
idx = 0
|
||||||
|
p raa.list_recent_updated(idx)
|
||||||
|
subsec("next 10 gems")
|
||||||
|
idx += 1
|
||||||
|
p raa.list_recent_updated(idx)
|
||||||
|
subsec("next 10 gems")
|
||||||
|
idx += 1
|
||||||
|
p raa.list_recent_updated(idx)
|
||||||
|
|
||||||
|
sec("retrieve gems which is created recently")
|
||||||
|
p raa.list_recent_created(idx)
|
||||||
|
|
||||||
|
sec("retrieve gems which is updated in 7 days")
|
||||||
|
date = Time.now - 7 * 24 * 60 * 60; idx = 0
|
||||||
|
p raa.list_updated_since(date, idx)
|
||||||
|
|
||||||
|
sec("retrieve gems which is created in 7 days")
|
||||||
|
p raa.list_created_since(date, idx)
|
||||||
|
|
||||||
|
sec("retrieve gems of specified owner")
|
||||||
|
owner_id = 8 # NaHi
|
||||||
|
p raa.list_by_owner(owner_id)
|
||||||
|
|
||||||
|
sec("search gems with keyword")
|
||||||
|
substring = 'soap'
|
||||||
|
pp raa.search(substring)
|
||||||
|
|
||||||
|
# There are several search interface to search a field explicitly.
|
||||||
|
# puts raa.search_name(substring, idx)
|
||||||
|
# puts raa.search_short_description(substring, idx)
|
||||||
|
# puts raa.search_owner(substring, idx)
|
||||||
|
# puts raa.search_version(substring, idx)
|
||||||
|
# puts raa.search_status(substring, idx)
|
||||||
|
# puts raa.search_description(substring, idx)
|
||||||
|
|
||||||
|
sec("retrieve owner info")
|
||||||
|
owner_id = 8
|
||||||
|
pp raa.owner(owner_id)
|
||||||
|
|
||||||
|
sec("retrieve owners")
|
||||||
|
idx = 0
|
||||||
|
p raa.list_owner(idx)
|
||||||
|
|
||||||
|
sec("update 'sampleproject'")
|
||||||
|
name = 'sampleproject'
|
||||||
|
pass = 'sampleproject'
|
||||||
|
gem = raa.gem(name)
|
||||||
|
p gem.project.version
|
||||||
|
gem.project.version.succ!
|
||||||
|
gem.updated = Time.now
|
||||||
|
raa.update(name, pass, gem)
|
||||||
|
p raa.gem(name).project.version
|
||||||
|
|
||||||
|
sec("update pass phrase")
|
||||||
|
raa.update_pass(name, 'sampleproject', 'foo')
|
||||||
|
subsec("update check")
|
||||||
|
gem = raa.gem(name)
|
||||||
|
gem.project.description = 'Current pass phrase is "foo"'
|
||||||
|
gem.updated = Time.now
|
||||||
|
raa.update(name, 'foo', gem)
|
||||||
|
#
|
||||||
|
subsec("recover pass phrase")
|
||||||
|
raa.update_pass(name, 'foo', 'sampleproject')
|
||||||
|
subsec("update check")
|
||||||
|
gem = raa.gem(name)
|
||||||
|
gem.project.description = 'Current pass phrase is "sampleproject"'
|
||||||
|
gem.updated = Time.now
|
||||||
|
raa.update(name, 'sampleproject', gem)
|
||||||
|
|
||||||
|
sec("done")
|
@ -2,13 +2,7 @@ require 'test/unit'
|
|||||||
require 'soap/rpc/driver'
|
require 'soap/rpc/driver'
|
||||||
require 'logger'
|
require 'logger'
|
||||||
require 'webrick'
|
require 'webrick'
|
||||||
begin
|
require 'rbconfig'
|
||||||
loadpath = $:.dup
|
|
||||||
$:.replace($: | [File.expand_path("../../ruby", File.dirname(__FILE__))])
|
|
||||||
require 'envutil'
|
|
||||||
ensure
|
|
||||||
$:.replace(loadpath)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
module SOAP
|
module SOAP
|
||||||
@ -16,7 +10,11 @@ module Calc
|
|||||||
|
|
||||||
|
|
||||||
class TestCalcCGI < Test::Unit::TestCase
|
class TestCalcCGI < Test::Unit::TestCase
|
||||||
RUBYBIN = EnvUtil.rubybin
|
# This test shuld be run after installing ruby.
|
||||||
|
RUBYBIN = File.join(
|
||||||
|
Config::CONFIG["bindir"],
|
||||||
|
Config::CONFIG["ruby_install_name"] + Config::CONFIG["EXEEXT"]
|
||||||
|
)
|
||||||
RUBYBIN << " -d" if $DEBUG
|
RUBYBIN << " -d" if $DEBUG
|
||||||
|
|
||||||
Port = 17171
|
Port = 17171
|
||||||
|
119
test/soap/header/server.cgi
Normal file
119
test/soap/header/server.cgi
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
require 'pstore'
|
||||||
|
require 'soap/rpc/cgistub'
|
||||||
|
require 'soap/header/simplehandler'
|
||||||
|
|
||||||
|
|
||||||
|
class AuthHeaderPortServer < SOAP::RPC::CGIStub
|
||||||
|
PortName = 'http://tempuri.org/authHeaderPort'
|
||||||
|
SupportPortName = 'http://tempuri.org/authHeaderSupportPort'
|
||||||
|
MyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "auth")
|
||||||
|
SessionDB = File.join(File.expand_path(File.dirname(__FILE__)), 'session.pstoredb')
|
||||||
|
|
||||||
|
class AuthHeaderService
|
||||||
|
def self.create
|
||||||
|
new
|
||||||
|
end
|
||||||
|
|
||||||
|
def deposit(amt)
|
||||||
|
"deposit #{amt} OK"
|
||||||
|
end
|
||||||
|
|
||||||
|
def withdrawal(amt)
|
||||||
|
"withdrawal #{amt} OK"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class AuthHeaderSupportService
|
||||||
|
def delete_sessiondb
|
||||||
|
File.unlink(SessionDB) if File.file?(SessionDB)
|
||||||
|
backup = SessionDB + "~"
|
||||||
|
File.unlink(backup) if File.file?(backup)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(*arg)
|
||||||
|
super
|
||||||
|
add_rpc_servant(AuthHeaderService.new, PortName)
|
||||||
|
add_rpc_servant(AuthHeaderSupportService.new, SupportPortName)
|
||||||
|
add_rpc_headerhandler(ServerAuthHeaderHandler.new)
|
||||||
|
end
|
||||||
|
|
||||||
|
class ServerAuthHeaderHandler < SOAP::Header::SimpleHandler
|
||||||
|
Users = {
|
||||||
|
'NaHi' => 'passwd',
|
||||||
|
'HiNa' => 'wspass'
|
||||||
|
}
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
super(MyHeaderName)
|
||||||
|
@db = PStore.new(SessionDB)
|
||||||
|
@db.transaction do
|
||||||
|
@db["root"] = {} unless @db.root?("root")
|
||||||
|
end
|
||||||
|
@userid = @sessionid = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def login(userid, passwd)
|
||||||
|
userid and passwd and Users[userid] == passwd
|
||||||
|
end
|
||||||
|
|
||||||
|
def auth(sessionid)
|
||||||
|
in_sessiondb do |root|
|
||||||
|
root[sessionid][0]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_session(userid)
|
||||||
|
in_sessiondb do |root|
|
||||||
|
while true
|
||||||
|
key = create_sessionkey
|
||||||
|
break unless root[key]
|
||||||
|
end
|
||||||
|
root[key] = [userid]
|
||||||
|
key
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy_session(sessionkey)
|
||||||
|
in_sessiondb do |root|
|
||||||
|
root.delete(sessionkey)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_simple_outbound
|
||||||
|
{ "sessionid" => @sessionid }
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_simple_inbound(my_header, mu)
|
||||||
|
auth = false
|
||||||
|
userid = my_header["userid"]
|
||||||
|
passwd = my_header["passwd"]
|
||||||
|
if login(userid, passwd)
|
||||||
|
auth = true
|
||||||
|
elsif sessionid = my_header["sessionid"]
|
||||||
|
if userid = auth(sessionid)
|
||||||
|
destroy_session(sessionid)
|
||||||
|
auth = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
raise RuntimeError.new("authentication failed") unless auth
|
||||||
|
@userid = userid
|
||||||
|
@sessionid = create_session(userid)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def create_sessionkey
|
||||||
|
Time.now.usec.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
def in_sessiondb
|
||||||
|
@db.transaction do
|
||||||
|
yield(@db["root"])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
status = AuthHeaderPortServer.new('AuthHeaderPortServer', nil).start
|
247
test/soap/header/test_authheader.rb
Normal file
247
test/soap/header/test_authheader.rb
Normal file
@ -0,0 +1,247 @@
|
|||||||
|
require 'test/unit'
|
||||||
|
require 'soap/rpc/driver'
|
||||||
|
require 'soap/rpc/standaloneServer'
|
||||||
|
require 'soap/header/simplehandler'
|
||||||
|
|
||||||
|
|
||||||
|
module SOAP
|
||||||
|
module Header
|
||||||
|
|
||||||
|
|
||||||
|
class TestAuthHeader < Test::Unit::TestCase
|
||||||
|
Port = 17171
|
||||||
|
PortName = 'http://tempuri.org/authHeaderPort'
|
||||||
|
MyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "auth")
|
||||||
|
DummyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "dummy")
|
||||||
|
|
||||||
|
class AuthHeaderPortServer < SOAP::RPC::StandaloneServer
|
||||||
|
class AuthHeaderService
|
||||||
|
def self.create
|
||||||
|
new
|
||||||
|
end
|
||||||
|
|
||||||
|
def deposit(amt)
|
||||||
|
"deposit #{amt} OK"
|
||||||
|
end
|
||||||
|
|
||||||
|
def withdrawal(amt)
|
||||||
|
"withdrawal #{amt} OK"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(*arg)
|
||||||
|
super
|
||||||
|
add_rpc_servant(AuthHeaderService.new, PortName)
|
||||||
|
ServerAuthHeaderHandler.init
|
||||||
|
add_rpc_request_headerhandler(ServerAuthHeaderHandler)
|
||||||
|
end
|
||||||
|
|
||||||
|
class ServerAuthHeaderHandler < SOAP::Header::SimpleHandler
|
||||||
|
class << self
|
||||||
|
def create
|
||||||
|
new
|
||||||
|
end
|
||||||
|
|
||||||
|
def init
|
||||||
|
@users = {
|
||||||
|
'NaHi' => 'passwd',
|
||||||
|
'HiNa' => 'wspass'
|
||||||
|
}
|
||||||
|
@sessions = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
def login(userid, passwd)
|
||||||
|
userid and passwd and @users[userid] == passwd
|
||||||
|
end
|
||||||
|
|
||||||
|
def auth(sessionid)
|
||||||
|
@sessions[sessionid][0]
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_session(userid)
|
||||||
|
while true
|
||||||
|
key = create_sessionkey
|
||||||
|
break unless @sessions[key]
|
||||||
|
end
|
||||||
|
@sessions[key] = [userid]
|
||||||
|
key
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy_session(sessionkey)
|
||||||
|
@sessions.delete(sessionkey)
|
||||||
|
end
|
||||||
|
|
||||||
|
def sessions
|
||||||
|
@sessions
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def create_sessionkey
|
||||||
|
Time.now.usec.to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
super(MyHeaderName)
|
||||||
|
@userid = @sessionid = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_simple_outbound
|
||||||
|
{ "sessionid" => @sessionid }
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_simple_inbound(my_header, mu)
|
||||||
|
auth = false
|
||||||
|
userid = my_header["userid"]
|
||||||
|
passwd = my_header["passwd"]
|
||||||
|
if self.class.login(userid, passwd)
|
||||||
|
auth = true
|
||||||
|
elsif sessionid = my_header["sessionid"]
|
||||||
|
if userid = self.class.auth(sessionid)
|
||||||
|
self.class.destroy_session(sessionid)
|
||||||
|
auth = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
raise RuntimeError.new("authentication failed") unless auth
|
||||||
|
@userid = userid
|
||||||
|
@sessionid = self.class.create_session(userid)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class ClientAuthHeaderHandler < SOAP::Header::SimpleHandler
|
||||||
|
def initialize(userid, passwd, mustunderstand)
|
||||||
|
super(MyHeaderName)
|
||||||
|
@sessionid = nil
|
||||||
|
@userid = userid
|
||||||
|
@passwd = passwd
|
||||||
|
@mustunderstand = mustunderstand
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_simple_outbound
|
||||||
|
if @sessionid
|
||||||
|
{ "sessionid" => @sessionid }
|
||||||
|
else
|
||||||
|
{ "userid" => @userid, "passwd" => @passwd }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_simple_inbound(my_header, mustunderstand)
|
||||||
|
@sessionid = my_header["sessionid"]
|
||||||
|
end
|
||||||
|
|
||||||
|
def sessionid
|
||||||
|
@sessionid
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class DummyHeaderHandler < SOAP::Header::SimpleHandler
|
||||||
|
def initialize(mustunderstand)
|
||||||
|
super(DummyHeaderName)
|
||||||
|
@mustunderstand = mustunderstand
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_simple_outbound
|
||||||
|
{ XSD::QName.new("foo", "bar") => nil }
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_simple_inbound(my_header, mustunderstand)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def setup
|
||||||
|
@endpoint = "http://localhost:#{Port}/"
|
||||||
|
setup_server
|
||||||
|
setup_client
|
||||||
|
end
|
||||||
|
|
||||||
|
def setup_server
|
||||||
|
@server = AuthHeaderPortServer.new(self.class.name, nil, '0.0.0.0', Port)
|
||||||
|
@server.level = Logger::Severity::ERROR
|
||||||
|
@t = Thread.new {
|
||||||
|
@server.start
|
||||||
|
}
|
||||||
|
while @server.status != :Running
|
||||||
|
sleep 0.1
|
||||||
|
unless @t.alive?
|
||||||
|
@t.join
|
||||||
|
raise
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def setup_client
|
||||||
|
@client = SOAP::RPC::Driver.new(@endpoint, PortName)
|
||||||
|
@client.wiredump_dev = STDERR if $DEBUG
|
||||||
|
@client.add_method('deposit', 'amt')
|
||||||
|
@client.add_method('withdrawal', 'amt')
|
||||||
|
end
|
||||||
|
|
||||||
|
def teardown
|
||||||
|
teardown_server
|
||||||
|
teardown_client
|
||||||
|
end
|
||||||
|
|
||||||
|
def teardown_server
|
||||||
|
@server.shutdown
|
||||||
|
@t.kill
|
||||||
|
@t.join
|
||||||
|
end
|
||||||
|
|
||||||
|
def teardown_client
|
||||||
|
@client.reset_stream
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_success_no_mu
|
||||||
|
h = ClientAuthHeaderHandler.new('NaHi', 'passwd', false)
|
||||||
|
@client.headerhandler << h
|
||||||
|
do_transaction_check(h)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_success_mu
|
||||||
|
h = ClientAuthHeaderHandler.new('NaHi', 'passwd', true)
|
||||||
|
@client.headerhandler << h
|
||||||
|
do_transaction_check(h)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_no_mu
|
||||||
|
h = ClientAuthHeaderHandler.new('NaHi', 'passwd', true)
|
||||||
|
@client.headerhandler << h
|
||||||
|
@client.headerhandler << DummyHeaderHandler.new(false)
|
||||||
|
do_transaction_check(h)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_mu
|
||||||
|
h = ClientAuthHeaderHandler.new('NaHi', 'passwd', true)
|
||||||
|
@client.headerhandler << h
|
||||||
|
@client.headerhandler << (h2 = DummyHeaderHandler.new(true))
|
||||||
|
assert_raise(SOAP::UnhandledMustUnderstandHeaderError) do
|
||||||
|
assert_equal("deposit 150 OK", @client.deposit(150))
|
||||||
|
end
|
||||||
|
@client.headerhandler.delete(h2)
|
||||||
|
@client.headerhandler << (h2 = DummyHeaderHandler.new(false))
|
||||||
|
do_transaction_check(h)
|
||||||
|
end
|
||||||
|
|
||||||
|
def do_transaction_check(h)
|
||||||
|
assert_equal("deposit 150 OK", @client.deposit(150))
|
||||||
|
serversess = AuthHeaderPortServer::ServerAuthHeaderHandler.sessions[h.sessionid]
|
||||||
|
assert_equal("NaHi", serversess[0])
|
||||||
|
assert_equal("withdrawal 120 OK", @client.withdrawal(120))
|
||||||
|
serversess = AuthHeaderPortServer::ServerAuthHeaderHandler.sessions[h.sessionid]
|
||||||
|
assert_equal("NaHi", serversess[0])
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_authfailure
|
||||||
|
h = ClientAuthHeaderHandler.new('NaHi', 'pa', false)
|
||||||
|
@client.headerhandler << h
|
||||||
|
assert_raises(RuntimeError) do
|
||||||
|
@client.deposit(150)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
128
test/soap/header/test_authheader_cgi.rb
Normal file
128
test/soap/header/test_authheader_cgi.rb
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
require 'test/unit'
|
||||||
|
require 'soap/rpc/driver'
|
||||||
|
require 'soap/rpc/standaloneServer'
|
||||||
|
require 'soap/header/simplehandler'
|
||||||
|
require 'logger'
|
||||||
|
require 'webrick'
|
||||||
|
require 'rbconfig'
|
||||||
|
|
||||||
|
|
||||||
|
module SOAP
|
||||||
|
module Header
|
||||||
|
|
||||||
|
|
||||||
|
class TestAuthHeaderCGI < Test::Unit::TestCase
|
||||||
|
# This test shuld be run after installing ruby.
|
||||||
|
RUBYBIN = File.join(
|
||||||
|
Config::CONFIG["bindir"],
|
||||||
|
Config::CONFIG["ruby_install_name"] + Config::CONFIG["EXEEXT"]
|
||||||
|
)
|
||||||
|
RUBYBIN << " -d" if $DEBUG
|
||||||
|
|
||||||
|
Port = 17171
|
||||||
|
PortName = 'http://tempuri.org/authHeaderPort'
|
||||||
|
SupportPortName = 'http://tempuri.org/authHeaderSupportPort'
|
||||||
|
MyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "auth")
|
||||||
|
|
||||||
|
class ClientAuthHeaderHandler < SOAP::Header::SimpleHandler
|
||||||
|
def initialize(userid, passwd)
|
||||||
|
super(MyHeaderName)
|
||||||
|
@sessionid = nil
|
||||||
|
@userid = userid
|
||||||
|
@passwd = passwd
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_simple_outbound
|
||||||
|
if @sessionid
|
||||||
|
{ "sessionid" => @sessionid }
|
||||||
|
else
|
||||||
|
{ "userid" => @userid, "passwd" => @passwd }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_simple_inbound(my_header, mustunderstand)
|
||||||
|
@sessionid = my_header["sessionid"]
|
||||||
|
end
|
||||||
|
|
||||||
|
def sessionid
|
||||||
|
@sessionid
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def setup
|
||||||
|
@endpoint = "http://localhost:#{Port}/"
|
||||||
|
setup_server
|
||||||
|
setup_client
|
||||||
|
end
|
||||||
|
|
||||||
|
def setup_server
|
||||||
|
@endpoint = "http://localhost:#{Port}/server.cgi"
|
||||||
|
logger = Logger.new(STDERR)
|
||||||
|
logger.level = Logger::Severity::ERROR
|
||||||
|
@server = WEBrick::HTTPServer.new(
|
||||||
|
:BindAddress => "0.0.0.0",
|
||||||
|
:Logger => logger,
|
||||||
|
:Port => Port,
|
||||||
|
:AccessLog => [],
|
||||||
|
:DocumentRoot => File.dirname(File.expand_path(__FILE__)),
|
||||||
|
:CGIPathEnv => ENV['PATH'],
|
||||||
|
:CGIInterpreter => RUBYBIN
|
||||||
|
)
|
||||||
|
@t = Thread.new {
|
||||||
|
Thread.current.abort_on_exception = true
|
||||||
|
@server.start
|
||||||
|
}
|
||||||
|
while @server.status != :Running
|
||||||
|
sleep 0.1
|
||||||
|
unless @t.alive?
|
||||||
|
@t.join
|
||||||
|
raise
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def setup_client
|
||||||
|
@client = SOAP::RPC::Driver.new(@endpoint, PortName)
|
||||||
|
@client.wiredump_dev = STDERR if $DEBUG
|
||||||
|
@client.add_method('deposit', 'amt')
|
||||||
|
@client.add_method('withdrawal', 'amt')
|
||||||
|
@supportclient = SOAP::RPC::Driver.new(@endpoint, SupportPortName)
|
||||||
|
@supportclient.add_method('delete_sessiondb')
|
||||||
|
end
|
||||||
|
|
||||||
|
def teardown
|
||||||
|
@supportclient.delete_sessiondb
|
||||||
|
teardown_server
|
||||||
|
teardown_client
|
||||||
|
end
|
||||||
|
|
||||||
|
def teardown_server
|
||||||
|
@server.shutdown
|
||||||
|
@t.kill
|
||||||
|
@t.join
|
||||||
|
end
|
||||||
|
|
||||||
|
def teardown_client
|
||||||
|
@client.reset_stream
|
||||||
|
@supportclient.reset_stream
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_success
|
||||||
|
h = ClientAuthHeaderHandler.new('NaHi', 'passwd')
|
||||||
|
@client.headerhandler << h
|
||||||
|
assert_equal("deposit 150 OK", @client.deposit(150))
|
||||||
|
assert_equal("withdrawal 120 OK", @client.withdrawal(120))
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_authfailure
|
||||||
|
h = ClientAuthHeaderHandler.new('NaHi', 'pa')
|
||||||
|
@client.headerhandler << h
|
||||||
|
assert_raises(RuntimeError) do
|
||||||
|
@client.deposit(150)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
1
test/soap/ssl/README
Normal file
1
test/soap/ssl/README
Normal file
@ -0,0 +1 @@
|
|||||||
|
* certificates and keys in this directory is copied from http-access2 test.
|
23
test/soap/ssl/ca.cert
Normal file
23
test/soap/ssl/ca.cert
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIID0DCCArigAwIBAgIBADANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGDAJKUDES
|
||||||
|
MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxCzAJBgNVBAMMAkNBMB4X
|
||||||
|
DTA0MDEzMDAwNDIzMloXDTM2MDEyMjAwNDIzMlowPDELMAkGA1UEBgwCSlAxEjAQ
|
||||||
|
BgNVBAoMCUpJTi5HUi5KUDEMMAoGA1UECwwDUlJSMQswCQYDVQQDDAJDQTCCASIw
|
||||||
|
DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANbv0x42BTKFEQOE+KJ2XmiSdZpR
|
||||||
|
wjzQLAkPLRnLB98tlzs4xo+y4RyY/rd5TT9UzBJTIhP8CJi5GbS1oXEerQXB3P0d
|
||||||
|
L5oSSMwGGyuIzgZe5+vZ1kgzQxMEKMMKlzA73rbMd4Jx3u5+jdbP0EDrPYfXSvLY
|
||||||
|
bS04n2aX7zrN3x5KdDrNBfwBio2/qeaaj4+9OxnwRvYP3WOvqdW0h329eMfHw0pi
|
||||||
|
JI0drIVdsEqClUV4pebT/F+CPUPkEh/weySgo9wANockkYu5ujw2GbLFcO5LXxxm
|
||||||
|
dEfcVr3r6t6zOA4bJwL0W/e6LBcrwiG/qPDFErhwtgTLYf6Er67SzLyA66UCAwEA
|
||||||
|
AaOB3DCB2TAPBgNVHRMBAf8EBTADAQH/MDEGCWCGSAGG+EIBDQQkFiJSdWJ5L09w
|
||||||
|
ZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRlMB0GA1UdDgQWBBRJ7Xd380KzBV7f
|
||||||
|
USKIQ+O/vKbhDzAOBgNVHQ8BAf8EBAMCAQYwZAYDVR0jBF0wW4AUSe13d/NCswVe
|
||||||
|
31EiiEPjv7ym4Q+hQKQ+MDwxCzAJBgNVBAYMAkpQMRIwEAYDVQQKDAlKSU4uR1Iu
|
||||||
|
SlAxDDAKBgNVBAsMA1JSUjELMAkGA1UEAwwCQ0GCAQAwDQYJKoZIhvcNAQEFBQAD
|
||||||
|
ggEBAIu/mfiez5XN5tn2jScgShPgHEFJBR0BTJBZF6xCk0jyqNx/g9HMj2ELCuK+
|
||||||
|
r/Y7KFW5c5M3AQ+xWW0ZSc4kvzyTcV7yTVIwj2jZ9ddYMN3nupZFgBK1GB4Y05GY
|
||||||
|
MJJFRkSu6d/Ph5ypzBVw2YMT/nsOo5VwMUGLgS7YVjU+u/HNWz80J3oO17mNZllj
|
||||||
|
PvORJcnjwlroDnS58KoJ7GDgejv3ESWADvX1OHLE4cRkiQGeLoEU4pxdCxXRqX0U
|
||||||
|
PbwIkZN9mXVcrmPHq8MWi4eC/V7hnbZETMHuWhUoiNdOEfsAXr3iP4KjyyRdwc7a
|
||||||
|
d/xgcK06UVQRL/HbEYGiQL056mc=
|
||||||
|
-----END CERTIFICATE-----
|
19
test/soap/ssl/client.cert
Normal file
19
test/soap/ssl/client.cert
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIDKDCCAhCgAwIBAgIBAjANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGDAJKUDES
|
||||||
|
MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxCzAJBgNVBAMMAkNBMB4X
|
||||||
|
DTA0MDEzMTAzMTQ1OFoXDTM1MDEyMzAzMTQ1OFowZTELMAkGA1UEBgwCSlAxEjAQ
|
||||||
|
BgNVBAoMCUpJTi5HUi5KUDEMMAoGA1UECwwDUlJSMRAwDgYDVQQDDAdleGFtcGxl
|
||||||
|
MSIwIAYJKoZIhvcNAQkBDBNleGFtcGxlQGV4YW1wbGUub3JnMIGfMA0GCSqGSIb3
|
||||||
|
DQEBAQUAA4GNADCBiQKBgQDRWssrK8Gyr+500hpLjCGR3+AHL8/hEJM5zKi/MgLW
|
||||||
|
jTkvsgOwbYwXOiNtAbR9y4/ucDq7EY+cMUMHES4uFaPTcOaAV0aZRmk8AgslN1tQ
|
||||||
|
gNS6ew7/Luq3DcVeWkX8PYgR9VG0mD1MPfJ6+IFA5d3vKpdBkBgN4l46jjO0/2Xf
|
||||||
|
ewIDAQABo4GPMIGMMAwGA1UdEwEB/wQCMAAwMQYJYIZIAYb4QgENBCQWIlJ1Ynkv
|
||||||
|
T3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFOFvay0H7lr2
|
||||||
|
xUx6waYEV2bVDYQhMAsGA1UdDwQEAwIF4DAdBgNVHSUEFjAUBggrBgEFBQcDAgYI
|
||||||
|
KwYBBQUHAwQwDQYJKoZIhvcNAQEFBQADggEBABd2dYWqbDIWf5sWFvslezxJv8gI
|
||||||
|
w64KCJBuyJAiDuf+oazr3016kMzAlt97KecLZDusGNagPrq02UX7YMoQFsWJBans
|
||||||
|
cDtHrkM0al5r6/WGexNMgtYbNTYzt/IwodISGBgZ6dsOuhznwms+IBsTNDAvWeLP
|
||||||
|
lt2tOqD8kEmjwMgn0GDRuKjs4EoboA3kMULb1p9akDV9ZESU3eOtpS5/G5J5msLI
|
||||||
|
9WXbYBjcjvkLuJH9VsJhb+R58Vl0ViemvAHhPilSl1SPWVunGhv6FcIkdBEi1k9F
|
||||||
|
e8BNMmsEjFiANiIRvpdLRbiGBt0KrKTndVfsmoKCvY48oCOvnzxtahFxfs8=
|
||||||
|
-----END CERTIFICATE-----
|
15
test/soap/ssl/client.key
Normal file
15
test/soap/ssl/client.key
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIICWwIBAAKBgQDRWssrK8Gyr+500hpLjCGR3+AHL8/hEJM5zKi/MgLWjTkvsgOw
|
||||||
|
bYwXOiNtAbR9y4/ucDq7EY+cMUMHES4uFaPTcOaAV0aZRmk8AgslN1tQgNS6ew7/
|
||||||
|
Luq3DcVeWkX8PYgR9VG0mD1MPfJ6+IFA5d3vKpdBkBgN4l46jjO0/2XfewIDAQAB
|
||||||
|
AoGAZcz8llWErtsV3QB9gNb3S/PNADGjqBFjReva8n3jG2k4sZSibpwWTwUaTNtT
|
||||||
|
ZQgjSRKRvH1hk9XwffNAvXAQZNNkuj/16gO2oO45nyLj4dO365ujLptWnVIWDHOE
|
||||||
|
uN0GeiZO+VzcCisT0WCq4tvtLeH8svrxzA8cbXIEyOK7NiECQQDwo2zPFyKAZ/Cu
|
||||||
|
lDJ6zKT+RjfWwW7DgWzirAlTrt4ViMaW+IaDH29TmQpb4V4NuR3Xi+2Xl4oicu6S
|
||||||
|
36TW9+/FAkEA3rgfOQJuLlWSnw1RTGwvnC816a/W7iYYY7B+0U4cDbfWl7IoXT4y
|
||||||
|
M8nV/HESooviZLqBwzAYSoj3fFKYBKpGPwJAUO8GN5iWWA2dW3ooiDiv/X1sZmRk
|
||||||
|
dojfMFWgRW747tEzya8Ivq0h6kH8w+5GjeMG8Gn1nRiwsulo6Ckj7dEx6QJACyui
|
||||||
|
7UIQ8qP6GZ4aYMHgVW4Mvy7Bkeo5OO7GPYs0Xv/EdJFL8vlGnVBXOjUVoS9w6Gpu
|
||||||
|
TbLg1QQvnX2rADjmEwJANxZO2GUkaWGsEif8aGW0x5g/IdaMGG27pTWk5zqix7P3
|
||||||
|
1UDrdo/JOXhptovhRi06EppIxAxYmbh9vd9VN8Itlw==
|
||||||
|
-----END RSA PRIVATE KEY-----
|
19
test/soap/ssl/server.cert
Normal file
19
test/soap/ssl/server.cert
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIC/zCCAeegAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MQswCQYDVQQGDAJKUDES
|
||||||
|
MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxDjAMBgNVBAMMBVN1YkNB
|
||||||
|
MB4XDTA0MDEzMTAzMTMxNloXDTMzMDEyMzAzMTMxNlowQzELMAkGA1UEBgwCSlAx
|
||||||
|
EjAQBgNVBAoMCUpJTi5HUi5KUDEMMAoGA1UECwwDUlJSMRIwEAYDVQQDDAlsb2Nh
|
||||||
|
bGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANFJTxWqup3nV9dsJAku
|
||||||
|
p+WaXnPNIzcpAA3qMGZDJTJsfa8Du7ZxTP0XJK5mETttBrn711cJxAuP3KjqnW9S
|
||||||
|
vtZ9lY2sXJ6Zj62sN5LwG3VVe25dI28yR1EsbHjJ5Zjf9tmggMC6am52dxuHbt5/
|
||||||
|
vHo4ngJuKE/U+eeGRivMn6gFAgMBAAGjgYUwgYIwDAYDVR0TAQH/BAIwADAxBglg
|
||||||
|
hkgBhvhCAQ0EJBYiUnVieS9PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAd
|
||||||
|
BgNVHQ4EFgQUpZIyygD9JxFYHHOTEuWOLbCKfckwCwYDVR0PBAQDAgWgMBMGA1Ud
|
||||||
|
JQQMMAoGCCsGAQUFBwMBMA0GCSqGSIb3DQEBBQUAA4IBAQBwAIj5SaBHaA5X31IP
|
||||||
|
CFCJiep96awfp7RANO0cuUj+ZpGoFn9d6FXY0g+Eg5wAkCNIzZU5NHN9xsdOpnUo
|
||||||
|
zIBbyTfQEPrge1CMWMvL6uGaoEXytq84VTitF/xBTky4KtTn6+es4/e7jrrzeUXQ
|
||||||
|
RC46gkHObmDT91RkOEGjHLyld2328jo3DIN/VTHIryDeVHDWjY5dENwpwdkhhm60
|
||||||
|
DR9IrNBbXWEe9emtguNXeN0iu1ux0lG1Hc6pWGQxMlRKNvGh0yZB9u5EVe38tOV0
|
||||||
|
jQaoNyL7qzcQoXD3Dmbi1p0iRmg/+HngISsz8K7k7MBNVsSclztwgCzTZOBiVtkM
|
||||||
|
rRlQ
|
||||||
|
-----END CERTIFICATE-----
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user