1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/lib/soap/rpc/standaloneServer.rb
nahi 9cba39a1a1 * lib/soap/baseData.rb: Introduce SOAPType as the common ancestor of
SOAPBasetype and SOAPCompoundtype.

* lib/soap/generator.rb, lib/soap/element.rb, lib/soap/encodingstyle/*:
  Encoding methods signature change.  Pass SOAPGenerator as a parameter.

* lib/soap/mapping/*, test/soap/marshal/test_marshal.rb: Refactoring for better
  marshalling/unmarshalling support.  Now I think SOAP marshaller supports all
  kind of object graph which is supported by Ruby's original marshaller.  Of
  course there could be bugs as always.  Find it.  :-)

* lib/soap/rpc/standaloneServer.rb: Set severity threshould to INFO.  DEBUG is
  too noisy.

* lib/xsd/datatypes.rb: DateTime#of is obsoleted.  Use DateTime#offset.

* test/wsdl/emptycomplextype.wsdl, test/xsd/xmlschema.xml: Avoid useless
  warning.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-10-14 15:14:02 +00:00

118 lines
3 KiB
Ruby

=begin
SOAP4R - WEBrick Server
Copyright (C) 2003 by NAKAMURA, Hiroshi
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PRATICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 675 Mass
Ave, Cambridge, MA 02139, USA.
=end
require 'logger'
require 'soap/rpc/soaplet'
require 'soap/streamHandler'
# require 'webrick'
require 'webrick/compat.rb'
require 'webrick/version.rb'
require 'webrick/config.rb'
require 'webrick/log.rb'
require 'webrick/server.rb'
require 'webrick/utils.rb'
require 'webrick/accesslog'
# require 'webrick/htmlutils.rb'
require 'webrick/httputils.rb'
# require 'webrick/cookie.rb'
require 'webrick/httpversion.rb'
require 'webrick/httpstatus.rb'
require 'webrick/httprequest.rb'
require 'webrick/httpresponse.rb'
require 'webrick/httpserver.rb'
# require 'webrick/httpservlet.rb'
# require 'webrick/httpauth.rb'
module SOAP
module RPC
class StandaloneServer < Logger::Application
attr_reader :server
def initialize(app_name, namespace, host = "0.0.0.0", port = 8080)
super(app_name)
self.level = Logger::Severity::INFO
@namespace = namespace
@host = host
@port = port
@server = nil
@soaplet = ::SOAP::RPC::SOAPlet.new
on_init
end
def on_init
# define extra methods in derived class.
end
def add_rpc_request_servant(klass, namespace = @namespace, mapping_registry = nil)
@soaplet.add_rpc_request_servant(klass, namespace, mapping_registry)
end
def add_rpc_servant(obj, namespace = @namespace)
@soaplet.add_rpc_servant(obj, namespace)
end
alias add_servant add_rpc_servant
def mapping_registry
@soaplet.app_scope_router.mapping_registry
end
def mapping_registry=(mapping_registry)
@soaplet.app_scope_router.mapping_registry = mapping_registry
end
def add_method(obj, name, *param)
add_method_as(obj, name, name, *param)
end
def add_method_as(obj, name, name_as, *param)
qname = XSD::QName.new(@namespace, name_as)
soapaction = nil
method = obj.method(name)
param_def = if param.size == 1 and param[0].is_a?(Array)
param[0]
elsif param.empty?
::SOAP::RPC::SOAPMethod.create_param_def(
(1..method.arity.abs).collect { |i| "p#{ i }" })
else
SOAP::RPC::SOAPMethod.create_param_def(param)
end
@soaplet.app_scope_router.add_method(obj, qname, soapaction, name, param_def)
end
private
def run
@server = WEBrick::HTTPServer.new(
:BindAddress => @host,
:Logger => @log,
:AccessLog => [],
:Port => @port
)
@server.mount('/', @soaplet)
@server.start
end
end
end
end