summaryrefslogtreecommitdiff
path: root/ruby_1_8_6/lib/soap/rpc
diff options
context:
space:
mode:
Diffstat (limited to 'ruby_1_8_6/lib/soap/rpc')
-rw-r--r--ruby_1_8_6/lib/soap/rpc/cgistub.rb206
-rw-r--r--ruby_1_8_6/lib/soap/rpc/driver.rb254
-rw-r--r--ruby_1_8_6/lib/soap/rpc/element.rb325
-rw-r--r--ruby_1_8_6/lib/soap/rpc/httpserver.rb129
-rw-r--r--ruby_1_8_6/lib/soap/rpc/proxy.rb497
-rw-r--r--ruby_1_8_6/lib/soap/rpc/router.rb594
-rw-r--r--ruby_1_8_6/lib/soap/rpc/rpc.rb25
-rw-r--r--ruby_1_8_6/lib/soap/rpc/soaplet.rb162
-rw-r--r--ruby_1_8_6/lib/soap/rpc/standaloneServer.rb43
9 files changed, 0 insertions, 2235 deletions
diff --git a/ruby_1_8_6/lib/soap/rpc/cgistub.rb b/ruby_1_8_6/lib/soap/rpc/cgistub.rb
deleted file mode 100644
index 487f05a9bf..0000000000
--- a/ruby_1_8_6/lib/soap/rpc/cgistub.rb
+++ /dev/null
@@ -1,206 +0,0 @@
-# SOAP4R - CGI/mod_ruby stub library
-# Copyright (C) 2001, 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/streamHandler'
-require 'webrick/httpresponse'
-require 'webrick/httpstatus'
-require 'logger'
-require 'soap/rpc/soaplet'
-
-
-module SOAP
-module RPC
-
-
-###
-# SYNOPSIS
-# CGIStub.new
-#
-# DESCRIPTION
-# To be written...
-#
-class CGIStub < Logger::Application
- include SOAP
- include WEBrick
-
- class SOAPRequest
- attr_reader :body
-
- def [](var); end
-
- def meta_vars; end
- end
-
- class SOAPStdinRequest < SOAPRequest
- attr_reader :body
-
- def initialize(stream)
- size = ENV['CONTENT_LENGTH'].to_i || 0
- @body = stream.read(size)
- end
-
- def [](var)
- ENV[var.gsub(/-/, '_').upcase]
- end
-
- def meta_vars
- {
- 'HTTP_SOAPACTION' => ENV['HTTP_SOAPAction']
- }
- end
- end
-
- class SOAPFCGIRequest < SOAPRequest
- attr_reader :body
-
- def initialize(request)
- @request = request
- @body = @request.in.read
- end
-
- def [](var)
- @request.env[var.gsub(/-/, '_').upcase]
- end
-
- def meta_vars
- {
- 'HTTP_SOAPACTION' => @request.env['HTTP_SOAPAction']
- }
- end
- end
-
- def initialize(appname, default_namespace)
- super(appname)
- set_log(STDERR)
- self.level = ERROR
- @default_namespace = default_namespace
- @remote_host = ENV['REMOTE_HOST'] || ENV['REMOTE_ADDR'] || 'unknown'
- @router = ::SOAP::RPC::Router.new(self.class.name)
- @soaplet = ::SOAP::RPC::SOAPlet.new(@router)
- on_init
- end
-
- def on_init
- # do extra initialization in a derived class if needed.
- end
-
- def mapping_registry
- @router.mapping_registry
- end
-
- def mapping_registry=(value)
- @router.mapping_registry = value
- end
-
- def generate_explicit_type
- @router.generate_explicit_type
- end
-
- def generate_explicit_type=(generate_explicit_type)
- @router.generate_explicit_type = generate_explicit_type
- end
-
- # servant entry interface
-
- def add_rpc_servant(obj, namespace = @default_namespace)
- @router.add_rpc_servant(obj, namespace)
- end
- alias add_servant add_rpc_servant
-
- def add_headerhandler(obj)
- @router.add_headerhandler(obj)
- end
- alias add_rpc_headerhandler add_headerhandler
-
- # method entry interface
-
- def add_rpc_method(obj, name, *param)
- add_rpc_method_with_namespace_as(@default_namespace, obj, name, name, *param)
- end
- alias add_method add_rpc_method
-
- def add_rpc_method_as(obj, name, name_as, *param)
- add_rpc_method_with_namespace_as(@default_namespace, obj, name, name_as, *param)
- end
- alias add_method_as add_rpc_method_as
-
- def add_rpc_method_with_namespace(namespace, obj, name, *param)
- add_rpc_method_with_namespace_as(namespace, obj, name, name, *param)
- end
- alias add_method_with_namespace add_rpc_method_with_namespace
-
- def add_rpc_method_with_namespace_as(namespace, obj, name, name_as, *param)
- qname = XSD::QName.new(namespace, name_as)
- soapaction = nil
- param_def = SOAPMethod.derive_rpc_param_def(obj, name, *param)
- @router.add_rpc_operation(obj, qname, soapaction, name, param_def)
- end
- alias add_method_with_namespace_as add_rpc_method_with_namespace_as
-
- def add_rpc_operation(receiver, qname, soapaction, name, param_def, opt = {})
- @router.add_rpc_operation(receiver, qname, soapaction, name, param_def, opt)
- end
-
- def add_document_operation(receiver, soapaction, name, param_def, opt = {})
- @router.add_document_operation(receiver, soapaction, name, param_def, opt)
- end
-
- def set_fcgi_request(request)
- @fcgi = request
- end
-
-private
-
- HTTPVersion = WEBrick::HTTPVersion.new('1.0') # dummy; ignored
-
- def run
- res = WEBrick::HTTPResponse.new({:HTTPVersion => HTTPVersion})
- begin
- @log.info { "received a request from '#{ @remote_host }'" }
- if @fcgi
- req = SOAPFCGIRequest.new(@fcgi)
- else
- req = SOAPStdinRequest.new($stdin)
- end
- @soaplet.do_POST(req, res)
- rescue HTTPStatus::EOFError, HTTPStatus::RequestTimeout => ex
- res.set_error(ex)
- rescue HTTPStatus::Error => ex
- res.set_error(ex)
- rescue HTTPStatus::Status => ex
- res.status = ex.code
- rescue StandardError, NameError => ex # for Ruby 1.6
- res.set_error(ex, true)
- ensure
- if defined?(MOD_RUBY)
- r = Apache.request
- r.status = res.status
- r.content_type = res.content_type
- r.send_http_header
- buf = res.body
- else
- buf = ''
- res.send_response(buf)
- buf.sub!(/^[^\r]+\r\n/, '') # Trim status line.
- end
- @log.debug { "SOAP CGI Response:\n#{ buf }" }
- if @fcgi
- @fcgi.out.print buf
- @fcgi.finish
- @fcgi = nil
- else
- print buf
- end
- end
- 0
- end
-end
-
-
-end
-end
diff --git a/ruby_1_8_6/lib/soap/rpc/driver.rb b/ruby_1_8_6/lib/soap/rpc/driver.rb
deleted file mode 100644
index 0fb4e82488..0000000000
--- a/ruby_1_8_6/lib/soap/rpc/driver.rb
+++ /dev/null
@@ -1,254 +0,0 @@
-# SOAP4R - SOAP RPC driver
-# Copyright (C) 2000, 2001, 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/soap'
-require 'soap/mapping'
-require 'soap/mapping/wsdlliteralregistry'
-require 'soap/rpc/rpc'
-require 'soap/rpc/proxy'
-require 'soap/rpc/element'
-require 'soap/streamHandler'
-require 'soap/property'
-require 'soap/header/handlerset'
-
-
-module SOAP
-module RPC
-
-
-class Driver
- class << self
- if RUBY_VERSION >= "1.7.0"
- def __attr_proxy(symbol, assignable = false)
- name = symbol.to_s
- define_method(name) {
- @proxy.__send__(name)
- }
- if assignable
- aname = name + '='
- define_method(aname) { |rhs|
- @proxy.__send__(aname, rhs)
- }
- end
- end
- else
- def __attr_proxy(symbol, assignable = false)
- name = symbol.to_s
- module_eval <<-EOS
- def #{name}
- @proxy.#{name}
- end
- EOS
- if assignable
- module_eval <<-EOS
- def #{name}=(value)
- @proxy.#{name} = value
- end
- EOS
- end
- end
- end
- end
-
- __attr_proxy :endpoint_url, true
- __attr_proxy :mapping_registry, true
- __attr_proxy :default_encodingstyle, true
- __attr_proxy :generate_explicit_type, true
- __attr_proxy :allow_unqualified_element, true
- __attr_proxy :headerhandler
- __attr_proxy :streamhandler
- __attr_proxy :test_loopback_response
- __attr_proxy :reset_stream
-
- attr_reader :proxy
- attr_reader :options
- attr_accessor :soapaction
-
- def inspect
- "#<#{self.class}:#{@proxy.inspect}>"
- end
-
- def httpproxy
- options["protocol.http.proxy"]
- end
-
- def httpproxy=(httpproxy)
- options["protocol.http.proxy"] = httpproxy
- end
-
- def wiredump_dev
- options["protocol.http.wiredump_dev"]
- end
-
- def wiredump_dev=(wiredump_dev)
- options["protocol.http.wiredump_dev"] = wiredump_dev
- end
-
- def mandatorycharset
- options["protocol.mandatorycharset"]
- end
-
- def mandatorycharset=(mandatorycharset)
- options["protocol.mandatorycharset"] = mandatorycharset
- end
-
- def wiredump_file_base
- options["protocol.wiredump_file_base"]
- end
-
- def wiredump_file_base=(wiredump_file_base)
- options["protocol.wiredump_file_base"] = wiredump_file_base
- end
-
- def initialize(endpoint_url, namespace = nil, soapaction = nil)
- @namespace = namespace
- @soapaction = soapaction
- @options = setup_options
- @wiredump_file_base = nil
- @proxy = Proxy.new(endpoint_url, @soapaction, @options)
- end
-
- def loadproperty(propertyname)
- unless options.loadproperty(propertyname)
- raise LoadError.new("No such property to load -- #{propertyname}")
- end
- end
-
- def add_rpc_method(name, *params)
- add_rpc_method_with_soapaction_as(name, name, @soapaction, *params)
- end
-
- def add_rpc_method_as(name, name_as, *params)
- add_rpc_method_with_soapaction_as(name, name_as, @soapaction, *params)
- end
-
- def add_rpc_method_with_soapaction(name, soapaction, *params)
- add_rpc_method_with_soapaction_as(name, name, soapaction, *params)
- end
-
- def add_rpc_method_with_soapaction_as(name, name_as, soapaction, *params)
- param_def = SOAPMethod.create_rpc_param_def(params)
- qname = XSD::QName.new(@namespace, name_as)
- @proxy.add_rpc_method(qname, soapaction, name, param_def)
- add_rpc_method_interface(name, param_def)
- end
-
- # add_method is for shortcut of typical rpc/encoded method definition.
- alias add_method add_rpc_method
- alias add_method_as add_rpc_method_as
- alias add_method_with_soapaction add_rpc_method_with_soapaction
- alias add_method_with_soapaction_as add_rpc_method_with_soapaction_as
-
- def add_document_method(name, soapaction, req_qname, res_qname)
- param_def = SOAPMethod.create_doc_param_def(req_qname, res_qname)
- @proxy.add_document_method(soapaction, name, param_def)
- add_document_method_interface(name, param_def)
- end
-
- def add_rpc_operation(qname, soapaction, name, param_def, opt = {})
- @proxy.add_rpc_operation(qname, soapaction, name, param_def, opt)
- add_rpc_method_interface(name, param_def)
- end
-
- def add_document_operation(soapaction, name, param_def, opt = {})
- @proxy.add_document_operation(soapaction, name, param_def, opt)
- add_document_method_interface(name, param_def)
- end
-
- def invoke(headers, body)
- if headers and !headers.is_a?(SOAPHeader)
- headers = create_header(headers)
- end
- set_wiredump_file_base(body.elename.name)
- env = @proxy.invoke(headers, body)
- if env.nil?
- return nil, nil
- else
- return env.header, env.body
- end
- end
-
- def call(name, *params)
- set_wiredump_file_base(name)
- @proxy.call(name, *params)
- end
-
-private
-
- def set_wiredump_file_base(name)
- if @wiredump_file_base
- @proxy.set_wiredump_file_base("#{@wiredump_file_base}_#{name}")
- end
- end
-
- def create_header(headers)
- header = SOAPHeader.new()
- headers.each do |content, mustunderstand, encodingstyle|
- header.add(SOAPHeaderItem.new(content, mustunderstand, encodingstyle))
- end
- header
- end
-
- def setup_options
- if opt = Property.loadproperty(::SOAP::PropertyName)
- opt = opt["client"]
- end
- opt ||= Property.new
- opt.add_hook("protocol.mandatorycharset") do |key, value|
- @proxy.mandatorycharset = value
- end
- opt.add_hook("protocol.wiredump_file_base") do |key, value|
- @wiredump_file_base = value
- end
- opt["protocol.http.charset"] ||= XSD::Charset.xml_encoding_label
- opt["protocol.http.proxy"] ||= Env::HTTP_PROXY
- opt["protocol.http.no_proxy"] ||= Env::NO_PROXY
- opt
- end
-
- def add_rpc_method_interface(name, param_def)
- param_count = RPC::SOAPMethod.param_count(param_def,
- RPC::SOAPMethod::IN, RPC::SOAPMethod::INOUT)
- add_method_interface(name, param_count)
- end
-
- def add_document_method_interface(name, param_def)
- param_count = RPC::SOAPMethod.param_count(param_def, RPC::SOAPMethod::IN)
- add_method_interface(name, param_count)
- end
-
- if RUBY_VERSION > "1.7.0"
- def add_method_interface(name, param_count)
- ::SOAP::Mapping.define_singleton_method(self, name) do |*arg|
- unless arg.size == param_count
- raise ArgumentError.new(
- "wrong number of arguments (#{arg.size} for #{param_count})")
- end
- call(name, *arg)
- end
- self.method(name)
- end
- else
- def add_method_interface(name, param_count)
- instance_eval <<-EOS
- def #{name}(*arg)
- unless arg.size == #{param_count}
- raise ArgumentError.new(
- "wrong number of arguments (\#{arg.size} for #{param_count})")
- end
- call(#{name.dump}, *arg)
- end
- EOS
- self.method(name)
- end
- end
-end
-
-
-end
-end
diff --git a/ruby_1_8_6/lib/soap/rpc/element.rb b/ruby_1_8_6/lib/soap/rpc/element.rb
deleted file mode 100644
index c224b03d0d..0000000000
--- a/ruby_1_8_6/lib/soap/rpc/element.rb
+++ /dev/null
@@ -1,325 +0,0 @@
-# SOAP4R - RPC element definition.
-# Copyright (C) 2000, 2001, 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/baseData'
-
-
-module SOAP
-
-# Add method definitions for RPC to common definition in element.rb
-class SOAPBody < SOAPStruct
- public
-
- def request
- root_node
- end
-
- def response
- root = root_node
- if !@is_fault
- if root.nil?
- nil
- elsif root.is_a?(SOAPBasetype)
- root
- else
- # Initial element is [retval].
- root[0]
- end
- else
- root
- end
- end
-
- def outparams
- root = root_node
- if !@is_fault and !root.nil? and !root.is_a?(SOAPBasetype)
- op = root[1..-1]
- op = nil if op && op.empty?
- op
- else
- nil
- end
- end
-
- def fault
- if @is_fault
- self['fault']
- else
- nil
- end
- end
-
- def fault=(fault)
- @is_fault = true
- add_member('fault', fault)
- end
-end
-
-
-module RPC
-
-
-class RPCError < Error; end
-class MethodDefinitionError < RPCError; end
-class ParameterError < RPCError; end
-
-class SOAPMethod < SOAPStruct
- RETVAL = 'retval'
- IN = 'in'
- OUT = 'out'
- INOUT = 'inout'
-
- attr_reader :param_def
- attr_reader :inparam
- attr_reader :outparam
- attr_reader :retval_name
- attr_reader :retval_class_name
-
- def initialize(qname, param_def = nil)
- super(nil)
- @elename = qname
- @encodingstyle = nil
-
- @param_def = param_def
-
- @signature = []
- @inparam_names = []
- @inoutparam_names = []
- @outparam_names = []
-
- @inparam = {}
- @outparam = {}
- @retval_name = nil
- @retval_class_name = nil
-
- init_param(@param_def) if @param_def
- end
-
- def have_outparam?
- @outparam_names.size > 0
- end
-
- def input_params
- collect_params(IN, INOUT)
- end
-
- def output_params
- collect_params(OUT, INOUT)
- end
-
- def set_param(params)
- params.each do |param, data|
- @inparam[param] = data
- data.elename.name = param
- data.parent = self
- end
- end
-
- def set_outparam(params)
- params.each do |param, data|
- @outparam[param] = data
- data.elename.name = param
- end
- end
-
- def SOAPMethod.param_count(param_def, *type)
- count = 0
- param_def.each do |io_type, name, param_type|
- if type.include?(io_type)
- count += 1
- end
- end
- count
- end
-
- def SOAPMethod.derive_rpc_param_def(obj, name, *param)
- if param.size == 1 and param[0].is_a?(Array)
- return param[0]
- end
- if param.empty?
- method = obj.method(name)
- param_names = (1..method.arity.abs).collect { |i| "p#{i}" }
- else
- param_names = param
- end
- create_rpc_param_def(param_names)
- end
-
- def SOAPMethod.create_rpc_param_def(param_names)
- param_def = []
- param_names.each do |param_name|
- param_def.push([IN, param_name, nil])
- end
- param_def.push([RETVAL, 'return', nil])
- param_def
- end
-
- def SOAPMethod.create_doc_param_def(req_qnames, res_qnames)
- req_qnames = [req_qnames] if req_qnames.is_a?(XSD::QName)
- res_qnames = [res_qnames] if res_qnames.is_a?(XSD::QName)
- param_def = []
- req_qnames.each do |qname|
- param_def << [IN, qname.name, [nil, qname.namespace, qname.name]]
- end
- res_qnames.each do |qname|
- param_def << [OUT, qname.name, [nil, qname.namespace, qname.name]]
- end
- param_def
- end
-
-private
-
- def collect_params(*type)
- names = []
- @signature.each do |io_type, name, param_type|
- names << name if type.include?(io_type)
- end
- names
- end
-
- def init_param(param_def)
- param_def.each do |io_type, name, param_type|
- case io_type
- when IN
- @signature.push([IN, name, param_type])
- @inparam_names.push(name)
- when OUT
- @signature.push([OUT, name, param_type])
- @outparam_names.push(name)
- when INOUT
- @signature.push([INOUT, name, param_type])
- @inoutparam_names.push(name)
- when RETVAL
- if @retval_name
- raise MethodDefinitionError.new('duplicated retval')
- end
- @retval_name = name
- @retval_class_name = nil
- if param_type
- if param_type[0].is_a?(String)
- @retval_class_name = Mapping.class_from_name(param_type[0])
- else
- @retval_class_name = param_type[0]
- end
- end
- else
- raise MethodDefinitionError.new("unknown type: #{io_type}")
- end
- end
- end
-end
-
-
-class SOAPMethodRequest < SOAPMethod
- attr_accessor :soapaction
-
- def SOAPMethodRequest.create_request(qname, *params)
- param_def = []
- param_value = []
- i = 0
- params.each do |param|
- param_name = "p#{i}"
- i += 1
- param_def << [IN, param_name, nil]
- param_value << [param_name, param]
- end
- param_def << [RETVAL, 'return', nil]
- o = new(qname, param_def)
- o.set_param(param_value)
- o
- end
-
- def initialize(qname, param_def = nil, soapaction = nil)
- check_elename(qname)
- super(qname, param_def)
- @soapaction = soapaction
- end
-
- def each
- input_params.each do |name|
- unless @inparam[name]
- raise ParameterError.new("parameter: #{name} was not given")
- end
- yield(name, @inparam[name])
- end
- end
-
- def dup
- req = self.class.new(@elename.dup, @param_def, @soapaction)
- req.encodingstyle = @encodingstyle
- req
- end
-
- def create_method_response(response_name = nil)
- response_name ||=
- XSD::QName.new(@elename.namespace, @elename.name + 'Response')
- SOAPMethodResponse.new(response_name, @param_def)
- end
-
-private
-
- def check_elename(qname)
- # NCName & ruby's method name
- unless /\A[\w_][\w\d_\-]*\z/ =~ qname.name
- raise MethodDefinitionError.new("element name '#{qname.name}' not allowed")
- end
- end
-end
-
-
-class SOAPMethodResponse < SOAPMethod
-
- def initialize(qname, param_def = nil)
- super(qname, param_def)
- @retval = nil
- end
-
- def retval=(retval)
- @retval = retval
- @retval.elename = @retval.elename.dup_name(@retval_name || 'return')
- retval.parent = self
- retval
- end
-
- def each
- if @retval_name and !@retval.is_a?(SOAPVoid)
- yield(@retval_name, @retval)
- end
-
- output_params.each do |name|
- unless @outparam[name]
- raise ParameterError.new("parameter: #{name} was not given")
- end
- yield(name, @outparam[name])
- end
- end
-end
-
-
-# To return(?) void explicitly.
-# def foo(input_var)
-# ...
-# return SOAP::RPC::SOAPVoid.new
-# end
-class SOAPVoid < XSD::XSDAnySimpleType
- include SOAPBasetype
- extend SOAPModuleUtils
- Name = XSD::QName.new(Mapping::RubyCustomTypeNamespace, nil)
-
-public
- def initialize()
- @elename = Name
- @id = nil
- @precedents = []
- @parent = nil
- end
-end
-
-
-end
-end
diff --git a/ruby_1_8_6/lib/soap/rpc/httpserver.rb b/ruby_1_8_6/lib/soap/rpc/httpserver.rb
deleted file mode 100644
index 6d2a72ebe3..0000000000
--- a/ruby_1_8_6/lib/soap/rpc/httpserver.rb
+++ /dev/null
@@ -1,129 +0,0 @@
-# SOAP4R - WEBrick HTTP Server
-# Copyright (C) 2003, 2004 by NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
-
-# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
-# redistribute it and/or modify it under the same terms of Ruby's license;
-# either the dual license version in 2003, or any later version.
-
-
-require 'logger'
-require 'soap/rpc/soaplet'
-require 'soap/streamHandler'
-require 'webrick'
-
-
-module SOAP
-module RPC
-
-
-class HTTPServer < Logger::Application
- attr_reader :server
- attr_accessor :default_namespace
-
- def initialize(config)
- super(config[:SOAPHTTPServerApplicationName] || self.class.name)
- @default_namespace = config[:SOAPDefaultNamespace]
- @webrick_config = config.dup
- self.level = Logger::Severity::ERROR # keep silent by default
- @webrick_config[:Logger] ||= @log
- @log = @webrick_config[:Logger] # sync logger of App and HTTPServer
- @router = ::SOAP::RPC::Router.new(self.class.name)
- @soaplet = ::SOAP::RPC::SOAPlet.new(@router)
- on_init
- @server = WEBrick::HTTPServer.new(@webrick_config)
- @server.mount('/', @soaplet)
- end
-
- def on_init
- # do extra initialization in a derived class if needed.
- end
-
- def status
- @server.status if @server
- end
-
- def shutdown
- @server.shutdown if @server
- end
-
- def mapping_registry
- @router.mapping_registry
- end
-
- def mapping_registry=(mapping_registry)
- @router.mapping_registry = mapping_registry
- end
-
- def generate_explicit_type
- @router.generate_explicit_type
- end
-
- def generate_explicit_type=(generate_explicit_type)
- @router.generate_explicit_type = generate_explicit_type
- end
-
- # servant entry interface
-
- def add_rpc_request_servant(factory, namespace = @default_namespace)
- @router.add_rpc_request_servant(factory, namespace)
- end
-
- def add_rpc_servant(obj, namespace = @default_namespace)
- @router.add_rpc_servant(obj, namespace)
- end
-
- def add_request_headerhandler(factory)
- @router.add_request_headerhandler(factory)
- end
-
- def add_headerhandler(obj)
- @router.add_headerhandler(obj)
- end
- alias add_rpc_headerhandler add_headerhandler
-
- # method entry interface
-
- def add_rpc_method(obj, name, *param)
- add_rpc_method_as(obj, name, name, *param)
- end
- alias add_method add_rpc_method
-
- def add_rpc_method_as(obj, name, name_as, *param)
- qname = XSD::QName.new(@default_namespace, name_as)
- soapaction = nil
- param_def = SOAPMethod.derive_rpc_param_def(obj, name, *param)
- @router.add_rpc_operation(obj, qname, soapaction, name, param_def)
- end
- alias add_method_as add_rpc_method_as
-
- def add_document_method(obj, soapaction, name, req_qnames, res_qnames)
- param_def = SOAPMethod.create_doc_param_def(req_qnames, res_qnames)
- @router.add_document_operation(obj, soapaction, name, param_def)
- end
-
- def add_rpc_operation(receiver, qname, soapaction, name, param_def, opt = {})
- @router.add_rpc_operation(receiver, qname, soapaction, name, param_def, opt)
- end
-
- def add_rpc_request_operation(factory, qname, soapaction, name, param_def, opt = {})
- @router.add_rpc_request_operation(factory, qname, soapaction, name, param_def, opt)
- end
-
- def add_document_operation(receiver, soapaction, name, param_def, opt = {})
- @router.add_document_operation(receiver, soapaction, name, param_def, opt)
- end
-
- def add_document_request_operation(factory, soapaction, name, param_def, opt = {})
- @router.add_document_request_operation(factory, soapaction, name, param_def, opt)
- end
-
-private
-
- def run
- @server.start
- end
-end
-
-
-end
-end
diff --git a/ruby_1_8_6/lib/soap/rpc/proxy.rb b/ruby_1_8_6/lib/soap/rpc/proxy.rb
deleted file mode 100644
index 7dfda62006..0000000000
--- a/ruby_1_8_6/lib/soap/rpc/proxy.rb
+++ /dev/null
@@ -1,497 +0,0 @@
-# SOAP4R - RPC Proxy library.
-# Copyright (C) 2000, 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/soap'
-require 'soap/processor'
-require 'soap/mapping'
-require 'soap/rpc/rpc'
-require 'soap/rpc/element'
-require 'soap/streamHandler'
-require 'soap/mimemessage'
-
-
-module SOAP
-module RPC
-
-
-class Proxy
- include SOAP
-
-public
-
- attr_accessor :soapaction
- attr_accessor :mandatorycharset
- attr_accessor :allow_unqualified_element
- attr_accessor :default_encodingstyle
- attr_accessor :generate_explicit_type
- attr_reader :headerhandler
- attr_reader :streamhandler
-
- attr_accessor :mapping_registry
- attr_accessor :literal_mapping_registry
-
- attr_reader :operation
-
- def initialize(endpoint_url, soapaction, options)
- @endpoint_url = endpoint_url
- @soapaction = soapaction
- @options = options
- @streamhandler = HTTPStreamHandler.new(
- @options["protocol.http"] ||= ::SOAP::Property.new)
- @operation = {}
- @mandatorycharset = nil
- @allow_unqualified_element = true
- @default_encodingstyle = nil
- @generate_explicit_type = true
- @headerhandler = Header::HandlerSet.new
- @mapping_registry = nil
- @literal_mapping_registry = ::SOAP::Mapping::WSDLLiteralRegistry.new
- end
-
- def inspect
- "#<#{self.class}:#{@endpoint_url}>"
- end
-
- def endpoint_url
- @endpoint_url
- end
-
- def endpoint_url=(endpoint_url)
- @endpoint_url = endpoint_url
- reset_stream
- end
-
- def reset_stream
- @streamhandler.reset(@endpoint_url)
- end
-
- def set_wiredump_file_base(wiredump_file_base)
- @streamhandler.wiredump_file_base = wiredump_file_base
- end
-
- def test_loopback_response
- @streamhandler.test_loopback_response
- end
-
- def add_rpc_operation(qname, soapaction, name, param_def, opt = {})
- opt[:request_qname] = qname
- opt[:request_style] ||= :rpc
- opt[:response_style] ||= :rpc
- opt[:request_use] ||= :encoded
- opt[:response_use] ||= :encoded
- @operation[name] = Operation.new(soapaction, param_def, opt)
- end
-
- def add_document_operation(soapaction, name, param_def, opt = {})
- opt[:request_style] ||= :document
- opt[:response_style] ||= :document
- opt[:request_use] ||= :literal
- opt[:response_use] ||= :literal
- # default values of these values are unqualified in XML Schema.
- # set true for backward compatibility.
- unless opt.key?(:elementformdefault)
- opt[:elementformdefault] = true
- end
- unless opt.key?(:attributeformdefault)
- opt[:attributeformdefault] = true
- end
- @operation[name] = Operation.new(soapaction, param_def, opt)
- end
-
- # add_method is for shortcut of typical rpc/encoded method definition.
- alias add_method add_rpc_operation
- alias add_rpc_method add_rpc_operation
- alias add_document_method add_document_operation
-
- def invoke(req_header, req_body, opt = nil)
- opt ||= create_encoding_opt
- route(req_header, req_body, opt, opt)
- end
-
- def call(name, *params)
- unless op_info = @operation[name]
- raise MethodDefinitionError, "method: #{name} not defined"
- end
- mapping_opt = create_mapping_opt
- req_header = create_request_header
- req_body = SOAPBody.new(
- op_info.request_body(params, @mapping_registry,
- @literal_mapping_registry, mapping_opt)
- )
- reqopt = create_encoding_opt(
- :soapaction => op_info.soapaction || @soapaction,
- :envelopenamespace => @options["soap.envelope.requestnamespace"],
- :default_encodingstyle =>
- @default_encodingstyle || op_info.request_default_encodingstyle,
- :elementformdefault => op_info.elementformdefault,
- :attributeformdefault => op_info.attributeformdefault
- )
- resopt = create_encoding_opt(
- :envelopenamespace => @options["soap.envelope.responsenamespace"],
- :default_encodingstyle =>
- @default_encodingstyle || op_info.response_default_encodingstyle,
- :elementformdefault => op_info.elementformdefault,
- :attributeformdefault => op_info.attributeformdefault
- )
- env = route(req_header, req_body, reqopt, resopt)
- raise EmptyResponseError unless env
- receive_headers(env.header)
- begin
- check_fault(env.body)
- rescue ::SOAP::FaultError => e
- op_info.raise_fault(e, @mapping_registry, @literal_mapping_registry)
- end
- op_info.response_obj(env.body, @mapping_registry,
- @literal_mapping_registry, mapping_opt)
- end
-
- def route(req_header, req_body, reqopt, resopt)
- req_env = ::SOAP::SOAPEnvelope.new(req_header, req_body)
- unless reqopt[:envelopenamespace].nil?
- set_envelopenamespace(req_env, reqopt[:envelopenamespace])
- end
- reqopt[:external_content] = nil
- conn_data = marshal(req_env, reqopt)
- if ext = reqopt[:external_content]
- mime = MIMEMessage.new
- ext.each do |k, v|
- mime.add_attachment(v.data)
- end
- mime.add_part(conn_data.send_string + "\r\n")
- mime.close
- conn_data.send_string = mime.content_str
- conn_data.send_contenttype = mime.headers['content-type'].str
- end
- conn_data = @streamhandler.send(@endpoint_url, conn_data,
- reqopt[:soapaction])
- if conn_data.receive_string.empty?
- return nil
- end
- unmarshal(conn_data, resopt)
- end
-
- def check_fault(body)
- if body.fault
- raise SOAP::FaultError.new(body.fault)
- end
- end
-
-private
-
- def set_envelopenamespace(env, namespace)
- env.elename = XSD::QName.new(namespace, env.elename.name)
- if env.header
- env.header.elename = XSD::QName.new(namespace, env.header.elename.name)
- end
- if env.body
- env.body.elename = XSD::QName.new(namespace, env.body.elename.name)
- end
- end
-
- def create_request_header
- headers = @headerhandler.on_outbound
- if headers.empty?
- nil
- else
- h = ::SOAP::SOAPHeader.new
- headers.each do |header|
- h.add(header.elename.name, header)
- end
- h
- end
- end
-
- def receive_headers(headers)
- @headerhandler.on_inbound(headers) if headers
- end
-
- def marshal(env, opt)
- send_string = Processor.marshal(env, opt)
- StreamHandler::ConnectionData.new(send_string)
- end
-
- def unmarshal(conn_data, opt)
- contenttype = conn_data.receive_contenttype
- if /#{MIMEMessage::MultipartContentType}/i =~ contenttype
- opt[:external_content] = {}
- mime = MIMEMessage.parse("Content-Type: " + contenttype,
- conn_data.receive_string)
- mime.parts.each do |part|
- value = Attachment.new(part.content)
- value.contentid = part.contentid
- obj = SOAPAttachment.new(value)
- opt[:external_content][value.contentid] = obj if value.contentid
- end
- opt[:charset] = @mandatorycharset ||
- StreamHandler.parse_media_type(mime.root.headers['content-type'].str)
- env = Processor.unmarshal(mime.root.content, opt)
- else
- opt[:charset] = @mandatorycharset ||
- ::SOAP::StreamHandler.parse_media_type(contenttype)
- env = Processor.unmarshal(conn_data.receive_string, opt)
- end
- unless env.is_a?(::SOAP::SOAPEnvelope)
- raise ResponseFormatError.new(
- "response is not a SOAP envelope: #{conn_data.receive_string}")
- end
- env
- end
-
- def create_header(headers)
- header = SOAPHeader.new()
- headers.each do |content, mustunderstand, encodingstyle|
- header.add(SOAPHeaderItem.new(content, mustunderstand, encodingstyle))
- end
- header
- end
-
- def create_encoding_opt(hash = nil)
- opt = {}
- opt[:default_encodingstyle] = @default_encodingstyle
- opt[:allow_unqualified_element] = @allow_unqualified_element
- opt[:generate_explicit_type] = @generate_explicit_type
- opt[:no_indent] = @options["soap.envelope.no_indent"]
- opt[:use_numeric_character_reference] =
- @options["soap.envelope.use_numeric_character_reference"]
- opt.update(hash) if hash
- opt
- end
-
- def create_mapping_opt(hash = nil)
- opt = {
- :external_ces => @options["soap.mapping.external_ces"]
- }
- opt.update(hash) if hash
- opt
- end
-
- class Operation
- attr_reader :soapaction
- attr_reader :request_style
- attr_reader :response_style
- attr_reader :request_use
- attr_reader :response_use
- attr_reader :elementformdefault
- attr_reader :attributeformdefault
-
- def initialize(soapaction, param_def, opt)
- @soapaction = soapaction
- @request_style = opt[:request_style]
- @response_style = opt[:response_style]
- @request_use = opt[:request_use]
- @response_use = opt[:response_use]
- # set nil(unqualified) by default
- @elementformdefault = opt[:elementformdefault]
- @attributeformdefault = opt[:attributeformdefault]
- check_style(@request_style)
- check_style(@response_style)
- check_use(@request_use)
- check_use(@response_use)
- if @request_style == :rpc
- @rpc_request_qname = opt[:request_qname]
- if @rpc_request_qname.nil?
- raise MethodDefinitionError.new("rpc_request_qname must be given")
- end
- @rpc_method_factory =
- RPC::SOAPMethodRequest.new(@rpc_request_qname, param_def, @soapaction)
- else
- @doc_request_qnames = []
- @doc_request_qualified = []
- @doc_response_qnames = []
- @doc_response_qualified = []
- param_def.each do |inout, paramname, typeinfo, eleinfo|
- klass_not_used, nsdef, namedef = typeinfo
- qualified = eleinfo
- if namedef.nil?
- raise MethodDefinitionError.new("qname must be given")
- end
- case inout
- when SOAPMethod::IN
- @doc_request_qnames << XSD::QName.new(nsdef, namedef)
- @doc_request_qualified << qualified
- when SOAPMethod::OUT
- @doc_response_qnames << XSD::QName.new(nsdef, namedef)
- @doc_response_qualified << qualified
- else
- raise MethodDefinitionError.new(
- "illegal inout definition for document style: #{inout}")
- end
- end
- end
- end
-
- def request_default_encodingstyle
- (@request_use == :encoded) ? EncodingNamespace : LiteralNamespace
- end
-
- def response_default_encodingstyle
- (@response_use == :encoded) ? EncodingNamespace : LiteralNamespace
- end
-
- def request_body(values, mapping_registry, literal_mapping_registry, opt)
- if @request_style == :rpc
- request_rpc(values, mapping_registry, literal_mapping_registry, opt)
- else
- request_doc(values, mapping_registry, literal_mapping_registry, opt)
- end
- end
-
- def response_obj(body, mapping_registry, literal_mapping_registry, opt)
- if @response_style == :rpc
- response_rpc(body, mapping_registry, literal_mapping_registry, opt)
- else
- response_doc(body, mapping_registry, literal_mapping_registry, opt)
- end
- end
-
- def raise_fault(e, mapping_registry, literal_mapping_registry)
- if @response_style == :rpc
- Mapping.fault2exception(e, mapping_registry)
- else
- Mapping.fault2exception(e, literal_mapping_registry)
- end
- end
-
- private
-
- def check_style(style)
- unless [:rpc, :document].include?(style)
- raise MethodDefinitionError.new("unknown style: #{style}")
- end
- end
-
- def check_use(use)
- unless [:encoded, :literal].include?(use)
- raise MethodDefinitionError.new("unknown use: #{use}")
- end
- end
-
- def request_rpc(values, mapping_registry, literal_mapping_registry, opt)
- if @request_use == :encoded
- request_rpc_enc(values, mapping_registry, opt)
- else
- request_rpc_lit(values, literal_mapping_registry, opt)
- end
- end
-
- def request_doc(values, mapping_registry, literal_mapping_registry, opt)
- if @request_use == :encoded
- request_doc_enc(values, mapping_registry, opt)
- else
- request_doc_lit(values, literal_mapping_registry, opt)
- end
- end
-
- def request_rpc_enc(values, mapping_registry, opt)
- method = @rpc_method_factory.dup
- names = method.input_params
- obj = create_request_obj(names, values)
- soap = Mapping.obj2soap(obj, mapping_registry, @rpc_request_qname, opt)
- method.set_param(soap)
- method
- end
-
- def request_rpc_lit(values, mapping_registry, opt)
- method = @rpc_method_factory.dup
- params = {}
- idx = 0
- method.input_params.each do |name|
- params[name] = Mapping.obj2soap(values[idx], mapping_registry,
- XSD::QName.new(nil, name), opt)
- idx += 1
- end
- method.set_param(params)
- method
- end
-
- def request_doc_enc(values, mapping_registry, opt)
- (0...values.size).collect { |idx|
- ele = Mapping.obj2soap(values[idx], mapping_registry, nil, opt)
- ele.elename = @doc_request_qnames[idx]
- ele
- }
- end
-
- def request_doc_lit(values, mapping_registry, opt)
- (0...values.size).collect { |idx|
- ele = Mapping.obj2soap(values[idx], mapping_registry,
- @doc_request_qnames[idx], opt)
- ele.encodingstyle = LiteralNamespace
- if ele.respond_to?(:qualified)
- ele.qualified = @doc_request_qualified[idx]
- end
- ele
- }
- end
-
- def response_rpc(body, mapping_registry, literal_mapping_registry, opt)
- if @response_use == :encoded
- response_rpc_enc(body, mapping_registry, opt)
- else
- response_rpc_lit(body, literal_mapping_registry, opt)
- end
- end
-
- def response_doc(body, mapping_registry, literal_mapping_registry, opt)
- if @response_use == :encoded
- return *response_doc_enc(body, mapping_registry, opt)
- else
- return *response_doc_lit(body, literal_mapping_registry, opt)
- end
- end
-
- def response_rpc_enc(body, mapping_registry, opt)
- ret = nil
- if body.response
- ret = Mapping.soap2obj(body.response, mapping_registry,
- @rpc_method_factory.retval_class_name, opt)
- end
- if body.outparams
- outparams = body.outparams.collect { |outparam|
- Mapping.soap2obj(outparam, mapping_registry, nil, opt)
- }
- [ret].concat(outparams)
- else
- ret
- end
- end
-
- def response_rpc_lit(body, mapping_registry, opt)
- body.root_node.collect { |key, value|
- Mapping.soap2obj(value, mapping_registry,
- @rpc_method_factory.retval_class_name, opt)
- }
- end
-
- def response_doc_enc(body, mapping_registry, opt)
- body.collect { |key, value|
- Mapping.soap2obj(value, mapping_registry, nil, opt)
- }
- end
-
- def response_doc_lit(body, mapping_registry, opt)
- body.collect { |key, value|
- Mapping.soap2obj(value, mapping_registry)
- }
- end
-
- def create_request_obj(names, params)
- o = Object.new
- idx = 0
- while idx < params.length
- o.instance_variable_set('@' + names[idx], params[idx])
- idx += 1
- end
- o
- end
- end
-end
-
-
-end
-end
diff --git a/ruby_1_8_6/lib/soap/rpc/router.rb b/ruby_1_8_6/lib/soap/rpc/router.rb
deleted file mode 100644
index 71c6eb625b..0000000000
--- a/ruby_1_8_6/lib/soap/rpc/router.rb
+++ /dev/null
@@ -1,594 +0,0 @@
-# SOAP4R - RPC Routing library
-# Copyright (C) 2001, 2002, 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 'soap/soap'
-require 'soap/processor'
-require 'soap/mapping'
-require 'soap/mapping/wsdlliteralregistry'
-require 'soap/rpc/rpc'
-require 'soap/rpc/element'
-require 'soap/streamHandler'
-require 'soap/mimemessage'
-require 'soap/header/handlerset'
-
-
-module SOAP
-module RPC
-
-
-class Router
- include SOAP
-
- attr_reader :actor
- attr_accessor :mapping_registry
- attr_accessor :literal_mapping_registry
- attr_accessor :generate_explicit_type
- attr_accessor :external_ces
-
- def initialize(actor)
- @actor = actor
- @mapping_registry = nil
- @headerhandler = Header::HandlerSet.new
- @literal_mapping_registry = ::SOAP::Mapping::WSDLLiteralRegistry.new
- @generate_explicit_type = true
- @external_ces = nil
- @operation_by_soapaction = {}
- @operation_by_qname = {}
- @headerhandlerfactory = []
- end
-
- ###
- ## header handler interface
- #
- def add_request_headerhandler(factory)
- unless factory.respond_to?(:create)
- raise TypeError.new("factory must respond to 'create'")
- end
- @headerhandlerfactory << factory
- end
-
- def add_headerhandler(handler)
- @headerhandler.add(handler)
- end
-
- ###
- ## servant definition interface
- #
- def add_rpc_request_servant(factory, namespace)
- unless factory.respond_to?(:create)
- raise TypeError.new("factory must respond to 'create'")
- end
- obj = factory.create # a dummy instance for introspection
- ::SOAP::RPC.defined_methods(obj).each do |name|
- begin
- qname = XSD::QName.new(namespace, name)
- param_def = ::SOAP::RPC::SOAPMethod.derive_rpc_param_def(obj, name)
- opt = create_styleuse_option(:rpc, :encoded)
- add_rpc_request_operation(factory, qname, nil, name, param_def, opt)
- rescue SOAP::RPC::MethodDefinitionError => e
- p e if $DEBUG
- end
- end
- end
-
- def add_rpc_servant(obj, namespace)
- ::SOAP::RPC.defined_methods(obj).each do |name|
- begin
- qname = XSD::QName.new(namespace, name)
- param_def = ::SOAP::RPC::SOAPMethod.derive_rpc_param_def(obj, name)
- opt = create_styleuse_option(:rpc, :encoded)
- add_rpc_operation(obj, qname, nil, name, param_def, opt)
- rescue SOAP::RPC::MethodDefinitionError => e
- p e if $DEBUG
- end
- end
- end
- alias add_servant add_rpc_servant
-
- ###
- ## operation definition interface
- #
- def add_rpc_operation(receiver, qname, soapaction, name, param_def, opt = {})
- ensure_styleuse_option(opt, :rpc, :encoded)
- opt[:request_qname] = qname
- op = ApplicationScopeOperation.new(soapaction, receiver, name, param_def,
- opt)
- if opt[:request_style] != :rpc
- raise RPCRoutingError.new("illegal request_style given")
- end
- assign_operation(soapaction, qname, op)
- end
- alias add_method add_rpc_operation
- alias add_rpc_method add_rpc_operation
-
- def add_rpc_request_operation(factory, qname, soapaction, name, param_def, opt = {})
- ensure_styleuse_option(opt, :rpc, :encoded)
- opt[:request_qname] = qname
- op = RequestScopeOperation.new(soapaction, factory, name, param_def, opt)
- if opt[:request_style] != :rpc
- raise RPCRoutingError.new("illegal request_style given")
- end
- assign_operation(soapaction, qname, op)
- end
-
- def add_document_operation(receiver, soapaction, name, param_def, opt = {})
- #
- # adopt workaround for doc/lit wrapper method
- # (you should consider to simply use rpc/lit service)
- #
- #unless soapaction
- # raise RPCRoutingError.new("soapaction is a must for document method")
- #end
- ensure_styleuse_option(opt, :document, :literal)
- op = ApplicationScopeOperation.new(soapaction, receiver, name, param_def,
- opt)
- if opt[:request_style] != :document
- raise RPCRoutingError.new("illegal request_style given")
- end
- assign_operation(soapaction, first_input_part_qname(param_def), op)
- end
- alias add_document_method add_document_operation
-
- def add_document_request_operation(factory, soapaction, name, param_def, opt = {})
- #
- # adopt workaround for doc/lit wrapper method
- # (you should consider to simply use rpc/lit service)
- #
- #unless soapaction
- # raise RPCRoutingError.new("soapaction is a must for document method")
- #end
- ensure_styleuse_option(opt, :document, :literal)
- op = RequestScopeOperation.new(soapaction, receiver, name, param_def, opt)
- if opt[:request_style] != :document
- raise RPCRoutingError.new("illegal request_style given")
- end
- assign_operation(soapaction, first_input_part_qname(param_def), op)
- end
-
- def route(conn_data)
- # we cannot set request_default_encodingsyle before parsing the content.
- env = unmarshal(conn_data)
- if env.nil?
- raise ArgumentError.new("illegal SOAP marshal format")
- end
- op = lookup_operation(conn_data.soapaction, env.body)
- headerhandler = @headerhandler.dup
- @headerhandlerfactory.each do |f|
- headerhandler.add(f.create)
- end
- receive_headers(headerhandler, env.header)
- soap_response = default_encodingstyle = nil
- begin
- soap_response =
- op.call(env.body, @mapping_registry, @literal_mapping_registry,
- create_mapping_opt)
- default_encodingstyle = op.response_default_encodingstyle
- rescue Exception
- soap_response = fault($!)
- default_encodingstyle = nil
- end
- conn_data.is_fault = true if soap_response.is_a?(SOAPFault)
- header = call_headers(headerhandler)
- body = SOAPBody.new(soap_response)
- env = SOAPEnvelope.new(header, body)
- marshal(conn_data, env, default_encodingstyle)
- end
-
- # Create fault response string.
- def create_fault_response(e)
- env = SOAPEnvelope.new(SOAPHeader.new, SOAPBody.new(fault(e)))
- opt = {}
- opt[:external_content] = nil
- response_string = Processor.marshal(env, opt)
- conn_data = StreamHandler::ConnectionData.new(response_string)
- conn_data.is_fault = true
- if ext = opt[:external_content]
- mimeize(conn_data, ext)
- end
- conn_data
- end
-
-private
-
- def first_input_part_qname(param_def)
- param_def.each do |inout, paramname, typeinfo|
- if inout == SOAPMethod::IN
- klass, nsdef, namedef = typeinfo
- return XSD::QName.new(nsdef, namedef)
- end
- end
- nil
- end
-
- def create_styleuse_option(style, use)
- opt = {}
- opt[:request_style] = opt[:response_style] = style
- opt[:request_use] = opt[:response_use] = use
- opt
- end
-
- def ensure_styleuse_option(opt, style, use)
- opt[:request_style] ||= style
- opt[:response_style] ||= style
- opt[:request_use] ||= use
- opt[:response_use] ||= use
- end
-
- def assign_operation(soapaction, qname, op)
- assigned = false
- if soapaction and !soapaction.empty?
- @operation_by_soapaction[soapaction] = op
- assigned = true
- end
- if qname
- @operation_by_qname[qname] = op
- assigned = true
- end
- unless assigned
- raise RPCRoutingError.new("cannot assign operation")
- end
- end
-
- def lookup_operation(soapaction, body)
- if op = @operation_by_soapaction[soapaction]
- return op
- end
- qname = body.root_node.elename
- if op = @operation_by_qname[qname]
- return op
- end
- if soapaction
- raise RPCRoutingError.new(
- "operation: #{soapaction} #{qname} not supported")
- else
- raise RPCRoutingError.new("operation: #{qname} not supported")
- end
- end
-
- def call_headers(headerhandler)
- headers = headerhandler.on_outbound
- if headers.empty?
- nil
- else
- h = ::SOAP::SOAPHeader.new
- headers.each do |header|
- h.add(header.elename.name, header)
- end
- h
- end
- end
-
- def receive_headers(headerhandler, headers)
- headerhandler.on_inbound(headers) if headers
- end
-
- def unmarshal(conn_data)
- opt = {}
- contenttype = conn_data.receive_contenttype
- if /#{MIMEMessage::MultipartContentType}/i =~ contenttype
- opt[:external_content] = {}
- mime = MIMEMessage.parse("Content-Type: " + contenttype,
- conn_data.receive_string)
- mime.parts.each do |part|
- value = Attachment.new(part.content)
- value.contentid = part.contentid
- obj = SOAPAttachment.new(value)
- opt[:external_content][value.contentid] = obj if value.contentid
- end
- opt[:charset] =
- StreamHandler.parse_media_type(mime.root.headers['content-type'].str)
- env = Processor.unmarshal(mime.root.content, opt)
- else
- opt[:charset] = ::SOAP::StreamHandler.parse_media_type(contenttype)
- env = Processor.unmarshal(conn_data.receive_string, opt)
- end
- charset = opt[:charset]
- conn_data.send_contenttype = "text/xml; charset=\"#{charset}\""
- env
- end
-
- def marshal(conn_data, env, default_encodingstyle = nil)
- opt = {}
- opt[:external_content] = nil
- opt[:default_encodingstyle] = default_encodingstyle
- opt[:generate_explicit_type] = @generate_explicit_type
- response_string = Processor.marshal(env, opt)
- conn_data.send_string = response_string
- if ext = opt[:external_content]
- mimeize(conn_data, ext)
- end
- conn_data
- end
-
- def mimeize(conn_data, ext)
- mime = MIMEMessage.new
- ext.each do |k, v|
- mime.add_attachment(v.data)
- end
- mime.add_part(conn_data.send_string + "\r\n")
- mime.close
- conn_data.send_string = mime.content_str
- conn_data.send_contenttype = mime.headers['content-type'].str
- conn_data
- end
-
- # Create fault response.
- def fault(e)
- detail = Mapping::SOAPException.new(e)
- SOAPFault.new(
- SOAPString.new('Server'),
- SOAPString.new(e.to_s),
- SOAPString.new(@actor),
- Mapping.obj2soap(detail, @mapping_registry))
- end
-
- def create_mapping_opt
- { :external_ces => @external_ces }
- end
-
- class Operation
- attr_reader :name
- attr_reader :soapaction
- attr_reader :request_style
- attr_reader :response_style
- attr_reader :request_use
- attr_reader :response_use
-
- def initialize(soapaction, name, param_def, opt)
- @soapaction = soapaction
- @name = name
- @request_style = opt[:request_style]
- @response_style = opt[:response_style]
- @request_use = opt[:request_use]
- @response_use = opt[:response_use]
- check_style(@request_style)
- check_style(@response_style)
- check_use(@request_use)
- check_use(@response_use)
- if @response_style == :rpc
- request_qname = opt[:request_qname] or raise
- @rpc_method_factory =
- RPC::SOAPMethodRequest.new(request_qname, param_def, @soapaction)
- @rpc_response_qname = opt[:response_qname]
- else
- @doc_request_qnames = []
- @doc_request_qualified = []
- @doc_response_qnames = []
- @doc_response_qualified = []
- param_def.each do |inout, paramname, typeinfo, eleinfo|
- klass, nsdef, namedef = typeinfo
- qualified = eleinfo
- case inout
- when SOAPMethod::IN
- @doc_request_qnames << XSD::QName.new(nsdef, namedef)
- @doc_request_qualified << qualified
- when SOAPMethod::OUT
- @doc_response_qnames << XSD::QName.new(nsdef, namedef)
- @doc_response_qualified << qualified
- else
- raise ArgumentError.new(
- "illegal inout definition for document style: #{inout}")
- end
- end
- end
- end
-
- def request_default_encodingstyle
- (@request_use == :encoded) ? EncodingNamespace : LiteralNamespace
- end
-
- def response_default_encodingstyle
- (@response_use == :encoded) ? EncodingNamespace : LiteralNamespace
- end
-
- def call(body, mapping_registry, literal_mapping_registry, opt)
- if @request_style == :rpc
- values = request_rpc(body, mapping_registry, literal_mapping_registry,
- opt)
- else
- values = request_document(body, mapping_registry,
- literal_mapping_registry, opt)
- end
- result = receiver.method(@name.intern).call(*values)
- return result if result.is_a?(SOAPFault)
- if @response_style == :rpc
- response_rpc(result, mapping_registry, literal_mapping_registry, opt)
- else
- response_doc(result, mapping_registry, literal_mapping_registry, opt)
- end
- end
-
- private
-
- def receiver
- raise NotImplementedError.new('must be defined in derived class')
- end
-
- def request_rpc(body, mapping_registry, literal_mapping_registry, opt)
- request = body.request
- unless request.is_a?(SOAPStruct)
- raise RPCRoutingError.new("not an RPC style")
- end
- if @request_use == :encoded
- request_rpc_enc(request, mapping_registry, opt)
- else
- request_rpc_lit(request, literal_mapping_registry, opt)
- end
- end
-
- def request_document(body, mapping_registry, literal_mapping_registry, opt)
- # ToDo: compare names with @doc_request_qnames
- if @request_use == :encoded
- request_doc_enc(body, mapping_registry, opt)
- else
- request_doc_lit(body, literal_mapping_registry, opt)
- end
- end
-
- def request_rpc_enc(request, mapping_registry, opt)
- param = Mapping.soap2obj(request, mapping_registry, nil, opt)
- request.collect { |key, value|
- param[key]
- }
- end
-
- def request_rpc_lit(request, mapping_registry, opt)
- request.collect { |key, value|
- Mapping.soap2obj(value, mapping_registry, nil, opt)
- }
- end
-
- def request_doc_enc(body, mapping_registry, opt)
- body.collect { |key, value|
- Mapping.soap2obj(value, mapping_registry, nil, opt)
- }
- end
-
- def request_doc_lit(body, mapping_registry, opt)
- body.collect { |key, value|
- Mapping.soap2obj(value, mapping_registry, nil, opt)
- }
- end
-
- def response_rpc(result, mapping_registry, literal_mapping_registry, opt)
- if @response_use == :encoded
- response_rpc_enc(result, mapping_registry, opt)
- else
- response_rpc_lit(result, literal_mapping_registry, opt)
- end
- end
-
- def response_doc(result, mapping_registry, literal_mapping_registry, opt)
- if @doc_response_qnames.size == 1 and !result.is_a?(Array)
- result = [result]
- end
- if result.size != @doc_response_qnames.size
- raise "required #{@doc_response_qnames.size} responses " +
- "but #{result.size} given"
- end
- if @response_use == :encoded
- response_doc_enc(result, mapping_registry, opt)
- else
- response_doc_lit(result, literal_mapping_registry, opt)
- end
- end
-
- def response_rpc_enc(result, mapping_registry, opt)
- soap_response =
- @rpc_method_factory.create_method_response(@rpc_response_qname)
- if soap_response.have_outparam?
- unless result.is_a?(Array)
- raise RPCRoutingError.new("out parameter was not returned")
- end
- outparams = {}
- i = 1
- soap_response.output_params.each do |outparam|
- outparams[outparam] = Mapping.obj2soap(result[i], mapping_registry,
- nil, opt)
- i += 1
- end
- soap_response.set_outparam(outparams)
- soap_response.retval = Mapping.obj2soap(result[0], mapping_registry,
- nil, opt)
- else
- soap_response.retval = Mapping.obj2soap(result, mapping_registry, nil,
- opt)
- end
- soap_response
- end
-
- def response_rpc_lit(result, mapping_registry, opt)
- soap_response =
- @rpc_method_factory.create_method_response(@rpc_response_qname)
- if soap_response.have_outparam?
- unless result.is_a?(Array)
- raise RPCRoutingError.new("out parameter was not returned")
- end
- outparams = {}
- i = 1
- soap_response.output_params.each do |outparam|
- outparams[outparam] = Mapping.obj2soap(result[i], mapping_registry,
- XSD::QName.new(nil, outparam), opt)
- i += 1
- end
- soap_response.set_outparam(outparams)
- soap_response.retval = Mapping.obj2soap(result[0], mapping_registry,
- XSD::QName.new(nil, soap_response.elename), opt)
- else
- soap_response.retval = Mapping.obj2soap(result, mapping_registry,
- XSD::QName.new(nil, soap_response.elename), opt)
- end
- soap_response
- end
-
- def response_doc_enc(result, mapping_registry, opt)
- (0...result.size).collect { |idx|
- ele = Mapping.obj2soap(result[idx], mapping_registry, nil, opt)
- ele.elename = @doc_response_qnames[idx]
- ele
- }
- end
-
- def response_doc_lit(result, mapping_registry, opt)
- (0...result.size).collect { |idx|
- ele = Mapping.obj2soap(result[idx], mapping_registry,
- @doc_response_qnames[idx])
- ele.encodingstyle = LiteralNamespace
- if ele.respond_to?(:qualified)
- ele.qualified = @doc_response_qualified[idx]
- end
- ele
- }
- end
-
- def check_style(style)
- unless [:rpc, :document].include?(style)
- raise ArgumentError.new("unknown style: #{style}")
- end
- end
-
- def check_use(use)
- unless [:encoded, :literal].include?(use)
- raise ArgumentError.new("unknown use: #{use}")
- end
- end
- end
-
- class ApplicationScopeOperation < Operation
- def initialize(soapaction, receiver, name, param_def, opt)
- super(soapaction, name, param_def, opt)
- @receiver = receiver
- end
-
- private
-
- def receiver
- @receiver
- end
- end
-
- class RequestScopeOperation < Operation
- def initialize(soapaction, receiver_factory, name, param_def, opt)
- super(soapaction, name, param_def, opt)
- unless receiver_factory.respond_to?(:create)
- raise TypeError.new("factory must respond to 'create'")
- end
- @receiver_factory = receiver_factory
- end
-
- private
-
- def receiver
- @receiver_factory.create
- end
- end
-end
-
-
-end
-end
diff --git a/ruby_1_8_6/lib/soap/rpc/rpc.rb b/ruby_1_8_6/lib/soap/rpc/rpc.rb
deleted file mode 100644
index a48b525dbb..0000000000
--- a/ruby_1_8_6/lib/soap/rpc/rpc.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-# SOAP4R - RPC utility.
-# 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.
-
-
-module SOAP
-
-
-module RPC
- ServerException = Mapping::MappedException
-
- def self.defined_methods(obj)
- if obj.is_a?(Module)
- obj.methods - Module.methods
- else
- obj.methods - Object.instance_methods(true)
- end
- end
-end
-
-
-end
diff --git a/ruby_1_8_6/lib/soap/rpc/soaplet.rb b/ruby_1_8_6/lib/soap/rpc/soaplet.rb
deleted file mode 100644
index 7cccdd3e31..0000000000
--- a/ruby_1_8_6/lib/soap/rpc/soaplet.rb
+++ /dev/null
@@ -1,162 +0,0 @@
-# SOAP4R - SOAP handler servlet for WEBrick
-# Copyright (C) 2001-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 'webrick/httpservlet/abstract'
-require 'webrick/httpstatus'
-require 'soap/rpc/router'
-require 'soap/streamHandler'
-begin
- require 'stringio'
- require 'zlib'
-rescue LoadError
- warn("Loading stringio or zlib failed. No gzipped response supported.") if $DEBUG
-end
-
-
-warn("Overriding WEBrick::Log#debug") if $DEBUG
-require 'webrick/log'
-module WEBrick
- class Log < BasicLog
- alias __debug debug
- def debug(msg = nil)
- if block_given? and msg.nil?
- __debug(yield)
- else
- __debug(msg)
- end
- end
- end
-end
-
-
-module SOAP
-module RPC
-
-
-class SOAPlet < WEBrick::HTTPServlet::AbstractServlet
-public
- attr_reader :options
-
- def initialize(router = nil)
- @router = router || ::SOAP::RPC::Router.new(self.class.name)
- @options = {}
- @config = {}
- end
-
- # for backward compatibility
- def app_scope_router
- @router
- end
-
- # for backward compatibility
- def add_servant(obj, namespace)
- @router.add_rpc_servant(obj, namespace)
- end
-
- def allow_content_encoding_gzip=(allow)
- @options[:allow_content_encoding_gzip] = allow
- end
-
- ###
- ## Servlet interfaces for WEBrick.
- #
- def get_instance(config, *options)
- @config = config
- self
- end
-
- def require_path_info?
- false
- end
-
- def do_GET(req, res)
- res.header['Allow'] = 'POST'
- raise WEBrick::HTTPStatus::MethodNotAllowed, "GET request not allowed"
- end
-
- def do_POST(req, res)
- logger.debug { "SOAP request: " + req.body } if logger
- begin
- conn_data = ::SOAP::StreamHandler::ConnectionData.new
- setup_req(conn_data, req)
- @router.external_ces = @options[:external_ces]
- conn_data = @router.route(conn_data)
- setup_res(conn_data, req, res)
- rescue Exception => e
- conn_data = @router.create_fault_response(e)
- res.status = WEBrick::HTTPStatus::RC_INTERNAL_SERVER_ERROR
- res.body = conn_data.send_string
- res['content-type'] = conn_data.send_contenttype || "text/xml"
- end
- if res.body.is_a?(IO)
- res.chunked = true
- logger.debug { "SOAP response: (chunked response not logged)" } if logger
- else
- logger.debug { "SOAP response: " + res.body } if logger
- end
- end
-
-private
-
- def logger
- @config[:Logger]
- end
-
- def setup_req(conn_data, req)
- conn_data.receive_string = req.body
- conn_data.receive_contenttype = req['content-type']
- conn_data.soapaction = parse_soapaction(req.meta_vars['HTTP_SOAPACTION'])
- end
-
- def setup_res(conn_data, req, res)
- res['content-type'] = conn_data.send_contenttype
- if conn_data.is_fault
- res.status = WEBrick::HTTPStatus::RC_INTERNAL_SERVER_ERROR
- end
- if outstring = encode_gzip(req, conn_data.send_string)
- res['content-encoding'] = 'gzip'
- res['content-length'] = outstring.size
- res.body = outstring
- else
- res.body = conn_data.send_string
- end
- end
-
- def parse_soapaction(soapaction)
- if !soapaction.nil? and !soapaction.empty?
- if /^"(.+)"$/ =~ soapaction
- return $1
- end
- end
- nil
- end
-
- def encode_gzip(req, outstring)
- unless encode_gzip?(req)
- return nil
- end
- begin
- ostream = StringIO.new
- gz = Zlib::GzipWriter.new(ostream)
- gz.write(outstring)
- ostream.string
- ensure
- gz.close
- end
- end
-
- def encode_gzip?(req)
- @options[:allow_content_encoding_gzip] and defined?(::Zlib) and
- req['accept-encoding'] and
- req['accept-encoding'].split(/,\s*/).include?('gzip')
- end
-end
-
-
-end
-end
diff --git a/ruby_1_8_6/lib/soap/rpc/standaloneServer.rb b/ruby_1_8_6/lib/soap/rpc/standaloneServer.rb
deleted file mode 100644
index 080343ba33..0000000000
--- a/ruby_1_8_6/lib/soap/rpc/standaloneServer.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-# SOAP4R - WEBrick Server
-# Copyright (C) 2003 by NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
-
-# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
-# redistribute it and/or modify it under the same terms of Ruby's license;
-# either the dual license version in 2003, or any later version.
-
-
-require 'soap/rpc/httpserver'
-
-
-module SOAP
-module RPC
-
-
-class StandaloneServer < HTTPServer
- def initialize(appname, default_namespace, host = "0.0.0.0", port = 8080)
- @appname = appname
- @default_namespace = default_namespace
- @host = host
- @port = port
- super(create_config)
- end
-
- alias add_servant add_rpc_servant
- alias add_headerhandler add_rpc_headerhandler
-
-private
-
- def create_config
- {
- :BindAddress => @host,
- :Port => @port,
- :AccessLog => [],
- :SOAPDefaultNamespace => @default_namespace,
- :SOAPHTTPServerApplicationName => @appname,
- }
- end
-end
-
-
-end
-end