summaryrefslogtreecommitdiff
path: root/ruby_1_8_5/lib/wsdl
diff options
context:
space:
mode:
Diffstat (limited to 'ruby_1_8_5/lib/wsdl')
-rw-r--r--ruby_1_8_5/lib/wsdl/binding.rb65
-rw-r--r--ruby_1_8_5/lib/wsdl/data.rb64
-rw-r--r--ruby_1_8_5/lib/wsdl/definitions.rb250
-rw-r--r--ruby_1_8_5/lib/wsdl/documentation.rb32
-rw-r--r--ruby_1_8_5/lib/wsdl/import.rb80
-rw-r--r--ruby_1_8_5/lib/wsdl/importer.rb38
-rw-r--r--ruby_1_8_5/lib/wsdl/info.rb39
-rw-r--r--ruby_1_8_5/lib/wsdl/message.rb54
-rw-r--r--ruby_1_8_5/lib/wsdl/operation.rb130
-rw-r--r--ruby_1_8_5/lib/wsdl/operationBinding.rb108
-rw-r--r--ruby_1_8_5/lib/wsdl/param.rb85
-rw-r--r--ruby_1_8_5/lib/wsdl/parser.rb163
-rw-r--r--ruby_1_8_5/lib/wsdl/part.rb52
-rw-r--r--ruby_1_8_5/lib/wsdl/port.rb84
-rw-r--r--ruby_1_8_5/lib/wsdl/portType.rb73
-rw-r--r--ruby_1_8_5/lib/wsdl/service.rb61
-rw-r--r--ruby_1_8_5/lib/wsdl/soap/address.rb40
-rw-r--r--ruby_1_8_5/lib/wsdl/soap/binding.rb49
-rw-r--r--ruby_1_8_5/lib/wsdl/soap/body.rb56
-rw-r--r--ruby_1_8_5/lib/wsdl/soap/cgiStubCreator.rb76
-rw-r--r--ruby_1_8_5/lib/wsdl/soap/classDefCreator.rb314
-rw-r--r--ruby_1_8_5/lib/wsdl/soap/classDefCreatorSupport.rb126
-rw-r--r--ruby_1_8_5/lib/wsdl/soap/clientSkeltonCreator.rb78
-rw-r--r--ruby_1_8_5/lib/wsdl/soap/complexType.rb161
-rw-r--r--ruby_1_8_5/lib/wsdl/soap/data.rb42
-rw-r--r--ruby_1_8_5/lib/wsdl/soap/definitions.rb149
-rw-r--r--ruby_1_8_5/lib/wsdl/soap/driverCreator.rb95
-rw-r--r--ruby_1_8_5/lib/wsdl/soap/element.rb28
-rw-r--r--ruby_1_8_5/lib/wsdl/soap/fault.rb56
-rw-r--r--ruby_1_8_5/lib/wsdl/soap/header.rb86
-rw-r--r--ruby_1_8_5/lib/wsdl/soap/headerfault.rb56
-rw-r--r--ruby_1_8_5/lib/wsdl/soap/mappingRegistryCreator.rb92
-rw-r--r--ruby_1_8_5/lib/wsdl/soap/methodDefCreator.rb228
-rw-r--r--ruby_1_8_5/lib/wsdl/soap/operation.rb122
-rw-r--r--ruby_1_8_5/lib/wsdl/soap/servantSkeltonCreator.rb67
-rw-r--r--ruby_1_8_5/lib/wsdl/soap/standaloneServerStubCreator.rb85
-rw-r--r--ruby_1_8_5/lib/wsdl/soap/wsdl2ruby.rb176
-rw-r--r--ruby_1_8_5/lib/wsdl/types.rb43
-rw-r--r--ruby_1_8_5/lib/wsdl/wsdl.rb23
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/all.rb69
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/annotation.rb34
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/any.rb56
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/attribute.rb127
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/choice.rb69
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/complexContent.rb92
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/complexType.rb139
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/content.rb96
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/data.rb80
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/element.rb154
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/enumeration.rb36
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/import.rb65
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/importer.rb87
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/include.rb54
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/length.rb35
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/parser.rb166
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/pattern.rb36
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/schema.rb143
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/sequence.rb69
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/simpleContent.rb65
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/simpleExtension.rb54
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/simpleRestriction.rb73
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/simpleType.rb73
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/unique.rb34
-rw-r--r--ruby_1_8_5/lib/wsdl/xmlSchema/xsd2ruby.rb107
64 files changed, 5639 insertions, 0 deletions
diff --git a/ruby_1_8_5/lib/wsdl/binding.rb b/ruby_1_8_5/lib/wsdl/binding.rb
new file mode 100644
index 0000000000..58a21d820d
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/binding.rb
@@ -0,0 +1,65 @@
+# WSDL4R - WSDL binding definition.
+# 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 'xsd/namedelements'
+
+
+module WSDL
+
+
+class Binding < Info
+ attr_reader :name # required
+ attr_reader :type # required
+ attr_reader :operations
+ attr_reader :soapbinding
+
+ def initialize
+ super
+ @name = nil
+ @type = nil
+ @operations = XSD::NamedElements.new
+ @soapbinding = nil
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def parse_element(element)
+ case element
+ when OperationName
+ o = OperationBinding.new
+ @operations << o
+ o
+ when SOAPBindingName
+ o = WSDL::SOAP::Binding.new
+ @soapbinding = o
+ o
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ when TypeAttrName
+ @type = value
+ else
+ nil
+ end
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/lib/wsdl/data.rb b/ruby_1_8_5/lib/wsdl/data.rb
new file mode 100644
index 0000000000..45eaad8526
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/data.rb
@@ -0,0 +1,64 @@
+# WSDL4R - WSDL data definitions.
+# 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 'xsd/qname'
+require 'wsdl/documentation'
+require 'wsdl/definitions'
+require 'wsdl/types'
+require 'wsdl/message'
+require 'wsdl/part'
+require 'wsdl/portType'
+require 'wsdl/operation'
+require 'wsdl/param'
+require 'wsdl/binding'
+require 'wsdl/operationBinding'
+require 'wsdl/service'
+require 'wsdl/port'
+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')
+FaultName = XSD::QName.new(Namespace, 'fault')
+ImportName = XSD::QName.new(Namespace, 'import')
+InputName = XSD::QName.new(Namespace, 'input')
+MessageName = XSD::QName.new(Namespace, 'message')
+OperationName = XSD::QName.new(Namespace, 'operation')
+OutputName = XSD::QName.new(Namespace, 'output')
+PartName = XSD::QName.new(Namespace, 'part')
+PortName = XSD::QName.new(Namespace, 'port')
+PortTypeName = XSD::QName.new(Namespace, 'portType')
+ServiceName = XSD::QName.new(Namespace, 'service')
+TypesName = XSD::QName.new(Namespace, 'types')
+
+SchemaName = XSD::QName.new(XSD::Namespace, 'schema')
+
+SOAPAddressName = XSD::QName.new(SOAPBindingNamespace, 'address')
+SOAPBindingName = XSD::QName.new(SOAPBindingNamespace, 'binding')
+SOAPHeaderName = XSD::QName.new(SOAPBindingNamespace, 'header')
+SOAPBodyName = XSD::QName.new(SOAPBindingNamespace, 'body')
+SOAPFaultName = XSD::QName.new(SOAPBindingNamespace, 'fault')
+SOAPOperationName = XSD::QName.new(SOAPBindingNamespace, 'operation')
+
+BindingAttrName = XSD::QName.new(nil, 'binding')
+ElementAttrName = XSD::QName.new(nil, 'element')
+LocationAttrName = XSD::QName.new(nil, 'location')
+MessageAttrName = XSD::QName.new(nil, 'message')
+NameAttrName = XSD::QName.new(nil, 'name')
+NamespaceAttrName = XSD::QName.new(nil, 'namespace')
+ParameterOrderAttrName = XSD::QName.new(nil, 'parameterOrder')
+TargetNamespaceAttrName = XSD::QName.new(nil, 'targetNamespace')
+TypeAttrName = XSD::QName.new(nil, 'type')
+
+
+end
diff --git a/ruby_1_8_5/lib/wsdl/definitions.rb b/ruby_1_8_5/lib/wsdl/definitions.rb
new file mode 100644
index 0000000000..5235037cfe
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/definitions.rb
@@ -0,0 +1,250 @@
+# WSDL4R - WSDL definitions.
+# 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 'xsd/namedelements'
+
+
+module WSDL
+
+
+class Definitions < Info
+ attr_reader :name
+ attr_reader :targetnamespace
+ attr_reader :imports
+
+ attr_accessor :location
+ attr_reader :importedschema
+
+ def initialize
+ super
+ @name = nil
+ @targetnamespace = nil
+ @location = nil
+ @importedschema = {}
+
+ @types = nil
+ @imports = []
+ @messages = XSD::NamedElements.new
+ @porttypes = XSD::NamedElements.new
+ @bindings = XSD::NamedElements.new
+ @services = XSD::NamedElements.new
+
+ @anontypes = XSD::NamedElements.new
+ @root = self
+ end
+
+ def inspect
+ sprintf("#<%s:0x%x %s>", self.class.name, __id__, @name || '(unnamed)')
+ end
+
+ def targetnamespace=(targetnamespace)
+ @targetnamespace = targetnamespace
+ if @name
+ @name = XSD::QName.new(@targetnamespace, @name.name)
+ end
+ end
+
+ def collect_attributes
+ result = XSD::NamedElements.new
+ if @types
+ @types.schemas.each do |schema|
+ result.concat(schema.collect_attributes)
+ end
+ end
+ @imports.each do |import|
+ result.concat(import.content.collect_attributes)
+ end
+ result
+ end
+
+ def collect_elements
+ result = XSD::NamedElements.new
+ if @types
+ @types.schemas.each do |schema|
+ result.concat(schema.collect_elements)
+ end
+ end
+ @imports.each do |import|
+ result.concat(import.content.collect_elements)
+ end
+ result
+ end
+
+ def collect_complextypes
+ result = @anontypes.dup
+ if @types
+ @types.schemas.each do |schema|
+ result.concat(schema.collect_complextypes)
+ end
+ end
+ @imports.each do |import|
+ result.concat(import.content.collect_complextypes)
+ end
+ result
+ 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)
+ @anontypes << complextype
+ end
+
+ def messages
+ result = @messages.dup
+ @imports.each do |import|
+ result.concat(import.content.messages) if self.class === import.content
+ end
+ result
+ end
+
+ def porttypes
+ result = @porttypes.dup
+ @imports.each do |import|
+ result.concat(import.content.porttypes) if self.class === import.content
+ end
+ result
+ end
+
+ def bindings
+ result = @bindings.dup
+ @imports.each do |import|
+ result.concat(import.content.bindings) if self.class === import.content
+ end
+ result
+ end
+
+ def services
+ result = @services.dup
+ @imports.each do |import|
+ result.concat(import.content.services) if self.class === import.content
+ end
+ result
+ end
+
+ def message(name)
+ message = @messages[name]
+ return message if message
+ @imports.each do |import|
+ message = import.content.message(name) if self.class === import.content
+ return message if message
+ end
+ nil
+ end
+
+ def porttype(name)
+ porttype = @porttypes[name]
+ return porttype if porttype
+ @imports.each do |import|
+ porttype = import.content.porttype(name) if self.class === import.content
+ return porttype if porttype
+ end
+ nil
+ end
+
+ def binding(name)
+ binding = @bindings[name]
+ return binding if binding
+ @imports.each do |import|
+ binding = import.content.binding(name) if self.class === import.content
+ return binding if binding
+ end
+ nil
+ end
+
+ def service(name)
+ service = @services[name]
+ return service if service
+ @imports.each do |import|
+ service = import.content.service(name) if self.class === import.content
+ return service if service
+ end
+ nil
+ end
+
+ def porttype_binding(name)
+ binding = @bindings.find { |item| item.type == name }
+ return binding if binding
+ @imports.each do |import|
+ binding = import.content.porttype_binding(name) if self.class === import.content
+ return binding if binding
+ end
+ nil
+ end
+
+ def parse_element(element)
+ case element
+ when ImportName
+ o = Import.new
+ @imports << o
+ o
+ when TypesName
+ o = Types.new
+ @types = o
+ o
+ when MessageName
+ o = Message.new
+ @messages << o
+ o
+ when PortTypeName
+ o = PortType.new
+ @porttypes << o
+ o
+ when BindingName
+ o = Binding.new
+ @bindings << o
+ o
+ when ServiceName
+ o = Service.new
+ @services << o
+ o
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ when TargetNamespaceAttrName
+ self.targetnamespace = value.source
+ else
+ nil
+ end
+ end
+
+ def self.parse_element(element)
+ if element == DefinitionsName
+ Definitions.new
+ else
+ nil
+ end
+ end
+
+private
+
+end
+
+
+end
diff --git a/ruby_1_8_5/lib/wsdl/documentation.rb b/ruby_1_8_5/lib/wsdl/documentation.rb
new file mode 100644
index 0000000000..3a7fd7d23e
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/documentation.rb
@@ -0,0 +1,32 @@
+# WSDL4R - WSDL SOAP documentation element.
+# Copyright (C) 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'
+
+
+module WSDL
+
+
+class Documentation < Info
+ def initialize
+ super
+ end
+
+ def parse_element(element)
+ # Accepts any element.
+ self
+ end
+
+ def parse_attr(attr, value)
+ # Accepts any attribute.
+ true
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/lib/wsdl/import.rb b/ruby_1_8_5/lib/wsdl/import.rb
new file mode 100644
index 0000000000..faf60871a5
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/import.rb
@@ -0,0 +1,80 @@
+# WSDL4R - WSDL import definition.
+# 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/importer'
+
+
+module WSDL
+
+
+class Import < Info
+ attr_reader :namespace
+ attr_reader :location
+ attr_reader :content
+
+ def initialize
+ super
+ @namespace = nil
+ @location = nil
+ @content = nil
+ @web_client = nil
+ end
+
+ def parse_element(element)
+ case element
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NamespaceAttrName
+ @namespace = value.source
+ if @content
+ @content.targetnamespace = @namespace
+ end
+ @namespace
+ when LocationAttrName
+ @location = URI.parse(value.source)
+ if @location.relative? and !parent.location.nil? and
+ !parent.location.relative?
+ @location = parent.location + @location
+ end
+ if root.importedschema.key?(@location)
+ @content = root.importedschema[@location]
+ else
+ root.importedschema[@location] = nil # placeholder
+ @content = import(@location)
+ if @content.is_a?(Definitions)
+ @content.root = root
+ if @namespace
+ @content.targetnamespace = @namespace
+ end
+ end
+ root.importedschema[@location] = @content
+ end
+ @location
+ else
+ nil
+ end
+ end
+
+private
+
+ def import(location)
+ Importer.import(location, root)
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/lib/wsdl/importer.rb b/ruby_1_8_5/lib/wsdl/importer.rb
new file mode 100644
index 0000000000..481bd81b25
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/importer.rb
@@ -0,0 +1,38 @@
+# WSDL4R - WSDL importer library.
+# Copyright (C) 2003, 2005 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/xmlSchema/importer'
+require 'wsdl/parser'
+
+
+module WSDL
+
+
+class Importer < WSDL::XMLSchema::Importer
+ def self.import(location, originalroot = nil)
+ new.import(location, originalroot)
+ end
+
+private
+
+ def parse(content, location, originalroot)
+ opt = {
+ :location => location,
+ :originalroot => originalroot
+ }
+ begin
+ WSDL::Parser.new(opt).parse(content)
+ rescue WSDL::Parser::ParseError
+ super(content, location, originalroot)
+ end
+ end
+
+end
+
+
+end
diff --git a/ruby_1_8_5/lib/wsdl/info.rb b/ruby_1_8_5/lib/wsdl/info.rb
new file mode 100644
index 0000000000..ffd90390a4
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/info.rb
@@ -0,0 +1,39 @@
+# WSDL4R - WSDL information base.
+# 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.
+
+
+module WSDL
+
+
+class Info
+ attr_accessor :root
+ attr_accessor :parent
+ attr_accessor :id
+
+ def initialize
+ @root = nil
+ @parent = nil
+ @id = nil
+ end
+
+ def inspect
+ if self.respond_to?(:name)
+ sprintf("#<%s:0x%x %s>", self.class.name, __id__, self.name)
+ else
+ sprintf("#<%s:0x%x>", self.class.name, __id__)
+ end
+ end
+
+ def parse_element(element); end # abstract
+
+ def parse_attr(attr, value); end # abstract
+
+ def parse_epilogue; end # abstract
+end
+
+
+end
diff --git a/ruby_1_8_5/lib/wsdl/message.rb b/ruby_1_8_5/lib/wsdl/message.rb
new file mode 100644
index 0000000000..cecc602da3
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/message.rb
@@ -0,0 +1,54 @@
+# WSDL4R - WSDL message definition.
+# 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'
+
+
+module WSDL
+
+
+class Message < Info
+ attr_reader :name # required
+ attr_reader :parts
+
+ def initialize
+ super
+ @name = nil
+ @parts = []
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def parse_element(element)
+ case element
+ when PartName
+ o = Part.new
+ @parts << o
+ o
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = XSD::QName.new(parent.targetnamespace, value.source)
+ else
+ nil
+ end
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/lib/wsdl/operation.rb b/ruby_1_8_5/lib/wsdl/operation.rb
new file mode 100644
index 0000000000..fb7f4a80f4
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/operation.rb
@@ -0,0 +1,130 @@
+# WSDL4R - WSDL operation definition.
+# 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'
+
+
+module WSDL
+
+
+class Operation < Info
+ class NameInfo
+ attr_reader :op_name
+ attr_reader :optype_name
+ attr_reader :parts
+ def initialize(op_name, optype_name, parts)
+ @op_name = op_name
+ @optype_name = optype_name
+ @parts = parts
+ end
+ end
+
+ attr_reader :name # required
+ attr_reader :parameter_order # optional
+ attr_reader :input
+ attr_reader :output
+ attr_reader :fault
+ attr_reader :type # required
+
+ def initialize
+ super
+ @name = nil
+ @type = nil
+ @parameter_order = nil
+ @input = nil
+ @output = nil
+ @fault = []
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def input_info
+ typename = input.find_message.name
+ NameInfo.new(@name, typename, inputparts)
+ end
+
+ def output_info
+ typename = output.find_message.name
+ NameInfo.new(@name, typename, outputparts)
+ end
+
+ def inputparts
+ sort_parts(input.find_message.parts)
+ end
+
+ def inputname
+ XSD::QName.new(targetnamespace, input.name ? input.name.name : @name.name)
+ end
+
+ def outputparts
+ sort_parts(output.find_message.parts)
+ end
+
+ def outputname
+ XSD::QName.new(targetnamespace,
+ output.name ? output.name.name : @name.name + 'Response')
+ end
+
+ def parse_element(element)
+ case element
+ when InputName
+ o = Param.new
+ @input = o
+ o
+ when OutputName
+ o = Param.new
+ @output = o
+ o
+ when FaultName
+ o = Param.new
+ @fault << o
+ o
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ when TypeAttrName
+ @type = value
+ when ParameterOrderAttrName
+ @parameter_order = value.source.split(/\s+/)
+ else
+ nil
+ end
+ end
+
+private
+
+ def sort_parts(parts)
+ return parts.dup unless parameter_order
+ result = []
+ parameter_order.each do |orderitem|
+ if (ele = parts.find { |part| part.name == orderitem })
+ result << ele
+ end
+ end
+ if result.length == 0
+ return parts.dup
+ end
+ # result length can be shorter than parts's.
+ # return part must not be a part of the parameterOrder.
+ result
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/lib/wsdl/operationBinding.rb b/ruby_1_8_5/lib/wsdl/operationBinding.rb
new file mode 100644
index 0000000000..c2b8cd6591
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/operationBinding.rb
@@ -0,0 +1,108 @@
+# WSDL4R - WSDL bound operation definition.
+# 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'
+
+
+module WSDL
+
+
+class OperationBinding < Info
+ attr_reader :name # required
+ attr_reader :input
+ attr_reader :output
+ attr_reader :fault
+ attr_reader :soapoperation
+
+ def initialize
+ super
+ @name = nil
+ @input = nil
+ @output = nil
+ @fault = []
+ @soapoperation = nil
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def porttype
+ root.porttype(parent.type)
+ end
+
+ def find_operation
+ porttype.operations[@name] or raise RuntimeError.new("#{@name} not found")
+ end
+
+ def soapoperation_name
+ if @soapoperation
+ @soapoperation.input_info.op_name
+ else
+ find_operation.name
+ end
+ end
+
+ def soapoperation_style
+ style = nil
+ if @soapoperation
+ style = @soapoperation.operation_style
+ elsif parent.soapbinding
+ style = parent.soapbinding.style
+ else
+ raise TypeError.new("operation style definition not found")
+ end
+ style || :document
+ end
+
+ def soapaction
+ if @soapoperation
+ @soapoperation.soapaction
+ else
+ nil
+ end
+ end
+
+ def parse_element(element)
+ case element
+ when InputName
+ o = Param.new
+ @input = o
+ o
+ when OutputName
+ o = Param.new
+ @output = o
+ o
+ when FaultName
+ o = Param.new
+ @fault << o
+ o
+ when SOAPOperationName
+ o = WSDL::SOAP::Operation.new
+ @soapoperation = o
+ o
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ else
+ nil
+ end
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/lib/wsdl/param.rb b/ruby_1_8_5/lib/wsdl/param.rb
new file mode 100644
index 0000000000..b6836b7def
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/param.rb
@@ -0,0 +1,85 @@
+# WSDL4R - WSDL param definition.
+# 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'
+
+
+module WSDL
+
+
+class Param < Info
+ attr_reader :message # required
+ attr_reader :name # optional but required for fault.
+ attr_reader :soapbody
+ attr_reader :soapheader
+ attr_reader :soapfault
+
+ def initialize
+ super
+ @message = nil
+ @name = nil
+ @soapbody = nil
+ @soapheader = []
+ @soapfault = nil
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def find_message
+ root.message(@message) or raise RuntimeError.new("#{@message} not found")
+ end
+
+ def soapbody_use
+ if @soapbody
+ @soapbody.use || :literal
+ else
+ raise RuntimeError.new("soap:body not found")
+ end
+ end
+
+ def parse_element(element)
+ case element
+ when SOAPBodyName
+ o = WSDL::SOAP::Body.new
+ @soapbody = o
+ o
+ when SOAPHeaderName
+ o = WSDL::SOAP::Header.new
+ @soapheader << o
+ o
+ when SOAPFaultName
+ o = WSDL::SOAP::Fault.new
+ @soap_fault = o
+ o
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when MessageAttrName
+ if value.namespace.nil?
+ value = XSD::QName.new(targetnamespace, value.source)
+ end
+ @message = value
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ else
+ nil
+ end
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/lib/wsdl/parser.rb b/ruby_1_8_5/lib/wsdl/parser.rb
new file mode 100644
index 0000000000..f96e96ee2a
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/parser.rb
@@ -0,0 +1,163 @@
+# WSDL4R - WSDL XML Instance parser library.
+# Copyright (C) 2002, 2003, 2005 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/qname'
+require 'xsd/ns'
+require 'xsd/charset'
+require 'xsd/datatypes'
+require 'xsd/xmlparser'
+require 'wsdl/wsdl'
+require 'wsdl/data'
+require 'wsdl/xmlSchema/data'
+require 'wsdl/soap/data'
+
+
+module WSDL
+
+
+class Parser
+ include WSDL
+
+ class ParseError < Error; end
+ class FormatDecodeError < ParseError; end
+ class UnknownElementError < FormatDecodeError; end
+ class UnknownAttributeError < FormatDecodeError; end
+ class UnexpectedElementError < FormatDecodeError; end
+ class ElementConstraintError < FormatDecodeError; end
+ class AttributeConstraintError < FormatDecodeError; end
+
+private
+
+ class ParseFrame
+ attr_reader :ns
+ attr_reader :name
+ attr_accessor :node
+
+ private
+
+ def initialize(ns, name, node)
+ @ns = ns
+ @name = name
+ @node = node
+ end
+ end
+
+public
+
+ def initialize(opt = {})
+ @parser = XSD::XMLParser.create_parser(self, opt)
+ @parsestack = nil
+ @lastnode = nil
+ @ignored = {}
+ @location = opt[:location]
+ @originalroot = opt[:originalroot]
+ end
+
+ def parse(string_or_readable)
+ @parsestack = []
+ @lastnode = nil
+ @textbuf = ''
+ @parser.do_parse(string_or_readable)
+ @lastnode
+ end
+
+ def charset
+ @parser.charset
+ end
+
+ def start_element(name, attrs)
+ lastframe = @parsestack.last
+ ns = parent = nil
+ if lastframe
+ ns = lastframe.ns.clone_ns
+ parent = lastframe.node
+ else
+ ns = XSD::NS.new
+ parent = nil
+ end
+ attrs = XSD::XMLParser.filter_ns(ns, attrs)
+ node = decode_tag(ns, name, attrs, parent)
+ @parsestack << ParseFrame.new(ns, name, node)
+ end
+
+ def characters(text)
+ lastframe = @parsestack.last
+ if lastframe
+ # Need not to be cloned because character does not have attr.
+ ns = lastframe.ns
+ decode_text(ns, text)
+ else
+ p text if $DEBUG
+ end
+ end
+
+ def end_element(name)
+ lastframe = @parsestack.pop
+ unless name == lastframe.name
+ raise UnexpectedElementError.new("closing element name '#{name}' does not match with opening element '#{lastframe.name}'")
+ end
+ decode_tag_end(lastframe.ns, lastframe.node)
+ @lastnode = lastframe.node
+ end
+
+private
+
+ def decode_tag(ns, name, attrs, parent)
+ o = nil
+ elename = ns.parse(name)
+ if !parent
+ if elename == DefinitionsName
+ o = Definitions.parse_element(elename)
+ o.location = @location
+ else
+ raise UnknownElementError.new("unknown element: #{elename}")
+ end
+ o.root = @originalroot if @originalroot # o.root = o otherwise
+ else
+ if elename == XMLSchema::AnnotationName
+ # only the first annotation element is allowed for each xsd element.
+ o = XMLSchema::Annotation.new
+ else
+ o = parent.parse_element(elename)
+ end
+ unless o
+ unless @ignored.key?(elename)
+ warn("ignored element: #{elename}")
+ @ignored[elename] = elename
+ end
+ o = Documentation.new # which accepts any element.
+ end
+ # node could be a pseudo element. pseudo element has its own parent.
+ o.root = parent.root
+ o.parent = parent if o.parent.nil?
+ end
+ attrs.each do |key, value|
+ attr_ele = ns.parse(key, true)
+ value_ele = ns.parse(value, true)
+ value_ele.source = value # for recovery; value may not be a QName
+ unless o.parse_attr(attr_ele, value_ele)
+ unless @ignored.key?(attr_ele)
+ warn("ignored attr: #{attr_ele}")
+ @ignored[attr_ele] = attr_ele
+ end
+ end
+ end
+ o
+ end
+
+ def decode_tag_end(ns, node)
+ node.parse_epilogue
+ end
+
+ def decode_text(ns, text)
+ @textbuf << text
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/lib/wsdl/part.rb b/ruby_1_8_5/lib/wsdl/part.rb
new file mode 100644
index 0000000000..5dafd4ee73
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/part.rb
@@ -0,0 +1,52 @@
+# WSDL4R - WSDL part definition.
+# 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'
+
+
+module WSDL
+
+
+class Part < Info
+ attr_reader :name # required
+ attr_reader :element # optional
+ attr_reader :type # optional
+
+ def initialize
+ super
+ @name = nil
+ @element = nil
+ @type = nil
+ end
+
+ def parse_element(element)
+ case element
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = value.source
+ when ElementAttrName
+ @element = value
+ when TypeAttrName
+ @type = value
+ else
+ nil
+ end
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/lib/wsdl/port.rb b/ruby_1_8_5/lib/wsdl/port.rb
new file mode 100644
index 0000000000..883cc3232d
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/port.rb
@@ -0,0 +1,84 @@
+# WSDL4R - WSDL port definition.
+# 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'
+
+
+module WSDL
+
+
+class Port < Info
+ attr_reader :name # required
+ attr_reader :binding # required
+ attr_reader :soap_address
+
+ def initialize
+ super
+ @name = nil
+ @binding = nil
+ @soap_address = nil
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def porttype
+ root.porttype(find_binding.type)
+ end
+
+ def find_binding
+ root.binding(@binding) or raise RuntimeError.new("#{@binding} not found")
+ end
+
+ def inputoperation_map
+ result = {}
+ find_binding.operations.each do |op_bind|
+ op_info = op_bind.soapoperation.input_info
+ result[op_info.op_name] = op_info
+ end
+ result
+ end
+
+ def outputoperation_map
+ result = {}
+ find_binding.operations.each do |op_bind|
+ op_info = op_bind.soapoperation.output_info
+ result[op_info.op_name] = op_info
+ end
+ result
+ end
+
+ def parse_element(element)
+ case element
+ when SOAPAddressName
+ o = WSDL::SOAP::Address.new
+ @soap_address = o
+ o
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ when BindingAttrName
+ @binding = value
+ else
+ nil
+ end
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/lib/wsdl/portType.rb b/ruby_1_8_5/lib/wsdl/portType.rb
new file mode 100644
index 0000000000..03e37690a8
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/portType.rb
@@ -0,0 +1,73 @@
+# WSDL4R - WSDL portType definition.
+# 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 'xsd/namedelements'
+
+
+module WSDL
+
+
+class PortType < Info
+ attr_reader :name # required
+ attr_reader :operations
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def initialize
+ super
+ @name = nil
+ @operations = XSD::NamedElements.new
+ end
+
+ def find_binding
+ root.bindings.find { |item| item.type == @name } or
+ raise RuntimeError.new("#{@name} not found")
+ end
+
+ def locations
+ bind_name = find_binding.name
+ result = []
+ root.services.each do |service|
+ service.ports.each do |port|
+ if port.binding == bind_name
+ result << port.soap_address.location if port.soap_address
+ end
+ end
+ end
+ result
+ end
+
+ def parse_element(element)
+ case element
+ when OperationName
+ o = Operation.new
+ @operations << o
+ o
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ else
+ nil
+ end
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/lib/wsdl/service.rb b/ruby_1_8_5/lib/wsdl/service.rb
new file mode 100644
index 0000000000..652b127331
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/service.rb
@@ -0,0 +1,61 @@
+# WSDL4R - WSDL service definition.
+# 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 'xsd/namedelements'
+
+
+module WSDL
+
+
+class Service < Info
+ attr_reader :name # required
+ attr_reader :ports
+ attr_reader :soap_address
+
+ def initialize
+ super
+ @name = nil
+ @ports = XSD::NamedElements.new
+ @soap_address = nil
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def parse_element(element)
+ case element
+ when PortName
+ o = Port.new
+ @ports << o
+ o
+ when SOAPAddressName
+ o = WSDL::SOAP::Address.new
+ @soap_address = o
+ o
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ else
+ nil
+ end
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/lib/wsdl/soap/address.rb b/ruby_1_8_5/lib/wsdl/soap/address.rb
new file mode 100644
index 0000000000..0b2b59caf0
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/soap/address.rb
@@ -0,0 +1,40 @@
+# WSDL4R - WSDL SOAP address definition.
+# 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'
+
+
+module WSDL
+module SOAP
+
+
+class Address < Info
+ attr_reader :location
+
+ def initialize
+ super
+ @location = nil
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when LocationAttrName
+ @location = value.source
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/soap/binding.rb b/ruby_1_8_5/lib/wsdl/soap/binding.rb
new file mode 100644
index 0000000000..7e15a99701
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/soap/binding.rb
@@ -0,0 +1,49 @@
+# WSDL4R - WSDL SOAP binding definition.
+# 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'
+
+
+module WSDL
+module SOAP
+
+
+class Binding < Info
+ attr_reader :style
+ attr_reader :transport
+
+ def initialize
+ super
+ @style = nil
+ @transport = nil
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when StyleAttrName
+ if ["document", "rpc"].include?(value.source)
+ @style = value.source.intern
+ else
+ raise Parser::AttributeConstraintError.new(
+ "Unexpected value #{ value }.")
+ end
+ when TransportAttrName
+ @transport = value.source
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/soap/body.rb b/ruby_1_8_5/lib/wsdl/soap/body.rb
new file mode 100644
index 0000000000..824f8121a2
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/soap/body.rb
@@ -0,0 +1,56 @@
+# WSDL4R - WSDL SOAP body definition.
+# 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'
+
+
+module WSDL
+module SOAP
+
+
+class Body < Info
+ attr_reader :parts
+ attr_reader :use # required
+ attr_reader :encodingstyle
+ attr_reader :namespace
+
+ def initialize
+ super
+ @parts = nil
+ @use = nil
+ @encodingstyle = nil
+ @namespace = nil
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when PartsAttrName
+ @parts = value.source
+ when UseAttrName
+ if ['literal', 'encoded'].include?(value.source)
+ @use = value.source.intern
+ else
+ raise RuntimeError.new("unknown use of soap:body: #{value.source}")
+ end
+ when EncodingStyleAttrName
+ @encodingstyle = value.source
+ when NamespaceAttrName
+ @namespace = value.source
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/soap/cgiStubCreator.rb b/ruby_1_8_5/lib/wsdl/soap/cgiStubCreator.rb
new file mode 100644
index 0000000000..2c4dff2f62
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/soap/cgiStubCreator.rb
@@ -0,0 +1,76 @@
+# WSDL4R - Creating CGI stub code from WSDL.
+# Copyright (C) 2002, 2003, 2005 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)
+ warn("CGI stub can have only 1 port. Creating stub for the first port... Rests are ignored.")
+ 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 |definitions|
+ opt = definitions.last
+ if opt[:request_style] == :document
+ @router.add_document_operation(servant, *definitions)
+ else
+ @router.add_rpc_operation(servant, *definitions)
+ end
+ 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
diff --git a/ruby_1_8_5/lib/wsdl/soap/classDefCreator.rb b/ruby_1_8_5/lib/wsdl/soap/classDefCreator.rb
new file mode 100644
index 0000000000..aeb67c0613
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/soap/classDefCreator.rb
@@ -0,0 +1,314 @@
+# WSDL4R - Creating class definition from WSDL
+# Copyright (C) 2002, 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 'wsdl/data'
+require 'wsdl/soap/classDefCreatorSupport'
+require 'xsd/codegen'
+
+
+module WSDL
+module SOAP
+
+
+class ClassDefCreator
+ include ClassDefCreatorSupport
+
+ def initialize(definitions)
+ @elements = definitions.collect_elements
+ @simpletypes = definitions.collect_simpletypes
+ @complextypes = definitions.collect_complextypes
+ @faulttypes = nil
+ if definitions.respond_to?(:collect_faulttypes)
+ @faulttypes = definitions.collect_faulttypes
+ end
+ end
+
+ def dump(type = nil)
+ result = "require 'xsd/qname'\n"
+ if type
+ result = dump_classdef(type.name, type)
+ else
+ str = dump_element
+ unless str.empty?
+ result << "\n" unless result.empty?
+ result << str
+ end
+ str = dump_complextype
+ unless str.empty?
+ result << "\n" unless result.empty?
+ result << str
+ end
+ str = dump_simpletype
+ unless str.empty?
+ result << "\n" unless result.empty?
+ result << str
+ end
+ end
+ result
+ end
+
+private
+
+ def dump_element
+ @elements.collect { |ele|
+ if ele.local_complextype
+ dump_classdef(ele.name, ele.local_complextype,
+ ele.elementform == 'qualified')
+ elsif ele.local_simpletype
+ dump_simpletypedef(ele.name, ele.local_simpletype)
+ else
+ nil
+ end
+ }.compact.join("\n")
+ end
+
+ def dump_simpletype
+ @simpletypes.collect { |type|
+ dump_simpletypedef(type.name, type)
+ }.compact.join("\n")
+ end
+
+ def dump_complextype
+ @complextypes.collect { |type|
+ case type.compoundtype
+ when :TYPE_STRUCT, :TYPE_EMPTY
+ dump_classdef(type.name, type)
+ when :TYPE_ARRAY
+ dump_arraydef(type)
+ when :TYPE_SIMPLE
+ dump_simpleclassdef(type)
+ when :TYPE_MAP
+ # mapped as a general Hash
+ nil
+ else
+ raise RuntimeError.new(
+ "unknown kind of complexContent: #{type.compoundtype}")
+ end
+ }.compact.join("\n")
+ end
+
+ def dump_simpletypedef(qname, simpletype)
+ if !simpletype.restriction or simpletype.restriction.enumeration.empty?
+ return nil
+ end
+ c = XSD::CodeGen::ModuleDef.new(create_class_name(qname))
+ c.comment = "#{qname}"
+ const = {}
+ simpletype.restriction.enumeration.each do |value|
+ constname = safeconstname(value)
+ const[constname] ||= 0
+ if (const[constname] += 1) > 1
+ constname += "_#{const[constname]}"
+ end
+ c.def_const(constname, ndq(value))
+ end
+ c.dump
+ end
+
+ def dump_simpleclassdef(type_or_element)
+ qname = type_or_element.name
+ base = create_class_name(type_or_element.simplecontent.base)
+ c = XSD::CodeGen::ClassDef.new(create_class_name(qname), base)
+ c.comment = "#{qname}"
+ c.dump
+ end
+
+ def dump_classdef(qname, typedef, qualified = false)
+ if @faulttypes and @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}"
+ c.def_classvar('schema_type', ndq(qname.name))
+ c.def_classvar('schema_ns', ndq(qname.namespace))
+ c.def_classvar('schema_qualified', dq('true')) if qualified
+ schema_element = []
+ init_lines = ''
+ params = []
+ typedef.each_element do |element|
+ if element.type == XSD::AnyTypeName
+ type = nil
+ elsif klass = element_basetype(element)
+ type = klass.name
+ elsif element.type
+ type = create_class_name(element.type)
+ else
+ type = nil # means anyType.
+ # do we define a class for local complexType from it's name?
+ # type = create_class_name(element.name)
+ # <element>
+ # <complexType>
+ # <seq...>
+ # </complexType>
+ # </element>
+ end
+ name = name_element(element).name
+ attrname = safemethodname?(name) ? name : safemethodname(name)
+ varname = safevarname(name)
+ c.def_attr(attrname, true, varname)
+ init_lines << "@#{varname} = #{varname}\n"
+ if element.map_as_array?
+ params << "#{varname} = []"
+ type << '[]' if type
+ else
+ params << "#{varname} = nil"
+ end
+ # nil means @@schema_ns + varname
+ eleqname =
+ (varname == name && element.name.namespace == qname.namespace) ?
+ nil : element.name
+ schema_element << [varname, eleqname, type]
+ end
+ unless typedef.attributes.empty?
+ define_attribute(c, typedef.attributes)
+ init_lines << "@__xmlattr = {}\n"
+ end
+ c.def_classvar('schema_element',
+ '[' +
+ schema_element.collect { |varname, name, type|
+ '[' +
+ (
+ if name
+ varname.dump + ', [' + ndq(type) + ', ' + dqname(name) + ']'
+ else
+ varname.dump + ', ' + ndq(type)
+ end
+ ) +
+ ']'
+ }.join(', ') +
+ ']'
+ )
+ c.def_method('initialize', *params) do
+ init_lines
+ end
+ c.dump
+ end
+
+ def element_basetype(ele)
+ if klass = basetype_class(ele.type)
+ klass
+ elsif ele.local_simpletype
+ basetype_class(ele.local_simpletype.base)
+ else
+ nil
+ end
+ end
+
+ def attribute_basetype(attr)
+ if klass = basetype_class(attr.type)
+ klass
+ elsif attr.local_simpletype
+ basetype_class(attr.local_simpletype.base)
+ else
+ nil
+ end
+ end
+
+ def basetype_class(type)
+ return nil if type.nil?
+ if simpletype = @simpletypes[type]
+ basetype_mapped_class(simpletype.base)
+ else
+ basetype_mapped_class(type)
+ end
+ end
+
+ def define_attribute(c, attributes)
+ schema_attribute = []
+ attributes.each do |attribute|
+ name = name_attribute(attribute)
+ if klass = attribute_basetype(attribute)
+ type = klass.name
+ else
+ type = nil
+ end
+ methodname = safemethodname('xmlattr_' + name.name)
+ c.def_method(methodname) do <<-__EOD__
+ (@__xmlattr ||= {})[#{dqname(name)}]
+ __EOD__
+ end
+ c.def_method(methodname + '=', 'value') do <<-__EOD__
+ (@__xmlattr ||= {})[#{dqname(name)}] = value
+ __EOD__
+ end
+ schema_attribute << [name, type]
+ end
+ c.def_classvar('schema_attribute',
+ '{' +
+ schema_attribute.collect { |name, type|
+ dqname(name) + ' => ' + ndq(type)
+ }.join(', ') +
+ '}'
+ )
+ end
+
+ def name_element(element)
+ return element.name if element.name
+ return element.ref if element.ref
+ raise RuntimeError.new("cannot define name of #{element}")
+ end
+
+ def name_attribute(attribute)
+ return attribute.name if attribute.name
+ return attribute.ref if attribute.ref
+ raise RuntimeError.new("cannot define name of #{attribute}")
+ end
+
+ DEFAULT_ITEM_NAME = XSD::QName.new(nil, 'item')
+
+ def dump_arraydef(complextype)
+ qname = complextype.name
+ c = XSD::CodeGen::ClassDef.new(create_class_name(qname), '::Array')
+ c.comment = "#{qname}"
+ child_type = complextype.child_type
+ c.def_classvar('schema_type', ndq(child_type.name))
+ c.def_classvar('schema_ns', ndq(child_type.namespace))
+ child_element = complextype.find_aryelement
+ schema_element = []
+ if child_type == XSD::AnyTypeName
+ type = nil
+ elsif child_element and (klass = element_basetype(child_element))
+ type = klass.name
+ elsif child_type
+ type = create_class_name(child_type)
+ else
+ type = nil
+ end
+ if child_element
+ if child_element.map_as_array?
+ type << '[]' if type
+ end
+ child_element_name = child_element.name
+ else
+ child_element_name = DEFAULT_ITEM_NAME
+ end
+ schema_element << [child_element_name.name, child_element_name, type]
+ c.def_classvar('schema_element',
+ '[' +
+ schema_element.collect { |varname, name, type|
+ '[' +
+ (
+ if name
+ varname.dump + ', [' + ndq(type) + ', ' + dqname(name) + ']'
+ else
+ varname.dump + ', ' + ndq(type)
+ end
+ ) +
+ ']'
+ }.join(', ') +
+ ']'
+ )
+ c.dump
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/soap/classDefCreatorSupport.rb b/ruby_1_8_5/lib/wsdl/soap/classDefCreatorSupport.rb
new file mode 100644
index 0000000000..8f335653c8
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/soap/classDefCreatorSupport.rb
@@ -0,0 +1,126 @@
+# 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
+
+ def dq(ele)
+ ele.dump
+ end
+
+ def ndq(ele)
+ ele.nil? ? 'nil' : dq(ele)
+ end
+
+ def sym(ele)
+ ':' + ele
+ end
+
+ def dqname(qname)
+ qname.dump
+ end
+
+private
+
+ def dump_inout_type(param)
+ if param
+ message = param.find_message
+ params = ""
+ message.parts.each do |part|
+ name = safevarname(part.name)
+ if part.type
+ typename = safeconstname(part.type.name)
+ params << add_at("# #{name}", "#{typename} - #{part.type}\n", 20)
+ elsif part.element
+ typename = safeconstname(part.element.name)
+ params << add_at("# #{name}", "#{typename} - #{part.element}\n", 20)
+ end
+ 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
diff --git a/ruby_1_8_5/lib/wsdl/soap/clientSkeltonCreator.rb b/ruby_1_8_5/lib/wsdl/soap/clientSkeltonCreator.rb
new file mode 100644
index 0000000000..916f0d4dc0
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/soap/clientSkeltonCreator.rb
@@ -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)
+
+# run ruby with -d to see SOAP wiredumps.
+obj.wiredump_dev = STDERR if $DEBUG
+
+__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|
+ safevarname(part.name)
+ }.join(" = ")
+ if result.empty?
+ ""
+ else
+ result << " = nil"
+ end
+ result
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/soap/complexType.rb b/ruby_1_8_5/lib/wsdl/soap/complexType.rb
new file mode 100644
index 0000000000..b2e13d0564
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/soap/complexType.rb
@@ -0,0 +1,161 @@
+# WSDL4R - SOAP complexType definition for 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/xmlSchema/complexType'
+require 'soap/mapping'
+
+
+module WSDL
+module XMLSchema
+
+
+class ComplexType < Info
+ def compoundtype
+ @compoundtype ||= check_type
+ end
+
+ def check_type
+ if content
+ if attributes.empty? and
+ content.elements.size == 1 and content.elements[0].maxoccurs != '1'
+ if name == ::SOAP::Mapping::MapQName
+ :TYPE_MAP
+ else
+ :TYPE_ARRAY
+ end
+ else
+ :TYPE_STRUCT
+ end
+ elsif complexcontent
+ if complexcontent.base == ::SOAP::ValueArrayName
+ :TYPE_ARRAY
+ else
+ complexcontent.basetype.check_type
+ end
+ elsif simplecontent
+ :TYPE_SIMPLE
+ elsif !attributes.empty?
+ :TYPE_STRUCT
+ else # empty complexType definition (seen in partner.wsdl of salesforce)
+ :TYPE_EMPTY
+ end
+ end
+
+ def child_type(name = nil)
+ case compoundtype
+ when :TYPE_STRUCT
+ if ele = find_element(name)
+ ele.type
+ elsif ele = find_element_by_name(name.name)
+ ele.type
+ end
+ when :TYPE_ARRAY
+ @contenttype ||= content_arytype
+ when :TYPE_MAP
+ item_ele = find_element_by_name("item") or
+ raise RuntimeError.new("'item' element not found in Map definition.")
+ content = item_ele.local_complextype or
+ raise RuntimeError.new("No complexType definition for 'item'.")
+ if ele = content.find_element(name)
+ ele.type
+ elsif ele = content.find_element_by_name(name.name)
+ ele.type
+ end
+ else
+ raise NotImplementedError.new("Unknown kind of complexType.")
+ end
+ end
+
+ def child_defined_complextype(name)
+ ele = nil
+ case compoundtype
+ when :TYPE_STRUCT, :TYPE_MAP
+ unless ele = find_element(name)
+ if name.namespace.nil?
+ ele = find_element_by_name(name.name)
+ end
+ end
+ when :TYPE_ARRAY
+ if content.elements.size == 1
+ ele = content.elements[0]
+ else
+ raise RuntimeError.new("Assert: must not reach.")
+ end
+ else
+ raise RuntimeError.new("Assert: Not implemented.")
+ end
+ unless ele
+ raise RuntimeError.new("Cannot find #{name} as a children of #{@name}.")
+ end
+ ele.local_complextype
+ end
+
+ def find_arytype
+ unless compoundtype == :TYPE_ARRAY
+ raise RuntimeError.new("Assert: not for array")
+ end
+ if complexcontent
+ complexcontent.attributes.each do |attribute|
+ if attribute.ref == ::SOAP::AttrArrayTypeName
+ return attribute.arytype
+ end
+ end
+ if check_array_content(complexcontent.content)
+ return element_simpletype(complexcontent.content.elements[0])
+ end
+ elsif check_array_content(content)
+ return element_simpletype(content.elements[0])
+ end
+ raise RuntimeError.new("Assert: Unknown array definition.")
+ end
+
+ def find_aryelement
+ unless compoundtype == :TYPE_ARRAY
+ raise RuntimeError.new("Assert: not for array")
+ end
+ if complexcontent
+ if check_array_content(complexcontent.content)
+ return complexcontent.content.elements[0]
+ end
+ elsif check_array_content(content)
+ return content.elements[0]
+ end
+ nil # use default item name
+ end
+
+private
+
+ def element_simpletype(element)
+ if element.type
+ element.type
+ elsif element.local_simpletype
+ element.local_simpletype.base
+ else
+ nil
+ end
+ end
+
+ def check_array_content(content)
+ content and content.elements.size == 1 and
+ content.elements[0].maxoccurs != '1'
+ end
+
+ def content_arytype
+ if arytype = find_arytype
+ ns = arytype.namespace
+ name = arytype.name.sub(/\[(?:,)*\]$/, '')
+ XSD::QName.new(ns, name)
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/soap/data.rb b/ruby_1_8_5/lib/wsdl/soap/data.rb
new file mode 100644
index 0000000000..48512d3751
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/soap/data.rb
@@ -0,0 +1,42 @@
+# WSDL4R - WSDL SOAP binding data definitions.
+# 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 'xsd/qname'
+require 'wsdl/soap/definitions'
+require 'wsdl/soap/binding'
+require 'wsdl/soap/operation'
+require 'wsdl/soap/body'
+require 'wsdl/soap/element'
+require 'wsdl/soap/header'
+require 'wsdl/soap/headerfault'
+require 'wsdl/soap/fault'
+require 'wsdl/soap/address'
+require 'wsdl/soap/complexType'
+
+
+module WSDL
+module SOAP
+
+
+HeaderFaultName = XSD::QName.new(SOAPBindingNamespace, 'headerfault')
+
+LocationAttrName = XSD::QName.new(nil, 'location')
+StyleAttrName = XSD::QName.new(nil, 'style')
+TransportAttrName = XSD::QName.new(nil, 'transport')
+UseAttrName = XSD::QName.new(nil, 'use')
+PartsAttrName = XSD::QName.new(nil, 'parts')
+PartAttrName = XSD::QName.new(nil, 'part')
+NameAttrName = XSD::QName.new(nil, 'name')
+MessageAttrName = XSD::QName.new(nil, 'message')
+EncodingStyleAttrName = XSD::QName.new(nil, 'encodingStyle')
+NamespaceAttrName = XSD::QName.new(nil, 'namespace')
+SOAPActionAttrName = XSD::QName.new(nil, 'soapAction')
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/soap/definitions.rb b/ruby_1_8_5/lib/wsdl/soap/definitions.rb
new file mode 100644
index 0000000000..b014d5af6b
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/soap/definitions.rb
@@ -0,0 +1,149 @@
+# WSDL4R - WSDL additional definitions for SOAP.
+# Copyright (C) 2002-2005 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'
+require 'soap/mapping'
+
+
+module WSDL
+
+
+class Definitions < Info
+ def self.soap_rpc_complextypes
+ types = XSD::NamedElements.new
+ types << array_complextype
+ types << fault_complextype
+ types << exception_complextype
+ types
+ end
+
+ def self.array_complextype
+ type = XMLSchema::ComplexType.new(::SOAP::ValueArrayName)
+ type.complexcontent = XMLSchema::ComplexContent.new
+ type.complexcontent.base = ::SOAP::ValueArrayName
+ attr = XMLSchema::Attribute.new
+ attr.ref = ::SOAP::AttrArrayTypeName
+ anytype = XSD::AnyTypeName.dup
+ anytype.name += '[]'
+ attr.arytype = anytype
+ type.complexcontent.attributes << attr
+ type
+ end
+
+=begin
+<xs:complexType name="Fault" final="extension">
+ <xs:sequence>
+ <xs:element name="faultcode" type="xs:QName" />
+ <xs:element name="faultstring" type="xs:string" />
+ <xs:element name="faultactor" type="xs:anyURI" minOccurs="0" />
+ <xs:element name="detail" type="tns:detail" minOccurs="0" />
+ </xs:sequence>
+</xs:complexType>
+=end
+ def self.fault_complextype
+ type = XMLSchema::ComplexType.new(::SOAP::EleFaultName)
+ faultcode = XMLSchema::Element.new(::SOAP::EleFaultCodeName, XSD::XSDQName::Type)
+ faultstring = XMLSchema::Element.new(::SOAP::EleFaultStringName, XSD::XSDString::Type)
+ faultactor = XMLSchema::Element.new(::SOAP::EleFaultActorName, XSD::XSDAnyURI::Type)
+ faultactor.minoccurs = 0
+ detail = XMLSchema::Element.new(::SOAP::EleFaultDetailName, XSD::AnyTypeName)
+ detail.minoccurs = 0
+ type.all_elements = [faultcode, faultstring, faultactor, detail]
+ type.final = 'extension'
+ type
+ end
+
+ def self.exception_complextype
+ type = XMLSchema::ComplexType.new(XSD::QName.new(
+ ::SOAP::Mapping::RubyCustomTypeNamespace, 'SOAPException'))
+ 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)
+ type.all_elements = [excn_name, cause, backtrace, message]
+ type
+ end
+
+ def soap_rpc_complextypes(binding)
+ types = rpc_operation_complextypes(binding)
+ types + self.class.soap_rpc_complextypes
+ end
+
+ def collect_faulttypes
+ result = []
+ collect_fault_messages.each do |name|
+ faultparts = message(name).parts
+ if faultparts.size != 1
+ raise RuntimeError.new("expecting fault message to have only 1 part")
+ end
+ if result.index(faultparts[0].type).nil?
+ result << faultparts[0].type
+ end
+ end
+ result
+ end
+
+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)
+ types = XSD::NamedElements.new
+ binding.operations.each do |op_bind|
+ if op_bind_rpc?(op_bind)
+ operation = op_bind.find_operation
+ if op_bind.input
+ type = XMLSchema::ComplexType.new(op_bind.soapoperation_name)
+ message = messages[operation.input.message]
+ type.sequence_elements = elements_from_message(message)
+ types << type
+ end
+ if op_bind.output
+ type = XMLSchema::ComplexType.new(operation.outputname)
+ message = messages[operation.output.message]
+ type.sequence_elements = elements_from_message(message)
+ types << type
+ end
+ end
+ end
+ types
+ end
+
+ def op_bind_rpc?(op_bind)
+ op_bind.soapoperation_style == :rpc
+ end
+
+ def elements_from_message(message)
+ message.parts.collect { |part|
+ if part.element
+ collect_elements[part.element]
+ elsif part.name.nil? or part.type.nil?
+ raise RuntimeError.new("part of a message must be an element or typed")
+ else
+ qname = XSD::QName.new(nil, part.name)
+ XMLSchema::Element.new(qname, part.type)
+ end
+ }
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/lib/wsdl/soap/driverCreator.rb b/ruby_1_8_5/lib/wsdl/soap/driverCreator.rb
new file mode 100644
index 0000000000..eba7c158a2
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/soap/driverCreator.rb
@@ -0,0 +1,95 @@
+# WSDL4R - Creating driver code from WSDL.
+# Copyright (C) 2002, 2003, 2005 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 }
+ return '' unless binding.soapbinding # not a SOAP binding
+ address = @definitions.porttype(name).locations[0]
+
+ 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", ndq(address))
+ 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 |definitions|
+ opt = definitions.last
+ if opt[:request_style] == :document
+ add_document_operation(*definitions)
+ else
+ add_rpc_operation(*definitions)
+ qname = definitions[0]
+ name = definitions[2]
+ if qname.name != name and qname.name.capitalize == name.capitalize
+ ::SOAP::Mapping.define_singleton_method(self, qname.name) do |*arg|
+ __send__(name, *arg)
+ end
+ end
+ end
+ end
+ EOD
+ end
+ c.dump
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/soap/element.rb b/ruby_1_8_5/lib/wsdl/soap/element.rb
new file mode 100644
index 0000000000..0fa6017c5b
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/soap/element.rb
@@ -0,0 +1,28 @@
+# WSDL4R - XMLSchema element 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/xmlSchema/element'
+
+
+module WSDL
+module XMLSchema
+
+
+class Element < Info
+ def map_as_array?
+ maxoccurs != '1'
+ end
+
+ def attributes
+ @local_complextype.attributes
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/soap/fault.rb b/ruby_1_8_5/lib/wsdl/soap/fault.rb
new file mode 100644
index 0000000000..2862b659ab
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/soap/fault.rb
@@ -0,0 +1,56 @@
+# WSDL4R - WSDL SOAP body definition.
+# 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'
+
+
+module WSDL
+module SOAP
+
+
+class Fault < Info
+ attr_reader :name # required
+ attr_reader :use # required
+ attr_reader :encodingstyle
+ attr_reader :namespace
+
+ def initialize
+ super
+ @name = nil
+ @use = nil
+ @encodingstyle = nil
+ @namespace = nil
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ when UseAttrName
+ @use = value.source
+ when EncodingStyleAttrName
+ @encodingstyle = value.source
+ when NamespaceAttrName
+ @namespace = value.source
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/soap/header.rb b/ruby_1_8_5/lib/wsdl/soap/header.rb
new file mode 100644
index 0000000000..8d7c4e9d70
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/soap/header.rb
@@ -0,0 +1,86 @@
+# WSDL4R - WSDL SOAP body definition.
+# 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'
+
+
+module WSDL
+module SOAP
+
+
+class Header < Info
+ attr_reader :headerfault
+
+ attr_reader :message # required
+ attr_reader :part # required
+ attr_reader :use # required
+ attr_reader :encodingstyle
+ attr_reader :namespace
+
+ def initialize
+ super
+ @message = nil
+ @part = nil
+ @use = nil
+ @encodingstyle = nil
+ @namespace = nil
+ @headerfault = nil
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def find_message
+ root.message(@message) or raise RuntimeError.new("#{@message} not found")
+ end
+
+ def find_part
+ find_message.parts.each do |part|
+ if part.name == @part
+ return part
+ end
+ end
+ raise RuntimeError.new("#{@part} not found")
+ end
+
+ def parse_element(element)
+ case element
+ when HeaderFaultName
+ o = WSDL::SOAP::HeaderFault.new
+ @headerfault = o
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when MessageAttrName
+ if value.namespace.nil?
+ value = XSD::QName.new(targetnamespace, value.source)
+ end
+ @message = value
+ when PartAttrName
+ @part = value.source
+ when UseAttrName
+ @use = value.source
+ when EncodingStyleAttrName
+ @encodingstyle = value.source
+ when NamespaceAttrName
+ @namespace = value.source
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/soap/headerfault.rb b/ruby_1_8_5/lib/wsdl/soap/headerfault.rb
new file mode 100644
index 0000000000..d6b14f2646
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/soap/headerfault.rb
@@ -0,0 +1,56 @@
+# WSDL4R - WSDL SOAP body definition.
+# 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'
+
+
+module WSDL
+module SOAP
+
+
+class HeaderFault < Info
+ attr_reader :message # required
+ attr_reader :part # required
+ attr_reader :use # required
+ attr_reader :encodingstyle
+ attr_reader :namespace
+
+ def initialize
+ super
+ @message = nil
+ @part = nil
+ @use = nil
+ @encodingstyle = nil
+ @namespace = nil
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when MessageAttrName
+ @message = value
+ when PartAttrName
+ @part = value.source
+ when UseAttrName
+ @use = value.source
+ when EncodingStyleAttrName
+ @encodingstyle = value.source
+ when NamespaceAttrName
+ @namespace = value.source
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/soap/mappingRegistryCreator.rb b/ruby_1_8_5/lib/wsdl/soap/mappingRegistryCreator.rb
new file mode 100644
index 0000000000..8669339ce4
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/soap/mappingRegistryCreator.rb
@@ -0,0 +1,92 @@
+# WSDL4R - Creating MappingRegistry code from WSDL.
+# Copyright (C) 2002, 2003, 2005 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)
+ when :TYPE_MAP, :TYPE_EMPTY
+ nil
+ 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 => #{dqname(ele)} }
+)
+__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 => #{dqname(type)} }
+)
+__EOD__
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/soap/methodDefCreator.rb b/ruby_1_8_5/lib/wsdl/soap/methodDefCreator.rb
new file mode 100644
index 0000000000..f3ffadbe69
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/soap/methodDefCreator.rb
@@ -0,0 +1,228 @@
+# WSDL4R - Creating driver code from WSDL.
+# Copyright (C) 2002, 2003, 2005 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 'soap/rpc/element'
+
+
+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 = []
+ end
+
+ def dump(porttype)
+ @types.clear
+ result = ""
+ operations = @definitions.porttype(porttype).operations
+ binding = @definitions.porttype_binding(porttype)
+ operations.each do |operation|
+ op_bind = binding.operations[operation.name]
+ next unless op_bind # no binding is defined
+ next unless op_bind.soapoperation # not a SOAP operation binding
+ result << ",\n" unless result.empty?
+ result << dump_method(operation, op_bind).chomp
+ end
+ return result, @types
+ end
+
+ def collect_rpcparameter(operation)
+ result = operation.inputparts.collect { |part|
+ collect_type(part.type)
+ param_set(::SOAP::RPC::SOAPMethod::IN, part.name, rpcdefinedtype(part))
+ }
+ outparts = operation.outputparts
+ if outparts.size > 0
+ retval = outparts[0]
+ collect_type(retval.type)
+ result << param_set(::SOAP::RPC::SOAPMethod::RETVAL, retval.name,
+ rpcdefinedtype(retval))
+ cdr(outparts).each { |part|
+ collect_type(part.type)
+ result << param_set(::SOAP::RPC::SOAPMethod::OUT, part.name,
+ rpcdefinedtype(part))
+ }
+ end
+ result
+ end
+
+ def collect_documentparameter(operation)
+ param = []
+ operation.inputparts.each do |input|
+ param << param_set(::SOAP::RPC::SOAPMethod::IN, input.name,
+ documentdefinedtype(input), elementqualified(input))
+ end
+ operation.outputparts.each do |output|
+ param << param_set(::SOAP::RPC::SOAPMethod::OUT, output.name,
+ documentdefinedtype(output), elementqualified(output))
+ end
+ param
+ end
+
+private
+
+ def dump_method(operation, binding)
+ name = safemethodname(operation.name.name)
+ name_as = operation.name.name
+ style = binding.soapoperation_style
+ inputuse = binding.input.soapbody_use
+ outputuse = binding.output.soapbody_use
+ namespace = binding.input.soapbody.namespace
+ if style == :rpc
+ qname = XSD::QName.new(namespace, name_as)
+ paramstr = param2str(collect_rpcparameter(operation))
+ else
+ qname = nil
+ paramstr = param2str(collect_documentparameter(operation))
+ end
+ if paramstr.empty?
+ paramstr = '[]'
+ else
+ paramstr = "[ " << paramstr.split(/\r?\n/).join("\n ") << " ]"
+ end
+ definitions = <<__EOD__
+#{ndq(binding.soapaction)},
+ #{dq(name)},
+ #{paramstr},
+ { :request_style => #{sym(style.id2name)}, :request_use => #{sym(inputuse.id2name)},
+ :response_style => #{sym(style.id2name)}, :response_use => #{sym(outputuse.id2name)} }
+__EOD__
+ if style == :rpc
+ return <<__EOD__
+[ #{qname.dump},
+ #{definitions}]
+__EOD__
+ else
+ return <<__EOD__
+[ #{definitions}]
+__EOD__
+ end
+ end
+
+ def rpcdefinedtype(part)
+ if mapped = basetype_mapped_class(part.type)
+ ['::' + mapped.name]
+ elsif definedtype = @simpletypes[part.type]
+ ['::' + basetype_mapped_class(definedtype.base).name]
+ elsif definedtype = @elements[part.element]
+ #['::SOAP::SOAPStruct', part.element.namespace, part.element.name]
+ ['nil', part.element.namespace, part.element.name]
+ elsif definedtype = @complextypes[part.type]
+ case definedtype.compoundtype
+ when :TYPE_STRUCT, :TYPE_EMPTY # ToDo: empty should be treated as void.
+ type = create_class_name(part.type)
+ [type, part.type.namespace, part.type.name]
+ when :TYPE_MAP
+ [Hash.name, part.type.namespace, part.type.name]
+ when :TYPE_ARRAY
+ arytype = definedtype.find_arytype || XSD::AnyTypeName
+ ns = arytype.namespace
+ name = arytype.name.sub(/\[(?:,)*\]$/, '')
+ type = create_class_name(XSD::QName.new(ns, name))
+ [type + '[]', ns, name]
+ else
+ raise NotImplementedError.new("must not reach here")
+ end
+ else
+ raise RuntimeError.new("part: #{part.name} cannot be resolved")
+ end
+ end
+
+ def documentdefinedtype(part)
+ if mapped = basetype_mapped_class(part.type)
+ ['::' + mapped.name, nil, part.name]
+ elsif definedtype = @simpletypes[part.type]
+ ['::' + basetype_mapped_class(definedtype.base).name, nil, part.name]
+ elsif definedtype = @elements[part.element]
+ ['::SOAP::SOAPElement', part.element.namespace, part.element.name]
+ elsif definedtype = @complextypes[part.type]
+ ['::SOAP::SOAPElement', part.type.namespace, part.type.name]
+ else
+ raise RuntimeError.new("part: #{part.name} cannot be resolved")
+ end
+ end
+
+ def elementqualified(part)
+ if mapped = basetype_mapped_class(part.type)
+ false
+ elsif definedtype = @simpletypes[part.type]
+ false
+ elsif definedtype = @elements[part.element]
+ definedtype.elementform == 'qualified'
+ elsif definedtype = @complextypes[part.type]
+ false
+ else
+ raise RuntimeError.new("part: #{part.name} cannot be resolved")
+ end
+ end
+
+ def param_set(io_type, name, type, ele = nil)
+ [io_type, name, type, ele]
+ end
+
+ def collect_type(type)
+ # ignore inline type definition.
+ return if type.nil?
+ return if @types.include?(type)
+ @types << type
+ return unless @complextypes[type]
+ @complextypes[type].each_element do |element|
+ collect_type(element.type)
+ end
+ end
+
+ def param2str(params)
+ params.collect { |param|
+ io, name, type, ele = param
+ unless ele.nil?
+ "[#{dq(io)}, #{dq(name)}, #{type2str(type)}, #{ele2str(ele)}]"
+ else
+ "[#{dq(io)}, #{dq(name)}, #{type2str(type)}]"
+ end
+ }.join(",\n")
+ end
+
+ def type2str(type)
+ if type.size == 1
+ "[#{dq(type[0])}]"
+ else
+ "[#{dq(type[0])}, #{ndq(type[1])}, #{dq(type[2])}]"
+ end
+ end
+
+ def ele2str(ele)
+ qualified = ele
+ if qualified
+ "true"
+ else
+ "false"
+ end
+ end
+
+ def cdr(ary)
+ result = ary.dup
+ result.shift
+ result
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/soap/operation.rb b/ruby_1_8_5/lib/wsdl/soap/operation.rb
new file mode 100644
index 0000000000..502d34a07d
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/soap/operation.rb
@@ -0,0 +1,122 @@
+# WSDL4R - WSDL SOAP operation definition.
+# 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'
+
+
+module WSDL
+module SOAP
+
+
+class Operation < Info
+ class OperationInfo
+ attr_reader :style
+ attr_reader :op_name
+ attr_reader :optype_name
+ attr_reader :headerparts
+ attr_reader :bodyparts
+ attr_reader :faultpart
+ attr_reader :soapaction
+
+ def initialize(style, op_name, optype_name, headerparts, bodyparts, faultpart, soapaction)
+ @style = style
+ @op_name = op_name
+ @optype_name = optype_name
+ @headerparts = headerparts
+ @bodyparts = bodyparts
+ @faultpart = faultpart
+ @soapaction = soapaction
+ end
+ end
+
+ attr_reader :soapaction
+ attr_reader :style
+
+ def initialize
+ super
+ @soapaction = nil
+ @style = nil
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when StyleAttrName
+ if ["document", "rpc"].include?(value.source)
+ @style = value.source.intern
+ else
+ raise Parser::AttributeConstraintError.new(
+ "Unexpected value #{ value }.")
+ end
+ when SOAPActionAttrName
+ @soapaction = value.source
+ else
+ nil
+ end
+ end
+
+ def input_info
+ name_info = parent.find_operation.input_info
+ param_info(name_info, parent.input)
+ end
+
+ def output_info
+ name_info = parent.find_operation.output_info
+ param_info(name_info, parent.output)
+ end
+
+ def operation_style
+ return @style if @style
+ if parent_binding.soapbinding
+ return parent_binding.soapbinding.style
+ end
+ nil
+ end
+
+private
+
+ def parent_binding
+ parent.parent
+ end
+
+ def param_info(name_info, param)
+ op_name = name_info.op_name
+ optype_name = name_info.optype_name
+
+ soapheader = param.soapheader
+ headerparts = soapheader.collect { |item| item.find_part }
+
+ soapbody = param.soapbody
+ if soapbody.encodingstyle and
+ soapbody.encodingstyle != ::SOAP::EncodingNamespace
+ raise NotImplementedError.new(
+ "EncodingStyle '#{ soapbody.encodingstyle }' not supported.")
+ end
+ if soapbody.namespace
+ op_name = XSD::QName.new(soapbody.namespace, op_name.name)
+ end
+ if soapbody.parts
+ target = soapbody.parts.split(/\s+/)
+ bodyparts = name_info.parts.find_all { |part|
+ target.include?(part.name)
+ }
+ else
+ bodyparts = name_info.parts
+ end
+
+ faultpart = nil
+ OperationInfo.new(operation_style, op_name, optype_name, headerparts, bodyparts, faultpart, parent.soapaction)
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/soap/servantSkeltonCreator.rb b/ruby_1_8_5/lib/wsdl/soap/servantSkeltonCreator.rb
new file mode 100644
index 0000000000..88294ffed8
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/soap/servantSkeltonCreator.rb
@@ -0,0 +1,67 @@
+# WSDL4R - Creating servant skelton code from WSDL.
+# Copyright (C) 2002, 2003, 2005 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 = safemethodname(operation.name.name)
+ input = operation.input
+ params = input.find_message.parts.collect { |part|
+ safevarname(part.name)
+ }
+ m = XSD::CodeGen::MethodDef.new(name, params) do <<-EOD
+ p [#{params.join(", ")}]
+ raise NotImplementedError.new
+ EOD
+ end
+ m.comment = dump_method_signature(operation)
+ c.add_method(m)
+ end
+ c.dump
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/soap/standaloneServerStubCreator.rb b/ruby_1_8_5/lib/wsdl/soap/standaloneServerStubCreator.rb
new file mode 100644
index 0000000000..0b751b5153
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/soap/standaloneServerStubCreator.rb
@@ -0,0 +1,85 @@
+# WSDL4R - Creating standalone server stub code from WSDL.
+# Copyright (C) 2002, 2003, 2005 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)
+ warn("- Standalone stub can have only 1 port for now. So creating stub for the first port and rests are ignored.")
+ warn("- 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 manually.")
+ 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 |definitions|
+ opt = definitions.last
+ if opt[:request_style] == :document
+ @router.add_document_operation(servant, *definitions)
+ else
+ @router.add_rpc_operation(servant, *definitions)
+ end
+ end
+ self.mapping_registry = #{class_name}::MappingRegistry
+ EOD
+ end
+ c1.dump + "\n" + c2.dump + format(<<-EOD)
+
+ if $0 == __FILE__
+ # Change listen port.
+ server = #{class_name}App.new('app', nil, '0.0.0.0', 10080)
+ trap(:INT) do
+ server.shutdown
+ end
+ server.start
+ end
+ EOD
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/soap/wsdl2ruby.rb b/ruby_1_8_5/lib/wsdl/soap/wsdl2ruby.rb
new file mode 100644
index 0000000000..16b05fb032
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/soap/wsdl2ruby.rb
@@ -0,0 +1,176 @@
+# WSDL4R - WSDL to ruby mapping library.
+# Copyright (C) 2002-2005 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 'xsd/qname'
+require 'wsdl/importer'
+require 'wsdl/soap/classDefCreator'
+require 'wsdl/soap/servantSkeltonCreator'
+require 'wsdl/soap/driverCreator'
+require 'wsdl/soap/clientSkeltonCreator'
+require 'wsdl/soap/standaloneServerStubCreator'
+require 'wsdl/soap/cgiStubCreator'
+
+
+module WSDL
+module SOAP
+
+
+class WSDL2Ruby
+ attr_accessor :location
+ attr_reader :opt
+ attr_accessor :logger
+ attr_accessor :basedir
+
+ def run
+ unless @location
+ raise RuntimeError, "WSDL location not given"
+ end
+ @wsdl = import(@location)
+ @name = @wsdl.name ? @wsdl.name.name : 'default'
+ create_file
+ end
+
+private
+
+ def initialize
+ @location = nil
+ @opt = {}
+ @logger = Logger.new(STDERR)
+ @basedir = nil
+ @wsdl = nil
+ @name = nil
+ end
+
+ def create_file
+ create_classdef if @opt.key?('classdef')
+ create_servant_skelton(@opt['servant_skelton']) if @opt.key?('servant_skelton')
+ create_cgi_stub(@opt['cgi_stub']) if @opt.key?('cgi_stub')
+ create_standalone_server_stub(@opt['standalone_server_stub']) if @opt.key?('standalone_server_stub')
+ create_driver(@opt['driver']) if @opt.key?('driver')
+ create_client_skelton(@opt['client_skelton']) if @opt.key?('client_skelton')
+ end
+
+ def create_classdef
+ @logger.info { "Creating class definition." }
+ @classdef_filename = @name + '.rb'
+ check_file(@classdef_filename) or return
+ write_file(@classdef_filename) do |f|
+ f << WSDL::SOAP::ClassDefCreator.new(@wsdl).dump
+ end
+ end
+
+ def create_client_skelton(servicename)
+ @logger.info { "Creating client skelton." }
+ servicename ||= @wsdl.services[0].name.name
+ @client_skelton_filename = servicename + 'Client.rb'
+ check_file(@client_skelton_filename) or return
+ write_file(@client_skelton_filename) do |f|
+ f << shbang << "\n"
+ f << "require '#{@driver_filename}'\n\n" if @driver_filename
+ f << WSDL::SOAP::ClientSkeltonCreator.new(@wsdl).dump(
+ create_name(servicename))
+ end
+ end
+
+ def create_servant_skelton(porttypename)
+ @logger.info { "Creating servant skelton." }
+ @servant_skelton_filename = (porttypename || @name + 'Servant') + '.rb'
+ check_file(@servant_skelton_filename) or return
+ write_file(@servant_skelton_filename) do |f|
+ f << "require '#{@classdef_filename}'\n\n" if @classdef_filename
+ f << WSDL::SOAP::ServantSkeltonCreator.new(@wsdl).dump(
+ create_name(porttypename))
+ end
+ end
+
+ def create_cgi_stub(servicename)
+ @logger.info { "Creating CGI stub." }
+ servicename ||= @wsdl.services[0].name.name
+ @cgi_stubFilename = servicename + '.cgi'
+ check_file(@cgi_stubFilename) or return
+ write_file(@cgi_stubFilename) do |f|
+ f << shbang << "\n"
+ if @servant_skelton_filename
+ f << "require '#{@servant_skelton_filename}'\n\n"
+ end
+ f << WSDL::SOAP::CGIStubCreator.new(@wsdl).dump(create_name(servicename))
+ end
+ end
+
+ def create_standalone_server_stub(servicename)
+ @logger.info { "Creating standalone stub." }
+ servicename ||= @wsdl.services[0].name.name
+ @standalone_server_stub_filename = servicename + '.rb'
+ check_file(@standalone_server_stub_filename) or return
+ write_file(@standalone_server_stub_filename) do |f|
+ f << shbang << "\n"
+ f << "require '#{@servant_skelton_filename}'\n\n" if @servant_skelton_filename
+ f << WSDL::SOAP::StandaloneServerStubCreator.new(@wsdl).dump(
+ create_name(servicename))
+ end
+ end
+
+ def create_driver(porttypename)
+ @logger.info { "Creating driver." }
+ @driver_filename = (porttypename || @name) + 'Driver.rb'
+ check_file(@driver_filename) or return
+ write_file(@driver_filename) do |f|
+ f << "require '#{@classdef_filename}'\n\n" if @classdef_filename
+ f << WSDL::SOAP::DriverCreator.new(@wsdl).dump(
+ create_name(porttypename))
+ end
+ end
+
+ def write_file(filename)
+ if @basedir
+ filename = File.join(basedir, filename)
+ end
+ File.open(filename, "w") do |f|
+ yield f
+ end
+ end
+
+ def check_file(filename)
+ if @basedir
+ filename = File.join(basedir, filename)
+ end
+ if FileTest.exist?(filename)
+ if @opt.key?('force')
+ @logger.warn {
+ "File '#{filename}' exists but overrides it."
+ }
+ true
+ else
+ @logger.warn {
+ "File '#{filename}' exists. #{$0} did not override it."
+ }
+ false
+ end
+ else
+ @logger.info { "Creates file '#{filename}'." }
+ true
+ end
+ end
+
+ def shbang
+ "#!/usr/bin/env ruby"
+ end
+
+ def create_name(name)
+ name ? XSD::QName.new(@wsdl.targetnamespace, name) : nil
+ end
+
+ def import(location)
+ WSDL::Importer.import(location)
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/types.rb b/ruby_1_8_5/lib/wsdl/types.rb
new file mode 100644
index 0000000000..96ae5a4988
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/types.rb
@@ -0,0 +1,43 @@
+# WSDL4R - WSDL types definition.
+# 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'
+
+
+module WSDL
+
+
+class Types < Info
+ attr_reader :schemas
+
+ def initialize
+ super
+ @schemas = []
+ end
+
+ def parse_element(element)
+ case element
+ when SchemaName
+ o = XMLSchema::Schema.new
+ @schemas << o
+ o
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ nil
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/lib/wsdl/wsdl.rb b/ruby_1_8_5/lib/wsdl/wsdl.rb
new file mode 100644
index 0000000000..eb13c18806
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/wsdl.rb
@@ -0,0 +1,23 @@
+# WSDL4R - Base definitions.
+# Copyright (C) 2000, 2001, 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 'xsd/qname'
+
+
+module WSDL
+
+
+Version = '0.0.2'
+
+Namespace = 'http://schemas.xmlsoap.org/wsdl/'
+SOAPBindingNamespace ='http://schemas.xmlsoap.org/wsdl/soap/'
+
+class Error < StandardError; end
+
+
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/all.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/all.rb
new file mode 100644
index 0000000000..bb9566feac
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/all.rb
@@ -0,0 +1,69 @@
+# WSDL4R - XMLSchema complexType definition for 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'
+
+
+module WSDL
+module XMLSchema
+
+
+class All < Info
+ attr_reader :minoccurs
+ attr_reader :maxoccurs
+ attr_reader :elements
+
+ def initialize
+ super()
+ @minoccurs = '1'
+ @maxoccurs = '1'
+ @elements = []
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def elementformdefault
+ parent.elementformdefault
+ end
+
+ def <<(element)
+ @elements << element
+ end
+
+ def parse_element(element)
+ case element
+ when AnyName
+ o = Any.new
+ @elements << o
+ o
+ when ElementName
+ o = Element.new
+ @elements << o
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when MaxOccursAttrName
+ @maxoccurs = value.source
+ when MinOccursAttrName
+ @minoccurs = value.source
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/annotation.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/annotation.rb
new file mode 100644
index 0000000000..633bd196f1
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/annotation.rb
@@ -0,0 +1,34 @@
+# WSDL4R - WSDL SOAP documentation element.
+# Copyright (C) 2003, 2005 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 Annotation < Info
+ def initialize
+ super
+ end
+
+ def parse_element(element)
+ # Accepts any element.
+ self
+ end
+
+ def parse_attr(attr, value)
+ # Accepts any attribute.
+ true
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/any.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/any.rb
new file mode 100644
index 0000000000..72d25e8dde
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/any.rb
@@ -0,0 +1,56 @@
+# WSDL4R - XMLSchema any definition for WSDL.
+# Copyright (C) 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'
+
+
+module WSDL
+module XMLSchema
+
+
+class Any < Info
+ attr_accessor :maxoccurs
+ attr_accessor :minoccurs
+ attr_accessor :namespace
+ attr_accessor :process_contents
+
+ def initialize
+ super()
+ @maxoccurs = '1'
+ @minoccurs = '1'
+ @namespace = '##any'
+ @process_contents = 'strict'
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when MaxOccursAttrName
+ @maxoccurs = value.source
+ when MinOccursAttrName
+ @minoccurs = value.source
+ when NamespaceAttrName
+ @namespace = value.source
+ when ProcessContentsAttrName
+ @process_contents = value.source
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/attribute.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/attribute.rb
new file mode 100644
index 0000000000..f9048661a2
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/attribute.rb
@@ -0,0 +1,127 @@
+# WSDL4R - XMLSchema attribute definition for WSDL.
+# Copyright (C) 2002, 2003, 2005 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 Attribute < Info
+ class << self
+ if RUBY_VERSION > "1.7.0"
+ def attr_reader_ref(symbol)
+ name = symbol.to_s
+ define_method(name) {
+ instance_variable_get("@#{name}") ||
+ (refelement ? refelement.__send__(name) : nil)
+ }
+ end
+ else
+ def attr_reader_ref(symbol)
+ name = symbol.to_s
+ module_eval <<-EOS
+ def #{name}
+ @#{name} || (refelement ? refelement.#{name} : nil)
+ end
+ EOS
+ end
+ end
+ end
+
+ attr_writer :use
+ attr_writer :form
+ attr_writer :name
+ attr_writer :type
+ attr_writer :local_simpletype
+ attr_writer :default
+ attr_writer :fixed
+
+ attr_reader_ref :use
+ attr_reader_ref :form
+ attr_reader_ref :name
+ attr_reader_ref :type
+ attr_reader_ref :local_simpletype
+ attr_reader_ref :default
+ attr_reader_ref :fixed
+
+ attr_accessor :ref
+ attr_accessor :arytype
+
+ def initialize
+ super
+ @use = nil
+ @form = nil
+ @name = nil
+ @type = nil
+ @local_simpletype = nil
+ @default = nil
+ @fixed = nil
+ @ref = nil
+ @refelement = nil
+ @arytype = nil
+ end
+
+ def refelement
+ @refelement ||= root.collect_attributes[@ref]
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def parse_element(element)
+ case element
+ when SimpleTypeName
+ @local_simpletype = SimpleType.new
+ @local_simpletype
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when RefAttrName
+ @ref = value
+ when UseAttrName
+ @use = value.source
+ when FormAttrName
+ @form = value.source
+ when NameAttrName
+ if directelement?
+ @name = XSD::QName.new(targetnamespace, value.source)
+ else
+ @name = XSD::QName.new(nil, value.source)
+ end
+ when TypeAttrName
+ @type = value
+ when DefaultAttrName
+ @default = value.source
+ when FixedAttrName
+ @fixed = value.source
+ when ArrayTypeAttrName
+ @arytype = if value.namespace.nil?
+ XSD::QName.new(XSD::Namespace, value.source)
+ else
+ value
+ end
+ else
+ nil
+ end
+ end
+
+private
+
+ def directelement?
+ parent.is_a?(Schema)
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/choice.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/choice.rb
new file mode 100644
index 0000000000..f6d27fa38c
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/choice.rb
@@ -0,0 +1,69 @@
+# WSDL4R - XMLSchema complexType definition for 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'
+
+
+module WSDL
+module XMLSchema
+
+
+class Choice < Info
+ attr_reader :minoccurs
+ attr_reader :maxoccurs
+ attr_reader :elements
+
+ def initialize
+ super()
+ @minoccurs = '1'
+ @maxoccurs = '1'
+ @elements = []
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def elementformdefault
+ parent.elementformdefault
+ end
+
+ def <<(element)
+ @elements << element
+ end
+
+ def parse_element(element)
+ case element
+ when AnyName
+ o = Any.new
+ @elements << o
+ o
+ when ElementName
+ o = Element.new
+ @elements << o
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when MaxOccursAttrName
+ @maxoccurs = value.source
+ when MinOccursAttrName
+ @minoccurs = value.source
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/complexContent.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/complexContent.rb
new file mode 100644
index 0000000000..f7fb6c16b4
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/complexContent.rb
@@ -0,0 +1,92 @@
+# WSDL4R - XMLSchema complexContent definition for 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 'xsd/namedelements'
+
+
+module WSDL
+module XMLSchema
+
+
+class ComplexContent < Info
+ attr_accessor :base
+ attr_reader :derivetype
+ attr_reader :content
+ attr_reader :attributes
+
+ def initialize
+ super
+ @base = nil
+ @derivetype = nil
+ @content = nil
+ @attributes = XSD::NamedElements.new
+ @basetype = nil
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def elementformdefault
+ parent.elementformdefault
+ end
+
+ def basetype
+ @basetype ||= root.collect_complextypes[@base]
+ end
+
+ def parse_element(element)
+ case element
+ when RestrictionName, ExtensionName
+ @derivetype = element.name
+ self
+ when AllName
+ if @derivetype.nil?
+ raise Parser::ElementConstraintError.new("base attr not found.")
+ end
+ @content = All.new
+ @content
+ when SequenceName
+ if @derivetype.nil?
+ raise Parser::ElementConstraintError.new("base attr not found.")
+ end
+ @content = Sequence.new
+ @content
+ when ChoiceName
+ if @derivetype.nil?
+ raise Parser::ElementConstraintError.new("base attr not found.")
+ end
+ @content = Choice.new
+ @content
+ when AttributeName
+ if @derivetype.nil?
+ raise Parser::ElementConstraintError.new("base attr not found.")
+ end
+ o = Attribute.new
+ @attributes << o
+ o
+ end
+ end
+
+ def parse_attr(attr, value)
+ if @derivetype.nil?
+ return nil
+ end
+ case attr
+ when BaseAttrName
+ @base = value
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/complexType.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/complexType.rb
new file mode 100644
index 0000000000..dc9ec954fc
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/complexType.rb
@@ -0,0 +1,139 @@
+# WSDL4R - XMLSchema complexType definition for 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/xmlSchema/content'
+require 'wsdl/xmlSchema/element'
+require 'xsd/namedelements'
+
+
+module WSDL
+module XMLSchema
+
+
+class ComplexType < Info
+ attr_accessor :name
+ attr_accessor :complexcontent
+ attr_accessor :simplecontent
+ attr_reader :content
+ attr_accessor :final
+ attr_accessor :mixed
+ attr_reader :attributes
+
+ def initialize(name = nil)
+ super()
+ @name = name
+ @complexcontent = nil
+ @simplecontent = nil
+ @content = nil
+ @final = nil
+ @mixed = false
+ @attributes = XSD::NamedElements.new
+ end
+
+ def targetnamespace
+ # inner elements can be qualified
+ # parent.is_a?(WSDL::XMLSchema::Element) ? nil : parent.targetnamespace
+ parent.targetnamespace
+ end
+
+ def elementformdefault
+ parent.elementformdefault
+ end
+
+ AnyAsElement = Element.new(XSD::QName.new(nil, 'any'), XSD::AnyTypeName)
+ def each_element
+ if content
+ content.elements.each do |element|
+ if element.is_a?(Any)
+ yield(AnyAsElement)
+ else
+ yield(element)
+ end
+ end
+ end
+ end
+
+ def find_element(name)
+ if content
+ content.elements.each do |element|
+ if element.is_a?(Any)
+ return AnyAsElement if name == AnyAsElement.name
+ else
+ return element if name == element.name
+ end
+ end
+ end
+ nil
+ end
+
+ def find_element_by_name(name)
+ if content
+ content.elements.each do |element|
+ if element.is_a?(Any)
+ return AnyAsElement if name == AnyAsElement.name.name
+ else
+ return element if name == element.name.name
+ end
+ end
+ end
+ nil
+ end
+
+ def sequence_elements=(elements)
+ @content = Sequence.new
+ elements.each do |element|
+ @content << element
+ end
+ end
+
+ def all_elements=(elements)
+ @content = All.new
+ elements.each do |element|
+ @content << element
+ end
+ end
+
+ def parse_element(element)
+ case element
+ when AllName
+ @content = All.new
+ when SequenceName
+ @content = Sequence.new
+ when ChoiceName
+ @content = Choice.new
+ when ComplexContentName
+ @complexcontent = ComplexContent.new
+ when SimpleContentName
+ @simplecontent = SimpleContent.new
+ when AttributeName
+ o = Attribute.new
+ @attributes << o
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when FinalAttrName
+ @final = value.source
+ when MixedAttrName
+ @mixed = (value.source == 'true')
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/content.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/content.rb
new file mode 100644
index 0000000000..2f1dfb4b6c
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/content.rb
@@ -0,0 +1,96 @@
+# WSDL4R - XMLSchema complexType definition for 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'
+
+
+module WSDL
+module XMLSchema
+
+
+class Content < Info
+ attr_accessor :final
+ attr_accessor :mixed
+ attr_accessor :type
+ attr_reader :contents
+ attr_reader :elements
+
+ def initialize
+ super()
+ @final = nil
+ @mixed = false
+ @type = nil
+ @contents = []
+ @elements = []
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def <<(content)
+ @contents << content
+ update_elements
+ end
+
+ def each
+ @contents.each do |content|
+ yield content
+ end
+ end
+
+ def parse_element(element)
+ case element
+ when AllName, SequenceName, ChoiceName
+ o = Content.new
+ o.type = element.name
+ @contents << o
+ o
+ when AnyName
+ o = Any.new
+ @contents << o
+ o
+ when ElementName
+ o = Element.new
+ @contents << o
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when FinalAttrName
+ @final = value.source
+ when MixedAttrName
+ @mixed = (value.source == 'true')
+ else
+ nil
+ end
+ end
+
+ def parse_epilogue
+ update_elements
+ end
+
+private
+
+ def update_elements
+ @elements = []
+ @contents.each do |content|
+ if content.is_a?(Element)
+ @elements << [content.name, content]
+ end
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/data.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/data.rb
new file mode 100644
index 0000000000..23ab1adf0b
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/data.rb
@@ -0,0 +1,80 @@
+# WSDL4R - XMLSchema data definitions.
+# Copyright (C) 2002, 2003, 2005 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/datatypes'
+require 'wsdl/xmlSchema/annotation'
+require 'wsdl/xmlSchema/schema'
+require 'wsdl/xmlSchema/import'
+require 'wsdl/xmlSchema/include'
+require 'wsdl/xmlSchema/simpleType'
+require 'wsdl/xmlSchema/simpleRestriction'
+require 'wsdl/xmlSchema/simpleExtension'
+require 'wsdl/xmlSchema/complexType'
+require 'wsdl/xmlSchema/complexContent'
+require 'wsdl/xmlSchema/simpleContent'
+require 'wsdl/xmlSchema/any'
+require 'wsdl/xmlSchema/element'
+require 'wsdl/xmlSchema/all'
+require 'wsdl/xmlSchema/choice'
+require 'wsdl/xmlSchema/sequence'
+require 'wsdl/xmlSchema/attribute'
+require 'wsdl/xmlSchema/unique'
+require 'wsdl/xmlSchema/enumeration'
+require 'wsdl/xmlSchema/length'
+require 'wsdl/xmlSchema/pattern'
+
+module WSDL
+module XMLSchema
+
+
+AllName = XSD::QName.new(XSD::Namespace, 'all')
+AnnotationName = XSD::QName.new(XSD::Namespace, 'annotation')
+AnyName = XSD::QName.new(XSD::Namespace, 'any')
+AttributeName = XSD::QName.new(XSD::Namespace, 'attribute')
+ChoiceName = XSD::QName.new(XSD::Namespace, 'choice')
+ComplexContentName = XSD::QName.new(XSD::Namespace, 'complexContent')
+ComplexTypeName = XSD::QName.new(XSD::Namespace, 'complexType')
+ElementName = XSD::QName.new(XSD::Namespace, 'element')
+EnumerationName = XSD::QName.new(XSD::Namespace, 'enumeration')
+ExtensionName = XSD::QName.new(XSD::Namespace, 'extension')
+ImportName = XSD::QName.new(XSD::Namespace, 'import')
+IncludeName = XSD::QName.new(XSD::Namespace, 'include')
+LengthName = XSD::QName.new(XSD::Namespace, 'length')
+PatternName = XSD::QName.new(XSD::Namespace, 'pattern')
+RestrictionName = XSD::QName.new(XSD::Namespace, 'restriction')
+SequenceName = XSD::QName.new(XSD::Namespace, 'sequence')
+SchemaName = XSD::QName.new(XSD::Namespace, 'schema')
+SimpleContentName = XSD::QName.new(XSD::Namespace, 'simpleContent')
+SimpleTypeName = XSD::QName.new(XSD::Namespace, 'simpleType')
+UniqueName = XSD::QName.new(XSD::Namespace, 'unique')
+
+AttributeFormDefaultAttrName = XSD::QName.new(nil, 'attributeFormDefault')
+BaseAttrName = XSD::QName.new(nil, 'base')
+DefaultAttrName = XSD::QName.new(nil, 'default')
+ElementFormDefaultAttrName = XSD::QName.new(nil, 'elementFormDefault')
+FinalAttrName = XSD::QName.new(nil, 'final')
+FixedAttrName = XSD::QName.new(nil, 'fixed')
+FormAttrName = XSD::QName.new(nil, 'form')
+IdAttrName = XSD::QName.new(nil, 'id')
+MaxOccursAttrName = XSD::QName.new(nil, 'maxOccurs')
+MinOccursAttrName = XSD::QName.new(nil, 'minOccurs')
+MixedAttrName = XSD::QName.new(nil, 'mixed')
+NameAttrName = XSD::QName.new(nil, 'name')
+NamespaceAttrName = XSD::QName.new(nil, 'namespace')
+NillableAttrName = XSD::QName.new(nil, 'nillable')
+ProcessContentsAttrName = XSD::QName.new(nil, 'processContents')
+RefAttrName = XSD::QName.new(nil, 'ref')
+SchemaLocationAttrName = XSD::QName.new(nil, 'schemaLocation')
+TargetNamespaceAttrName = XSD::QName.new(nil, 'targetNamespace')
+TypeAttrName = XSD::QName.new(nil, 'type')
+UseAttrName = XSD::QName.new(nil, 'use')
+ValueAttrName = XSD::QName.new(nil, 'value')
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/element.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/element.rb
new file mode 100644
index 0000000000..fffb6485d0
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/element.rb
@@ -0,0 +1,154 @@
+# WSDL4R - XMLSchema element definition for WSDL.
+# Copyright (C) 2002, 2003, 2005 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 Element < Info
+ class << self
+ if RUBY_VERSION > "1.7.0"
+ def attr_reader_ref(symbol)
+ name = symbol.to_s
+ define_method(name) {
+ instance_variable_get("@#{name}") ||
+ (refelement ? refelement.__send__(name) : nil)
+ }
+ end
+ else
+ def attr_reader_ref(symbol)
+ name = symbol.to_s
+ module_eval <<-EOS
+ def #{name}
+ @#{name} || (refelement ? refelement.#{name} : nil)
+ end
+ EOS
+ end
+ end
+ end
+
+ attr_writer :name # required
+ attr_writer :form
+ attr_writer :type
+ attr_writer :local_simpletype
+ attr_writer :local_complextype
+ attr_writer :constraint
+ attr_writer :maxoccurs
+ attr_writer :minoccurs
+ attr_writer :nillable
+
+ attr_reader_ref :name
+ attr_reader_ref :form
+ attr_reader_ref :type
+ attr_reader_ref :local_simpletype
+ attr_reader_ref :local_complextype
+ attr_reader_ref :constraint
+ attr_reader_ref :maxoccurs
+ attr_reader_ref :minoccurs
+ attr_reader_ref :nillable
+
+ attr_accessor :ref
+
+ def initialize(name = nil, type = nil)
+ super()
+ @name = name
+ @form = nil
+ @type = type
+ @local_simpletype = @local_complextype = nil
+ @constraint = nil
+ @maxoccurs = '1'
+ @minoccurs = '1'
+ @nillable = nil
+ @ref = nil
+ @refelement = nil
+ end
+
+ def refelement
+ @refelement ||= (@ref ? root.collect_elements[@ref] : nil)
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def elementformdefault
+ parent.elementformdefault
+ end
+
+ def elementform
+ self.form.nil? ? parent.elementformdefault : self.form
+ end
+
+ def parse_element(element)
+ case element
+ when SimpleTypeName
+ @local_simpletype = SimpleType.new
+ @local_simpletype
+ when ComplexTypeName
+ @type = nil
+ @local_complextype = ComplexType.new
+ @local_complextype
+ when UniqueName
+ @constraint = Unique.new
+ @constraint
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ # namespace may be nil
+ if directelement? or elementform == 'qualified'
+ @name = XSD::QName.new(targetnamespace, value.source)
+ else
+ @name = XSD::QName.new(nil, value.source)
+ end
+ when FormAttrName
+ @form = value.source
+ when TypeAttrName
+ @type = value
+ when RefAttrName
+ @ref = value
+ when MaxOccursAttrName
+ if parent.is_a?(All)
+ if value.source != '1'
+ raise Parser::AttrConstraintError.new(
+ "cannot parse #{value} for #{attr}")
+ end
+ end
+ @maxoccurs = value.source
+ when MinOccursAttrName
+ if parent.is_a?(All)
+ unless ['0', '1'].include?(value.source)
+ raise Parser::AttrConstraintError.new(
+ "cannot parse #{value} for #{attr}")
+ end
+ end
+ @minoccurs = value.source
+ when NillableAttrName
+ @nillable = (value.source == 'true')
+ else
+ nil
+ end
+ end
+
+private
+
+ def directelement?
+ parent.is_a?(Schema)
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/enumeration.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/enumeration.rb
new file mode 100644
index 0000000000..5a16476032
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/enumeration.rb
@@ -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.source
+ value.source
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/import.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/import.rb
new file mode 100644
index 0000000000..d3487af934
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/import.rb
@@ -0,0 +1,65 @@
+# WSDL4R - XMLSchema import definition.
+# Copyright (C) 2002, 2003, 2005 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/xmlSchema/importer'
+
+
+module WSDL
+module XMLSchema
+
+
+class Import < Info
+ attr_reader :namespace
+ attr_reader :schemalocation
+ attr_reader :content
+
+ def initialize
+ super
+ @namespace = nil
+ @schemalocation = nil
+ @content = nil
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NamespaceAttrName
+ @namespace = value.source
+ when SchemaLocationAttrName
+ @schemalocation = URI.parse(value.source)
+ if @schemalocation.relative? and !parent.location.nil? and
+ !parent.location.relative?
+ @schemalocation = parent.location + @schemalocation
+ end
+ if root.importedschema.key?(@schemalocation)
+ @content = root.importedschema[@schemalocation]
+ else
+ root.importedschema[@schemalocation] = nil # placeholder
+ @content = import(@schemalocation)
+ root.importedschema[@schemalocation] = @content
+ end
+ @schemalocation
+ else
+ nil
+ end
+ end
+
+private
+
+ def import(location)
+ Importer.import(location, root)
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/importer.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/importer.rb
new file mode 100644
index 0000000000..f57bfd972a
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/importer.rb
@@ -0,0 +1,87 @@
+# WSDL4R - XSD importer library.
+# Copyright (C) 2003, 2005 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/httpconfigloader'
+require 'wsdl/xmlSchema/parser'
+
+
+module WSDL
+module XMLSchema
+
+
+class Importer
+ def self.import(location, originalroot = nil)
+ new.import(location, originalroot)
+ end
+
+ def initialize
+ @web_client = nil
+ end
+
+ def import(location, originalroot = nil)
+ unless location.is_a?(URI)
+ location = URI.parse(location)
+ end
+ content = parse(fetch(location), location, originalroot)
+ content.location = location
+ content
+ end
+
+private
+
+ def parse(content, location, originalroot)
+ opt = {
+ :location => location,
+ :originalroot => originalroot
+ }
+ WSDL::XMLSchema::Parser.new(opt).parse(content)
+ end
+
+ def fetch(location)
+ warn("importing: #{location}") if $DEBUG
+ content = nil
+ if location.scheme == 'file' or
+ (location.relative? and FileTest.exist?(location.path))
+ content = File.open(location.path).read
+ elsif location.scheme and location.scheme.size == 1 and
+ FileTest.exist?(location.to_s)
+ # ToDo: remove this ugly workaround for a path with drive letter
+ # (D://foo/bar)
+ content = File.open(location.to_s).read
+ else
+ client = web_client.new(nil, "WSDL4R")
+ client.proxy = ::SOAP::Env::HTTP_PROXY
+ client.no_proxy = ::SOAP::Env::NO_PROXY
+ if opt = ::SOAP::Property.loadproperty(::SOAP::PropertyName)
+ ::SOAP::HTTPConfigLoader.set_options(client,
+ opt["client.protocol.http"])
+ end
+ content = client.get_content(location)
+ end
+ content
+ end
+
+ def web_client
+ @web_client ||= begin
+ require 'http-access2'
+ if HTTPAccess2::VERSION < "2.0"
+ raise LoadError.new("http-access/2.0 or later is required.")
+ end
+ HTTPAccess2::Client
+ rescue LoadError
+ warn("Loading http-access2 failed. Net/http is used.") if $DEBUG
+ require 'soap/netHttpClient'
+ ::SOAP::NetHttpClient
+ end
+ @web_client
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/include.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/include.rb
new file mode 100644
index 0000000000..af1ef942bb
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/include.rb
@@ -0,0 +1,54 @@
+# WSDL4R - XMLSchema include definition.
+# Copyright (C) 2005 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/xmlSchema/importer'
+
+
+module WSDL
+module XMLSchema
+
+
+class Include < Info
+ attr_reader :schemalocation
+ attr_reader :content
+
+ def initialize
+ super
+ @schemalocation = nil
+ @content = nil
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when SchemaLocationAttrName
+ @schemalocation = URI.parse(value.source)
+ if @schemalocation.relative?
+ @schemalocation = parent.location + @schemalocation
+ end
+ @content = import(@schemalocation)
+ @schemalocation
+ else
+ nil
+ end
+ end
+
+private
+
+ def import(location)
+ Importer.import(location)
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/length.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/length.rb
new file mode 100644
index 0000000000..7f61602da9
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/length.rb
@@ -0,0 +1,35 @@
+# WSDL4R - XMLSchema length definition for WSDL.
+# Copyright (C) 2005 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 Length < Info
+ def initialize
+ super
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when ValueAttrName
+ value.source
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/parser.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/parser.rb
new file mode 100644
index 0000000000..057d9d9b70
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/parser.rb
@@ -0,0 +1,166 @@
+# WSDL4R - WSDL XML Instance parser library.
+# Copyright (C) 2002, 2003, 2005 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/qname'
+require 'xsd/ns'
+require 'xsd/charset'
+require 'xsd/datatypes'
+require 'xsd/xmlparser'
+require 'wsdl/xmlSchema/data'
+
+
+module WSDL
+module XMLSchema
+
+
+class Parser
+ include XSD
+
+ class ParseError < Error; end
+ class FormatDecodeError < ParseError; end
+ class UnknownElementError < FormatDecodeError; end
+ class UnknownAttributeError < FormatDecodeError; end
+ class UnexpectedElementError < FormatDecodeError; end
+ class ElementConstraintError < FormatDecodeError; end
+ class AttributeConstraintError < FormatDecodeError; end
+
+private
+
+ class ParseFrame
+ attr_reader :ns
+ attr_reader :name
+ attr_accessor :node
+
+ private
+
+ def initialize(ns, name, node)
+ @ns = ns
+ @name = name
+ @node = node
+ end
+ end
+
+public
+
+ def initialize(opt = {})
+ @parser = XSD::XMLParser.create_parser(self, opt)
+ @parsestack = nil
+ @lastnode = nil
+ @ignored = {}
+ @location = opt[:location]
+ @originalroot = opt[:originalroot]
+ end
+
+ def parse(string_or_readable)
+ @parsestack = []
+ @lastnode = nil
+ @textbuf = ''
+ @parser.do_parse(string_or_readable)
+ @lastnode
+ end
+
+ def charset
+ @parser.charset
+ end
+
+ def start_element(name, attrs)
+ lastframe = @parsestack.last
+ ns = parent = nil
+ if lastframe
+ ns = lastframe.ns.clone_ns
+ parent = lastframe.node
+ else
+ ns = XSD::NS.new
+ parent = nil
+ end
+ attrs = XSD::XMLParser.filter_ns(ns, attrs)
+ node = decode_tag(ns, name, attrs, parent)
+ @parsestack << ParseFrame.new(ns, name, node)
+ end
+
+ def characters(text)
+ lastframe = @parsestack.last
+ if lastframe
+ # Need not to be cloned because character does not have attr.
+ ns = lastframe.ns
+ decode_text(ns, text)
+ else
+ p text if $DEBUG
+ end
+ end
+
+ def end_element(name)
+ lastframe = @parsestack.pop
+ unless name == lastframe.name
+ raise UnexpectedElementError.new("closing element name '#{name}' does not match with opening element '#{lastframe.name}'")
+ end
+ decode_tag_end(lastframe.ns, lastframe.node)
+ @lastnode = lastframe.node
+ end
+
+private
+
+ def decode_tag(ns, name, attrs, parent)
+ o = nil
+ elename = ns.parse(name)
+ if !parent
+ if elename == SchemaName
+ o = Schema.parse_element(elename)
+ o.location = @location
+ else
+ raise UnknownElementError.new("unknown element: #{elename}")
+ end
+ o.root = @originalroot if @originalroot # o.root = o otherwise
+ else
+ if elename == AnnotationName
+ # only the first annotation element is allowed for each element.
+ o = Annotation.new
+ else
+ o = parent.parse_element(elename)
+ end
+ unless o
+ unless @ignored.key?(elename)
+ warn("ignored element: #{elename} of #{parent.class}")
+ @ignored[elename] = elename
+ end
+ o = Documentation.new # which accepts any element.
+ end
+ # node could be a pseudo element. pseudo element has its own parent.
+ o.root = parent.root
+ o.parent = parent if o.parent.nil?
+ end
+ attrs.each do |key, value|
+ attr_ele = ns.parse(key, true)
+ value_ele = ns.parse(value, true)
+ value_ele.source = value # for recovery; value may not be a QName
+ if attr_ele == IdAttrName
+ o.id = value_ele
+ else
+ unless o.parse_attr(attr_ele, value_ele)
+ unless @ignored.key?(attr_ele)
+ warn("ignored attr: #{attr_ele}")
+ @ignored[attr_ele] = attr_ele
+ end
+ end
+ end
+ end
+ o
+ end
+
+ def decode_tag_end(ns, node)
+ node.parse_epilogue
+ end
+
+ def decode_text(ns, text)
+ @textbuf << text
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/pattern.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/pattern.rb
new file mode 100644
index 0000000000..f826be4578
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/pattern.rb
@@ -0,0 +1,36 @@
+# WSDL4R - XMLSchema pattern definition for WSDL.
+# Copyright (C) 2005 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 Pattern < Info
+ def initialize
+ super
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when ValueAttrName
+ parent.pattern = /\A#{value.source}\z/n
+ value.source
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/schema.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/schema.rb
new file mode 100644
index 0000000000..ec97d07aa5
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/schema.rb
@@ -0,0 +1,143 @@
+# WSDL4R - XMLSchema schema definition for WSDL.
+# Copyright (C) 2002, 2003-2005 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 Schema < Info
+ attr_reader :targetnamespace # required
+ attr_reader :complextypes
+ attr_reader :simpletypes
+ attr_reader :elements
+ attr_reader :attributes
+ attr_reader :imports
+ attr_accessor :attributeformdefault
+ attr_accessor :elementformdefault
+
+ attr_reader :importedschema
+
+ def initialize
+ super
+ @targetnamespace = nil
+ @complextypes = XSD::NamedElements.new
+ @simpletypes = XSD::NamedElements.new
+ @elements = XSD::NamedElements.new
+ @attributes = XSD::NamedElements.new
+ @imports = []
+ @attributeformdefault = "unqualified"
+ @elementformdefault = "unqualified"
+ @importedschema = {}
+ @location = nil
+ @root = self
+ end
+
+ def location
+ @location || (root.nil? ? nil : root.location)
+ end
+
+ def location=(location)
+ @location = location
+ end
+
+ def parse_element(element)
+ case element
+ when ImportName
+ o = Import.new
+ @imports << o
+ o
+ when IncludeName
+ o = Include.new
+ @imports << o
+ o
+ when ComplexTypeName
+ o = ComplexType.new
+ @complextypes << o
+ o
+ when SimpleTypeName
+ o = SimpleType.new
+ @simpletypes << o
+ o
+ when ElementName
+ o = Element.new
+ @elements << o
+ o
+ when AttributeName
+ o = Attribute.new
+ @attributes << o
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when TargetNamespaceAttrName
+ @targetnamespace = value.source
+ when AttributeFormDefaultAttrName
+ @attributeformdefault = value.source
+ when ElementFormDefaultAttrName
+ @elementformdefault = value.source
+ else
+ nil
+ end
+ end
+
+ def collect_attributes
+ result = XSD::NamedElements.new
+ result.concat(@attributes)
+ @imports.each do |import|
+ result.concat(import.content.collect_attributes) if import.content
+ end
+ result
+ end
+
+ def collect_elements
+ result = XSD::NamedElements.new
+ result.concat(@elements)
+ @imports.each do |import|
+ result.concat(import.content.collect_elements) if import.content
+ end
+ result
+ end
+
+ def collect_complextypes
+ result = XSD::NamedElements.new
+ result.concat(@complextypes)
+ @imports.each do |import|
+ result.concat(import.content.collect_complextypes) if import.content
+ end
+ result
+ end
+
+ def collect_simpletypes
+ result = XSD::NamedElements.new
+ result.concat(@simpletypes)
+ @imports.each do |import|
+ result.concat(import.content.collect_simpletypes) if import.content
+ end
+ result
+ end
+
+ def self.parse_element(element)
+ if element == SchemaName
+ Schema.new
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/sequence.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/sequence.rb
new file mode 100644
index 0000000000..823fa3b7f9
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/sequence.rb
@@ -0,0 +1,69 @@
+# WSDL4R - XMLSchema complexType definition for 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'
+
+
+module WSDL
+module XMLSchema
+
+
+class Sequence < Info
+ attr_reader :minoccurs
+ attr_reader :maxoccurs
+ attr_reader :elements
+
+ def initialize
+ super()
+ @minoccurs = '1'
+ @maxoccurs = '1'
+ @elements = []
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def elementformdefault
+ parent.elementformdefault
+ end
+
+ def <<(element)
+ @elements << element
+ end
+
+ def parse_element(element)
+ case element
+ when AnyName
+ o = Any.new
+ @elements << o
+ o
+ when ElementName
+ o = Element.new
+ @elements << o
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when MaxOccursAttrName
+ @maxoccurs = value.source
+ when MinOccursAttrName
+ @minoccurs = value.source
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/simpleContent.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/simpleContent.rb
new file mode 100644
index 0000000000..e1f35c88b8
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/simpleContent.rb
@@ -0,0 +1,65 @@
+# WSDL4R - XMLSchema simpleContent definition for WSDL.
+# Copyright (C) 2004, 2005 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 SimpleContent < Info
+ attr_reader :restriction
+ attr_reader :extension
+
+ def check_lexical_format(value)
+ check(value)
+ end
+
+ def initialize
+ super
+ @restriction = nil
+ @extension = nil
+ end
+
+ def base
+ content.base
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def parse_element(element)
+ case element
+ when RestrictionName
+ @restriction = SimpleRestriction.new
+ @restriction
+ when ExtensionName
+ @extension = SimpleExtension.new
+ @extension
+ end
+ end
+
+private
+
+ def content
+ @restriction || @extension
+ end
+
+ def check(value)
+ unless content.valid?(value)
+ raise XSD::ValueSpaceError.new("#{@name}: cannot accept '#{value}'")
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/simpleExtension.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/simpleExtension.rb
new file mode 100644
index 0000000000..3c53a7328c
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/simpleExtension.rb
@@ -0,0 +1,54 @@
+# WSDL4R - XMLSchema simpleType extension definition for WSDL.
+# Copyright (C) 2005 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 SimpleExtension < Info
+ attr_reader :base
+ attr_reader :attributes
+
+ def initialize
+ super
+ @base = nil
+ @attributes = XSD::NamedElements.new
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def valid?(value)
+ true
+ end
+
+ def parse_element(element)
+ case element
+ when AttributeName
+ o = Attribute.new
+ @attributes << o
+ o
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when BaseAttrName
+ @base = value
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/simpleRestriction.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/simpleRestriction.rb
new file mode 100644
index 0000000000..e8bf3ebfa5
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/simpleRestriction.rb
@@ -0,0 +1,73 @@
+# WSDL4R - XMLSchema simpleContent restriction 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
+ attr_accessor :length
+ attr_accessor :pattern
+
+ def initialize
+ super
+ @base = nil
+ @enumeration = [] # NamedElements?
+ @length = nil
+ @pattern = nil
+ end
+
+ def valid?(value)
+ return false unless check_restriction(value)
+ return false unless check_length(value)
+ return false unless check_pattern(value)
+ true
+ end
+
+ def parse_element(element)
+ case element
+ when EnumerationName
+ Enumeration.new # just a parsing handler
+ when LengthName
+ Length.new # just a parsing handler
+ when PatternName
+ Pattern.new # just a parsing handler
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when BaseAttrName
+ @base = value
+ end
+ end
+
+private
+
+ def check_restriction(value)
+ @enumeration.empty? or @enumeration.include?(value)
+ end
+
+ def check_length(value)
+ @length.nil? or value.size == @length
+ end
+
+ def check_pattern(value)
+ @pattern.nil? or @pattern =~ value
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/simpleType.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/simpleType.rb
new file mode 100644
index 0000000000..e808c318c4
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/simpleType.rb
@@ -0,0 +1,73 @@
+# WSDL4R - XMLSchema simpleType definition for WSDL.
+# Copyright (C) 2004, 2005 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 :restriction
+
+ def check_lexical_format(value)
+ if @restriction
+ check_restriction(value)
+ else
+ raise ArgumentError.new("incomplete simpleType")
+ end
+ end
+
+ def base
+ if @restriction
+ @restriction.base
+ else
+ raise ArgumentError.new("incomplete simpleType")
+ end
+ end
+
+ def initialize(name = nil)
+ super()
+ @name = name
+ @restriction = nil
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def parse_element(element)
+ case element
+ when RestrictionName
+ @restriction = SimpleRestriction.new
+ @restriction
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ end
+ end
+
+private
+
+ def check_restriction(value)
+ unless @restriction.valid?(value)
+ raise XSD::ValueSpaceError.new("#{@name}: cannot accept '#{value}'")
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/unique.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/unique.rb
new file mode 100644
index 0000000000..837ff22b4a
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/unique.rb
@@ -0,0 +1,34 @@
+# WSDL4R - XMLSchema unique element.
+# Copyright (C) 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'
+
+
+module WSDL
+module XMLSchema
+
+
+class Unique < Info
+ def initialize
+ super
+ end
+
+ def parse_element(element)
+ # Accepts any element.
+ self
+ end
+
+ def parse_attr(attr, value)
+ # Accepts any attribute.
+ true
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/lib/wsdl/xmlSchema/xsd2ruby.rb b/ruby_1_8_5/lib/wsdl/xmlSchema/xsd2ruby.rb
new file mode 100644
index 0000000000..afe5fc5ada
--- /dev/null
+++ b/ruby_1_8_5/lib/wsdl/xmlSchema/xsd2ruby.rb
@@ -0,0 +1,107 @@
+# XSD4R - XSD to ruby mapping library.
+# Copyright (C) 2005 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 'wsdl/xmlSchema/importer'
+require 'wsdl/soap/classDefCreator'
+
+
+module WSDL
+module XMLSchema
+
+
+class XSD2Ruby
+ attr_accessor :location
+ attr_reader :opt
+ attr_accessor :logger
+ attr_accessor :basedir
+
+ def run
+ unless @location
+ raise RuntimeError, "XML Schema location not given"
+ end
+ @xsd = import(@location)
+ @name = create_classname(@xsd)
+ create_file
+ end
+
+private
+
+ def initialize
+ @location = nil
+ @opt = {}
+ @logger = Logger.new(STDERR)
+ @basedir = nil
+ @xsd = nil
+ @name = nil
+ end
+
+ def create_file
+ create_classdef
+ end
+
+ def create_classdef
+ @logger.info { "Creating class definition." }
+ @classdef_filename = @name + '.rb'
+ check_file(@classdef_filename) or return
+ write_file(@classdef_filename) do |f|
+ f << WSDL::SOAP::ClassDefCreator.new(@xsd).dump
+ end
+ end
+
+ def write_file(filename)
+ if @basedir
+ filename = File.join(basedir, filename)
+ end
+ File.open(filename, "w") do |f|
+ yield f
+ end
+ end
+
+ def check_file(filename)
+ if @basedir
+ filename = File.join(basedir, filename)
+ end
+ if FileTest.exist?(filename)
+ if @opt.key?('force')
+ @logger.warn {
+ "File '#{filename}' exists but overrides it."
+ }
+ true
+ else
+ @logger.warn {
+ "File '#{filename}' exists. #{$0} did not override it."
+ }
+ false
+ end
+ else
+ @logger.info { "Creates file '#{filename}'." }
+ true
+ end
+ end
+
+ def create_classname(xsd)
+ name = nil
+ if xsd.targetnamespace
+ name = xsd.targetnamespace.scan(/[a-zA-Z0-9]+$/)[0]
+ end
+ if name.nil?
+ 'default'
+ else
+ XSD::CodeGen::GenSupport.safevarname(name)
+ end
+ end
+
+ def import(location)
+ WSDL::XMLSchema::Importer.import(location)
+ end
+end
+
+
+end
+end