зеркало из https://github.com/github/ruby.git
* test/wsdl/raa/*: add new testcase for WSDL loading, parsing and reading.
* test/soap/marshal/*: backport from soap4r/1.5.1. all differences are for ruby/1.6. * lib/soap/*: backport from soap4r/1.5.1. all differences are for ruby/1.6. * lib/wsdl/data.rb, lib/wsdl/xmlSchema/data.rb: move definition of ArrayTypeAttrName from ::WSDL::XMLSchema::* to ::WSDL::*. [ruby-talk:84813] * lib/wsdl/soap/definitions.rb: element name typo in custom exception struct definition which is needed for wsdlDriver; camelCase -> underscore_name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
2c35c4254e
Коммит
b7931c40fe
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
|||
Sat Nov 8 18:50:20 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
|
||||
|
||||
* test/wsdl/raa/*: add new testcase for WSDL loading, parsing and
|
||||
reading.
|
||||
|
||||
* test/soap/marshal/*: backport from soap4r/1.5.1. all differences are
|
||||
for ruby/1.6.
|
||||
|
||||
* lib/soap/*: backport from soap4r/1.5.1. all differences are for
|
||||
ruby/1.6.
|
||||
|
||||
* lib/wsdl/data.rb, lib/wsdl/xmlSchema/data.rb: move definition of
|
||||
ArrayTypeAttrName from ::WSDL::XMLSchema::* to ::WSDL::*.
|
||||
[ruby-talk:84813]
|
||||
|
||||
* lib/wsdl/soap/definitions.rb: element name typo in custom exception
|
||||
struct definition which is needed for wsdlDriver; camelCase ->
|
||||
underscore_name.
|
||||
|
||||
Sat Nov 8 13:49:50 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
* configure.in: improvement of pthread check
|
||||
|
|
|
@ -44,10 +44,29 @@ class Factory
|
|||
klass.allocate
|
||||
end
|
||||
else
|
||||
MARSHAL_TAG = {
|
||||
String => ['"', 1],
|
||||
Regexp => ['/', 2],
|
||||
Array => ['[', 1],
|
||||
Hash => ['{', 1]
|
||||
}
|
||||
def create_empty_object(klass)
|
||||
if klass <= Struct
|
||||
name = klass.name
|
||||
return ::Marshal.load(sprintf("\004\006S:%c%s\000", name.length + 5, name))
|
||||
end
|
||||
if MARSHAL_TAG.has_key?(klass)
|
||||
tag, terminate = MARSHAL_TAG[klass]
|
||||
return ::Marshal.load(sprintf("\004\006%s%s", tag, "\000" * terminate))
|
||||
end
|
||||
MARSHAL_TAG.each do |k, v|
|
||||
if klass < k
|
||||
name = klass.name
|
||||
tag, terminate = v
|
||||
return ::Marshal.load(sprintf("\004\006C:%c%s%s%s", name.length + 5, name, tag, "\000" * terminate))
|
||||
end
|
||||
end
|
||||
name = klass.name
|
||||
# Below line is from TANAKA, Akira's amarshal.rb.
|
||||
# See http://cvs.m17n.org/cgi-bin/viewcvs/amarshal/?cvsroot=ruby
|
||||
::Marshal.load(sprintf("\004\006o:%c%s\000", name.length + 5, name))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -426,12 +426,23 @@ private
|
|||
Mapping.set_instance_vars(obj, vars)
|
||||
end
|
||||
|
||||
if RUBY_VERSION >= '1.8.0'
|
||||
def addextend2obj(obj, attr)
|
||||
return unless attr
|
||||
attr.split(/ /).reverse_each do |mstr|
|
||||
obj.extend(Mapping.class_from_name(mstr))
|
||||
end
|
||||
end
|
||||
else
|
||||
# (class < false; self; end).ancestors includes "TrueClass" under 1.6...
|
||||
def addextend2obj(obj, attr)
|
||||
return unless attr
|
||||
attr.split(/ /).reverse_each do |mstr|
|
||||
m = Mapping.class_from_name(mstr)
|
||||
obj.extend(m) if m.class == Module
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def addextend2soap(node, obj)
|
||||
return if obj.is_a?(Symbol) or obj.is_a?(Fixnum)
|
||||
|
|
|
@ -24,7 +24,7 @@ require 'xsd/charset'
|
|||
module SOAP
|
||||
|
||||
|
||||
Version = '1.5.0'
|
||||
Version = '1.5.1'
|
||||
|
||||
EnvelopeNamespace = 'http://schemas.xmlsoap.org/soap/envelope/'
|
||||
EncodingNamespace = 'http://schemas.xmlsoap.org/soap/encoding/'
|
||||
|
|
|
@ -35,6 +35,7 @@ require 'wsdl/import'
|
|||
module WSDL
|
||||
|
||||
|
||||
ArrayTypeAttrName = XSD::QName.new(Namespace, 'arrayType')
|
||||
BindingName = XSD::QName.new(Namespace, 'binding')
|
||||
DefinitionsName = XSD::QName.new(Namespace, 'definitions')
|
||||
DocumentationName = XSD::QName.new(Namespace, 'documentation')
|
||||
|
|
|
@ -117,7 +117,7 @@ private
|
|||
def exception_complextype
|
||||
type = XMLSchema::ComplexType.new(XSD::QName.new(
|
||||
::SOAP::Mapping::RubyCustomTypeNamespace, 'SOAPException'))
|
||||
excn_name = XMLSchema::Element.new(XSD::QName.new(nil, 'exceptionTypeName'), XSD::XSDString::Type)
|
||||
excn_name = XMLSchema::Element.new(XSD::QName.new(nil, 'excn_type_name'), XSD::XSDString::Type)
|
||||
cause = XMLSchema::Element.new(XSD::QName.new(nil, 'cause'), XSD::AnyTypeName)
|
||||
backtrace = XMLSchema::Element.new(XSD::QName.new(nil, 'backtrace'), ::SOAP::ValueArrayName)
|
||||
message = XMLSchema::Element.new(XSD::QName.new(nil, 'message'), XSD::XSDString::Type)
|
||||
|
|
|
@ -36,7 +36,6 @@ module XMLSchema
|
|||
|
||||
AllName = XSD::QName.new(XSD::Namespace, 'all')
|
||||
AnyName = XSD::QName.new(XSD::Namespace, 'any')
|
||||
ArrayTypeAttrName = XSD::QName.new(XSD::Namespace, 'arrayType')
|
||||
AttributeName = XSD::QName.new(XSD::Namespace, 'attribute')
|
||||
ChoiceName = XSD::QName.new(XSD::Namespace, 'choice')
|
||||
ComplexContentName = XSD::QName.new(XSD::Namespace, 'complexContent')
|
||||
|
|
|
@ -36,7 +36,9 @@ class TestDigraph < Test::Unit::TestCase
|
|||
f = File.open("digraph_marshalled_string.soap", "wb")
|
||||
SOAP::Marshal.dump(@n1, f)
|
||||
f.close
|
||||
str = File.read("digraph_marshalled_string.soap")
|
||||
f = File.open("digraph_marshalled_string.soap")
|
||||
str = f.read
|
||||
f.close
|
||||
newnode = SOAP::Marshal.unmarshal(str)
|
||||
assert_equal(newnode.first.first.__id__, newnode.second.first.__id__)
|
||||
assert_equal(newnode.first.first.first.first.__id__, newnode.second.first.second.first.__id__)
|
||||
|
|
|
@ -78,13 +78,18 @@ module MarshalTestLib
|
|||
}
|
||||
end
|
||||
|
||||
class MyArray < Array; def initialize(v, *args) super args; @v = v; end end
|
||||
class MyArray < Array
|
||||
def initialize(v, args)
|
||||
super(args)
|
||||
@v = v
|
||||
end
|
||||
end
|
||||
def test_array
|
||||
marshal_equal([1,2,3])
|
||||
marshal_equal(5)
|
||||
end
|
||||
|
||||
def test_array_subclass
|
||||
marshal_equal(MyArray.new(0, 1,2,3))
|
||||
marshal_equal(MyArray.new(0, 3))
|
||||
end
|
||||
|
||||
def test_array_ivar
|
||||
|
@ -166,7 +171,8 @@ module MarshalTestLib
|
|||
end
|
||||
|
||||
def test_fixnum
|
||||
marshal_equal(-0x4000_0000)
|
||||
#marshal_equal(-0x4000_0000) # not fixnum under 1.6...
|
||||
marshal_equal(-0x3fff_ffff)
|
||||
marshal_equal(-1)
|
||||
marshal_equal(0)
|
||||
marshal_equal(1)
|
||||
|
@ -253,7 +259,7 @@ module MarshalTestLib
|
|||
end
|
||||
|
||||
def test_string_ivar
|
||||
o1 = String.new
|
||||
o1 = ""
|
||||
o1.instance_eval { @iv = 1 }
|
||||
marshal_equal(o1) {|o| o.instance_eval { @iv }}
|
||||
end
|
||||
|
@ -281,12 +287,31 @@ module MarshalTestLib
|
|||
end
|
||||
|
||||
MyStruct = Struct.new("MyStruct", :a, :b)
|
||||
if RUBY_VERSION < "1.8.0"
|
||||
# Struct#== is not defined in ruby/1.6
|
||||
class MyStruct
|
||||
def ==(rhs)
|
||||
return true if __id__ == rhs.__id__
|
||||
return false unless rhs.is_a?(::Struct)
|
||||
return false if self.class != rhs.class
|
||||
members.each do |member|
|
||||
return false if self.__send__(member) != rhs.__send__(member)
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
class MySubStruct < MyStruct; def initialize(v, *args) super(*args); @v = v; end end
|
||||
def test_struct
|
||||
marshal_equal(MyStruct.new(1,2))
|
||||
end
|
||||
|
||||
def test_struct_subclass
|
||||
if RUBY_VERSION < "1.8.0"
|
||||
# Substruct instance cannot be dumped in ruby/1.6
|
||||
# ::Marshal.dump(MySubStruct.new(10, 1, 2)) #=> uninitialized struct
|
||||
return false
|
||||
end
|
||||
marshal_equal(MySubStruct.new(10,1,2))
|
||||
end
|
||||
|
||||
|
@ -379,6 +404,7 @@ module MarshalTestLib
|
|||
def <=>(other); true; end
|
||||
end
|
||||
def test_range_cyclic
|
||||
return unless CyclicRange.respond_to?(:allocate) # test for 1.8
|
||||
o1 = CyclicRange.allocate
|
||||
o1.instance_eval { initialize(o1, o1) }
|
||||
o2 = marshaltest(o1)
|
||||
|
@ -413,14 +439,14 @@ module MarshalTestLib
|
|||
end
|
||||
|
||||
def test_extend_string
|
||||
o = String.new
|
||||
o = ""
|
||||
o.extend Mod1
|
||||
marshal_equal(o) { |obj| obj.kind_of? Mod1 }
|
||||
o = String.new
|
||||
o = ""
|
||||
o.extend Mod1
|
||||
o.extend Mod2
|
||||
marshal_equal(o) {|obj| class << obj; ancestors end}
|
||||
o = String.new
|
||||
o = ""
|
||||
o.extend Module.new
|
||||
assert_raises(TypeError) { marshaltest(o) }
|
||||
end
|
||||
|
@ -447,8 +473,23 @@ module MarshalTestLib
|
|||
end
|
||||
|
||||
MyStruct2 = Struct.new(:a, :b)
|
||||
if RUBY_VERSION < "1.8.0"
|
||||
# Struct#== is not defined in ruby/1.6
|
||||
class MyStruct2
|
||||
def ==(rhs)
|
||||
return true if __id__ == rhs.__id__
|
||||
return false unless rhs.is_a?(::Struct)
|
||||
return false if self.class != rhs.class
|
||||
members.each do |member|
|
||||
return false if self.__send__(member) != rhs.__send__(member)
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
def test_struct_toplevel
|
||||
marshal_equal(MyStruct2.new(1,2))
|
||||
o = MyStruct2.new(1,2)
|
||||
marshal_equal(o)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,254 @@
|
|||
# http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/
|
||||
class Category
|
||||
@@schema_type = "Category"
|
||||
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"
|
||||
|
||||
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/interface/RAA/0.0.2/
|
||||
class Product
|
||||
@@schema_type = "Product"
|
||||
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"
|
||||
|
||||
def id
|
||||
@id
|
||||
end
|
||||
|
||||
def id=(value)
|
||||
@id = value
|
||||
end
|
||||
|
||||
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 homepage
|
||||
@homepage
|
||||
end
|
||||
|
||||
def homepage=(value)
|
||||
@homepage = 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 initialize(id = nil,
|
||||
name = nil,
|
||||
short_description = nil,
|
||||
version = nil,
|
||||
status = nil,
|
||||
homepage = nil,
|
||||
download = nil,
|
||||
license = nil,
|
||||
description = nil)
|
||||
@id = id
|
||||
@name = name
|
||||
@short_description = short_description
|
||||
@version = version
|
||||
@status = status
|
||||
@homepage = homepage
|
||||
@download = download
|
||||
@license = license
|
||||
@description = description
|
||||
end
|
||||
end
|
||||
|
||||
# http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/
|
||||
class Owner
|
||||
@@schema_type = "Owner"
|
||||
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"
|
||||
|
||||
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/interface/RAA/0.0.2/
|
||||
class Info
|
||||
@@schema_type = "Info"
|
||||
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"
|
||||
|
||||
def category
|
||||
@category
|
||||
end
|
||||
|
||||
def category=(value)
|
||||
@category = value
|
||||
end
|
||||
|
||||
def product
|
||||
@product
|
||||
end
|
||||
|
||||
def product=(value)
|
||||
@product = value
|
||||
end
|
||||
|
||||
def owner
|
||||
@owner
|
||||
end
|
||||
|
||||
def owner=(value)
|
||||
@owner = value
|
||||
end
|
||||
|
||||
def created
|
||||
@created
|
||||
end
|
||||
|
||||
def created=(value)
|
||||
@created = value
|
||||
end
|
||||
|
||||
def updated
|
||||
@updated
|
||||
end
|
||||
|
||||
def updated=(value)
|
||||
@updated = value
|
||||
end
|
||||
|
||||
def initialize(category = nil,
|
||||
product = nil,
|
||||
owner = nil,
|
||||
created = nil,
|
||||
updated = nil)
|
||||
@category = category
|
||||
@product = product
|
||||
@owner = owner
|
||||
@created = created
|
||||
@updated = updated
|
||||
end
|
||||
end
|
||||
|
||||
# http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/
|
||||
class InfoArray < Array
|
||||
# Contents type should be dumped here...
|
||||
@@schema_type = "InfoArray"
|
||||
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"
|
||||
end
|
||||
|
||||
# http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/
|
||||
class StringArray < Array
|
||||
# Contents type should be dumped here...
|
||||
@@schema_type = "StringArray"
|
||||
@@schema_ns = "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"
|
||||
end
|
||||
|
||||
# http://xml.apache.org/xml-soap
|
||||
class Map
|
||||
@@schema_type = "Map"
|
||||
@@schema_ns = "http://xml.apache.org/xml-soap"
|
||||
|
||||
def item
|
||||
@item
|
||||
end
|
||||
|
||||
def item=(value)
|
||||
@item = value
|
||||
end
|
||||
|
||||
def initialize(item = nil)
|
||||
@item = item
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
server.rb: based on RAAService.rb which is generated with the following command;
|
||||
bin/wsdl2ruby.rb --wsdl raa.wsdl --standalone_server_stub --force
|
||||
|
||||
RAA.rb: generated with the following command;
|
||||
bin/wsdl2ruby.rb --wsdl raa.wsdl --classdef --force
|
|
@ -0,0 +1,264 @@
|
|||
<?xml version="1.0"?>
|
||||
<definitions
|
||||
name="RAA"
|
||||
targetNamespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"
|
||||
xmlns:tns="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"
|
||||
xmlns:txd="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"
|
||||
xmlns="http://schemas.xmlsoap.org/wsdl/"
|
||||
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
||||
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
xmlns:apachesoap="http://xml.apache.org/xml-soap">
|
||||
|
||||
<types>
|
||||
<schema
|
||||
xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
targetNamespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/">
|
||||
|
||||
<complexType name="Category">
|
||||
<all>
|
||||
<element name="major" type="string"/>
|
||||
<element name="minor" type="string"/>
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
<complexType name="Product">
|
||||
<all>
|
||||
<element name="id" type="int"/>
|
||||
<element name="name" type="string"/>
|
||||
<element name="short_description" type="string"/>
|
||||
<element name="version" type="string"/>
|
||||
<element name="status" type="string"/>
|
||||
<element name="homepage" type="anyURI"/>
|
||||
<element name="download" type="anyURI"/>
|
||||
<element name="license" type="string"/>
|
||||
<element name="description" type="string"/>
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
<complexType name="Owner">
|
||||
<all>
|
||||
<element name="id" type="int"/>
|
||||
<element name="email" type="anyURI"/>
|
||||
<element name="name" type="string"/>
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
<complexType name="Info">
|
||||
<all>
|
||||
<element name="category" type="txd:Category"/>
|
||||
<element name="product" type="txd:Product"/>
|
||||
<element name="owner" type="txd:Owner"/>
|
||||
<element name="created" type="xsd:dateTime"/>
|
||||
<element name="updated" type="xsd:dateTime"/>
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
|
||||
<complexType name="InfoArray">
|
||||
<complexContent>
|
||||
<restriction base="soapenc:Array">
|
||||
<attribute ref="soapenc:arrayType" wsdl:arrayType="txd:Info[]"/>
|
||||
</restriction>
|
||||
</complexContent>
|
||||
</complexType>
|
||||
|
||||
<complexType name="StringArray">
|
||||
<complexContent>
|
||||
<restriction base="soapenc:Array">
|
||||
<attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
|
||||
</restriction>
|
||||
</complexContent>
|
||||
</complexType>
|
||||
</schema>
|
||||
|
||||
<!-- type definition for ApacheSOAP's Map -->
|
||||
<schema
|
||||
xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
targetNamespace="http://xml.apache.org/xml-soap">
|
||||
<complexType name="Map">
|
||||
<sequence>
|
||||
<element name="item" minOccurs="0" maxOccurs="unbounded">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element name="key" type="anyType" />
|
||||
<element name="value" type="anyType" />
|
||||
</sequence>
|
||||
</complexType>
|
||||
</element>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</schema>
|
||||
</types>
|
||||
|
||||
<message name="getAllListingsRequest"/>
|
||||
<message name="getAllListingsResponse">
|
||||
<part name="return" type="txd:StringArray"/>
|
||||
</message>
|
||||
|
||||
<message name="getProductTreeRequest"/>
|
||||
<message name="getProductTreeResponse">
|
||||
<part name="return" type="apachesoap:Map"/>
|
||||
</message>
|
||||
|
||||
<message name="getInfoFromCategoryRequest">
|
||||
<part name="category" type="txd:Category"/>
|
||||
</message>
|
||||
<message name="getInfoFromCategoryResponse">
|
||||
<part name="return" type="txd:InfoArray"/>
|
||||
</message>
|
||||
|
||||
<message name="getModifiedInfoSinceRequest">
|
||||
<part name="timeInstant" type="xsd:dateTime"/>
|
||||
</message>
|
||||
<message name="getModifiedInfoSinceResponse">
|
||||
<part name="return" type="txd:InfoArray"/>
|
||||
</message>
|
||||
|
||||
<message name="getInfoFromNameRequest">
|
||||
<part name="productName" type="xsd:string"/>
|
||||
</message>
|
||||
<message name="getInfoFromNameResponse">
|
||||
<part name="return" type="txd:Info"/>
|
||||
</message>
|
||||
|
||||
<message name="getInfoFromOwnerIdRequest">
|
||||
<part name="ownerId" type="xsd:int"/>
|
||||
</message>
|
||||
<message name="getInfoFromOwnerIdResponse">
|
||||
<part name="return" type="txd:InfoArray"/>
|
||||
</message>
|
||||
|
||||
<portType name="RAABaseServicePortType">
|
||||
<operation name="getAllListings"
|
||||
parameterOrder="">
|
||||
<input message="tns:getAllListingsRequest"/>
|
||||
<output message="tns:getAllListingsResponse"/>
|
||||
</operation>
|
||||
|
||||
<operation name="getProductTree"
|
||||
parameterOrder="">
|
||||
<input message="tns:getProductTreeRequest"/>
|
||||
<output message="tns:getProductTreeResponse"/>
|
||||
</operation>
|
||||
|
||||
<operation name="getInfoFromCategory"
|
||||
parameterOrder="category">
|
||||
<input message="tns:getInfoFromCategoryRequest"/>
|
||||
<output message="tns:getInfoFromCategoryResponse"/>
|
||||
</operation>
|
||||
|
||||
<operation name="getModifiedInfoSince"
|
||||
parameterOrder="timeInstant">
|
||||
<input message="tns:getModifiedInfoSinceRequest"/>
|
||||
<output message="tns:getModifiedInfoSinceResponse"/>
|
||||
</operation>
|
||||
|
||||
<operation name="getInfoFromName"
|
||||
parameterOrder="productName">
|
||||
<input message="tns:getInfoFromNameRequest"/>
|
||||
<output message="tns:getInfoFromNameResponse"/>
|
||||
</operation>
|
||||
|
||||
<operation name="getInfoFromOwnerId"
|
||||
parameterOrder="ownerId">
|
||||
<input message="tns:getInfoFromOwnerIdRequest"/>
|
||||
<output message="tns:getInfoFromOwnerIdResponse"/>
|
||||
</operation>
|
||||
</portType>
|
||||
|
||||
<binding name="RAABaseServicePortBinding" type="tns:RAABaseServicePortType">
|
||||
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
|
||||
|
||||
<operation name="getAllListings">
|
||||
<soap:operation soapAction=""/>
|
||||
<input>
|
||||
<soap:body use="encoded"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
|
||||
</input>
|
||||
<output>
|
||||
<soap:body use="encoded"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
|
||||
</output>
|
||||
</operation>
|
||||
|
||||
<operation name="getProductTree">
|
||||
<soap:operation soapAction=""/>
|
||||
<input>
|
||||
<soap:body use="encoded"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
|
||||
</input>
|
||||
<output>
|
||||
<soap:body use="encoded"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
|
||||
</output>
|
||||
</operation>
|
||||
|
||||
<operation name="getInfoFromCategory">
|
||||
<soap:operation soapAction=""/>
|
||||
<input>
|
||||
<soap:body use="encoded"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
|
||||
</input>
|
||||
<output>
|
||||
<soap:body use="encoded"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
|
||||
</output>
|
||||
</operation>
|
||||
|
||||
<operation name="getModifiedInfoSince">
|
||||
<soap:operation soapAction=""/>
|
||||
<input>
|
||||
<soap:body use="encoded"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
|
||||
</input>
|
||||
<output>
|
||||
<soap:body use="encoded"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
|
||||
</output>
|
||||
</operation>
|
||||
|
||||
<operation name="getInfoFromName">
|
||||
<soap:operation soapAction=""/>
|
||||
<input>
|
||||
<soap:body use="encoded"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
|
||||
</input>
|
||||
<output>
|
||||
<soap:body use="encoded"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
|
||||
</output>
|
||||
</operation>
|
||||
|
||||
<operation name="getInfoFromOwnerId">
|
||||
<soap:operation soapAction=""/>
|
||||
<input>
|
||||
<soap:body use="encoded"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
|
||||
</input>
|
||||
<output>
|
||||
<soap:body use="encoded"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
|
||||
</output>
|
||||
</operation>
|
||||
</binding>
|
||||
|
||||
<service name="RAAService">
|
||||
<port name="RAABaseServicePort" binding="tns:RAABaseServicePortBinding">
|
||||
<soap:address location="http://raa.ruby-lang.org/soap/1.0.2/"/>
|
||||
</port>
|
||||
</service>
|
||||
</definitions>
|
|
@ -0,0 +1,104 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'soap/rpc/standaloneServer'
|
||||
require 'RAA.rb'
|
||||
|
||||
class RAABaseServicePortType
|
||||
MappingRegistry = SOAP::Mapping::Registry.new
|
||||
|
||||
MappingRegistry.set(
|
||||
StringArray,
|
||||
::SOAP::SOAPArray,
|
||||
::SOAP::Mapping::Registry::TypedArrayFactory,
|
||||
{ :type => XSD::QName.new("http://www.w3.org/2001/XMLSchema", "string") }
|
||||
)
|
||||
MappingRegistry.set(
|
||||
Map,
|
||||
::SOAP::SOAPStruct,
|
||||
::SOAP::Mapping::Registry::TypedStructFactory,
|
||||
{ :type => XSD::QName.new("http://xml.apache.org/xml-soap", "Map") }
|
||||
)
|
||||
MappingRegistry.set(
|
||||
Category,
|
||||
::SOAP::SOAPStruct,
|
||||
::SOAP::Mapping::Registry::TypedStructFactory,
|
||||
{ :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Category") }
|
||||
)
|
||||
MappingRegistry.set(
|
||||
InfoArray,
|
||||
::SOAP::SOAPArray,
|
||||
::SOAP::Mapping::Registry::TypedArrayFactory,
|
||||
{ :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info") }
|
||||
)
|
||||
MappingRegistry.set(
|
||||
Info,
|
||||
::SOAP::SOAPStruct,
|
||||
::SOAP::Mapping::Registry::TypedStructFactory,
|
||||
{ :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info") }
|
||||
)
|
||||
MappingRegistry.set(
|
||||
Product,
|
||||
::SOAP::SOAPStruct,
|
||||
::SOAP::Mapping::Registry::TypedStructFactory,
|
||||
{ :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Product") }
|
||||
)
|
||||
MappingRegistry.set(
|
||||
Owner,
|
||||
::SOAP::SOAPStruct,
|
||||
::SOAP::Mapping::Registry::TypedStructFactory,
|
||||
{ :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Owner") }
|
||||
)
|
||||
|
||||
Methods = [
|
||||
["getAllListings", "getAllListings", [
|
||||
["retval", "return",
|
||||
[::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "string"]]],
|
||||
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"],
|
||||
["getProductTree", "getProductTree", [
|
||||
["retval", "return",
|
||||
[::SOAP::SOAPStruct, "http://xml.apache.org/xml-soap", "Map"]]],
|
||||
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"],
|
||||
["getInfoFromCategory", "getInfoFromCategory", [
|
||||
["in", "category",
|
||||
[::SOAP::SOAPStruct, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Category"]],
|
||||
["retval", "return",
|
||||
[::SOAP::SOAPArray, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]]],
|
||||
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"],
|
||||
["getModifiedInfoSince", "getModifiedInfoSince", [
|
||||
["in", "timeInstant",
|
||||
[SOAP::SOAPDateTime]],
|
||||
["retval", "return",
|
||||
[::SOAP::SOAPArray, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]]],
|
||||
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"],
|
||||
["getInfoFromName", "getInfoFromName", [
|
||||
["in", "productName",
|
||||
[SOAP::SOAPString]],
|
||||
["retval", "return",
|
||||
[::SOAP::SOAPStruct, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]]],
|
||||
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"],
|
||||
["getInfoFromOwnerId", "getInfoFromOwnerId", [
|
||||
["in", "ownerId",
|
||||
[SOAP::SOAPInt]],
|
||||
["retval", "return",
|
||||
[::SOAP::SOAPArray, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]]],
|
||||
"", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"]
|
||||
]
|
||||
|
||||
def getAllListings
|
||||
["ruby", "soap4r"]
|
||||
end
|
||||
end
|
||||
|
||||
class RAABaseServiceServer < SOAP::RPC::StandaloneServer
|
||||
def initialize(*arg)
|
||||
super
|
||||
|
||||
servant = RAABaseServicePortType.new
|
||||
RAABaseServicePortType::Methods.each do |name_as, name, params, soapaction, namespace|
|
||||
qname = XSD::QName.new(namespace, name_as)
|
||||
@soaplet.app_scope_router.add_method(servant, qname, soapaction,
|
||||
name, params)
|
||||
end
|
||||
|
||||
self.mapping_registry = RAABaseServicePortType::MappingRegistry
|
||||
end
|
||||
end
|
|
@ -0,0 +1,78 @@
|
|||
require 'test/unit'
|
||||
require 'soap/wsdlDriver'
|
||||
|
||||
|
||||
module WSDL
|
||||
module RAA
|
||||
|
||||
|
||||
class TestRAA < Test::Unit::TestCase
|
||||
DIR = File.dirname(File.expand_path(__FILE__))
|
||||
|
||||
Port = 17171
|
||||
|
||||
def setup
|
||||
setup_server
|
||||
setup_client
|
||||
end
|
||||
|
||||
def setup_server
|
||||
$:.push(DIR)
|
||||
require File.join(DIR, 'server.rb')
|
||||
$:.delete(DIR)
|
||||
@server = RAABaseServiceServer.new('RAA server', nil, '0.0.0.0', Port)
|
||||
@server.level = Logger::Severity::ERROR
|
||||
@t = Thread.new {
|
||||
Thread.current.abort_on_exception = true
|
||||
@server.start
|
||||
}
|
||||
while @server.server.nil? or @server.server.status != :Running
|
||||
sleep 0.1
|
||||
unless @t.alive?
|
||||
@t.join
|
||||
raise
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def setup_client
|
||||
wsdl = File.join(DIR, 'raa.wsdl')
|
||||
@raa = ::SOAP::WSDLDriverFactory.new(wsdl).create_driver
|
||||
@raa.endpoint_url = "http://localhost:#{Port}/"
|
||||
end
|
||||
|
||||
def teardown
|
||||
teardown_server
|
||||
teardown_client
|
||||
end
|
||||
|
||||
def teardown_server
|
||||
@server.server.shutdown
|
||||
@t.kill
|
||||
@t.join
|
||||
end
|
||||
|
||||
def teardown_client
|
||||
@raa.reset_stream
|
||||
end
|
||||
|
||||
def test_raa
|
||||
assert_equal(["ruby", "soap4r"], @raa.getAllListings)
|
||||
end
|
||||
|
||||
def foo
|
||||
p @raa.getProductTree()
|
||||
p @raa.getInfoFromCategory(Category.new("Library", "XML"))
|
||||
t = Time.at(Time.now.to_i - 24 * 3600)
|
||||
p @raa.getModifiedInfoSince(t)
|
||||
p @raa.getModifiedInfoSince(DateTime.new(t.year, t.mon, t.mday, t.hour, t.min, t.sec))
|
||||
o = @raa.getInfoFromName("SOAP4R")
|
||||
p o.type
|
||||
p o.owner.name
|
||||
p o
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
Загрузка…
Ссылка в новой задаче