mongrel-soap4r 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +19 -0
- data/README +1 -0
- data/Rakefile +30 -0
- data/lib/mongrel-soap/rpc/httpserver.rb +131 -0
- data/lib/mongrel-soap/rpc/standaloneServer.rb +31 -0
- data/lib/mongrel/soap4r.rb +70 -0
- metadata +54 -0
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2007 Jared Hanson
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
= mongrel-soap4r
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/gempackagetask'
|
4
|
+
require 'rake/clean'
|
5
|
+
|
6
|
+
PKG_NAME = 'mongrel-soap4r'
|
7
|
+
PKG_VERSION = '0.0.1'
|
8
|
+
|
9
|
+
|
10
|
+
PKG_FILES = FileList[
|
11
|
+
'[A-Z]*',
|
12
|
+
'lib/**/*'
|
13
|
+
]
|
14
|
+
|
15
|
+
spec = Gem::Specification.new do |s|
|
16
|
+
s.name = PKG_NAME
|
17
|
+
s.version = PKG_VERSION
|
18
|
+
s.summary = "Host SOAP web services using Mongrel as the underlying HTTP server."
|
19
|
+
|
20
|
+
s.files = PKG_FILES
|
21
|
+
|
22
|
+
s.author = "Jared Hanson"
|
23
|
+
s.email = "jaredhanson@gmail.com"
|
24
|
+
s.homepage = "http://mongrel-soap4r.rubyforge.org/"
|
25
|
+
s.rubyforge_project = "mongrel-soap4r"
|
26
|
+
end
|
27
|
+
|
28
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
29
|
+
pkg.gem_spec = spec
|
30
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'mongrel'
|
3
|
+
require 'mongrel/soap4r'
|
4
|
+
require 'soap/rpc/router'
|
5
|
+
|
6
|
+
|
7
|
+
module MongrelSOAP
|
8
|
+
module RPC
|
9
|
+
|
10
|
+
|
11
|
+
class HTTPServer < Logger::Application
|
12
|
+
attr_reader :server
|
13
|
+
attr_accessor :default_namespace
|
14
|
+
|
15
|
+
def initialize(config)
|
16
|
+
actor = config[:SOAPHTTPServerApplicationName] || self.class.name
|
17
|
+
super(actor)
|
18
|
+
|
19
|
+
@default_namespace = config[:SOAPDefaultNamespace]
|
20
|
+
|
21
|
+
@router = ::SOAP::RPC::Router.new(actor)
|
22
|
+
on_init
|
23
|
+
|
24
|
+
@server = Mongrel::HttpServer.new(config[:BindAddress], config[:Port])
|
25
|
+
@server.register("/", Mongrel::SOAP4RHandler.new(@router))
|
26
|
+
if wsdl_dir = config[:WSDLDocumentDirectory]
|
27
|
+
@server.register('/wsdl', Mongrel::DirHandler.new(wsdl_dir))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def on_init
|
32
|
+
end
|
33
|
+
|
34
|
+
def shutdown
|
35
|
+
@server.stop if @server
|
36
|
+
end
|
37
|
+
|
38
|
+
def mapping_registry
|
39
|
+
@router.mapping_registry
|
40
|
+
end
|
41
|
+
|
42
|
+
def mapping_registry=(mapping_registry)
|
43
|
+
@router.mapping_registry = mapping_registry
|
44
|
+
end
|
45
|
+
|
46
|
+
def literal_mapping_registry
|
47
|
+
@router.literal_mapping_registry
|
48
|
+
end
|
49
|
+
|
50
|
+
def literal_mapping_registry=(literal_mapping_registry)
|
51
|
+
@router.literal_mapping_registry = literal_mapping_registry
|
52
|
+
end
|
53
|
+
|
54
|
+
def generate_explicit_type
|
55
|
+
@router.generate_explicit_type
|
56
|
+
end
|
57
|
+
|
58
|
+
def generate_explicit_type=(generate_explicit_type)
|
59
|
+
@router.generate_explicit_type = generate_explicit_type
|
60
|
+
end
|
61
|
+
|
62
|
+
# servant entry interface
|
63
|
+
|
64
|
+
def add_rpc_request_servant(factory, namespace = @default_namespace)
|
65
|
+
@router.add_rpc_request_servant(factory, namespace)
|
66
|
+
end
|
67
|
+
|
68
|
+
def add_rpc_servant(obj, namespace = @default_namespace)
|
69
|
+
@router.add_rpc_servant(obj, namespace)
|
70
|
+
end
|
71
|
+
alias add_servant add_rpc_servant
|
72
|
+
|
73
|
+
def add_request_headerhandler(factory)
|
74
|
+
@router.add_request_headerhandler(factory)
|
75
|
+
end
|
76
|
+
|
77
|
+
def add_headerhandler(obj)
|
78
|
+
@router.add_headerhandler(obj)
|
79
|
+
end
|
80
|
+
alias add_rpc_headerhandler add_headerhandler
|
81
|
+
|
82
|
+
def filterchain
|
83
|
+
@router.filterchain
|
84
|
+
end
|
85
|
+
|
86
|
+
# method entry interface
|
87
|
+
|
88
|
+
def add_rpc_method(obj, name, *param)
|
89
|
+
add_rpc_method_as(obj, name, name, *param)
|
90
|
+
end
|
91
|
+
alias add_method add_rpc_method
|
92
|
+
|
93
|
+
def add_rpc_method_as(obj, name, name_as, *param)
|
94
|
+
qname = XSD::QName.new(@default_namespace, name_as)
|
95
|
+
soapaction = nil
|
96
|
+
param_def = ::SOAP::RPC::SOAPMethod.derive_rpc_param_def(obj, name, *param)
|
97
|
+
@router.add_rpc_operation(obj, qname, soapaction, name, param_def)
|
98
|
+
end
|
99
|
+
alias add_method_as add_rpc_method_as
|
100
|
+
|
101
|
+
def add_document_method(obj, soapaction, name, req_qnames, res_qnames)
|
102
|
+
param_def = SOAPMethod.create_doc_param_def(req_qnames, res_qnames)
|
103
|
+
@router.add_document_operation(obj, soapaction, name, param_def)
|
104
|
+
end
|
105
|
+
|
106
|
+
def add_rpc_operation(receiver, qname, soapaction, name, param_def, opt = {})
|
107
|
+
@router.add_rpc_operation(receiver, qname, soapaction, name, param_def, opt)
|
108
|
+
end
|
109
|
+
|
110
|
+
def add_rpc_request_operation(factory, qname, soapaction, name, param_def, opt = {})
|
111
|
+
@router.add_rpc_request_operation(factory, qname, soapaction, name, param_def, opt)
|
112
|
+
end
|
113
|
+
|
114
|
+
def add_document_operation(receiver, soapaction, name, param_def, opt = {})
|
115
|
+
@router.add_document_operation(receiver, soapaction, name, param_def, opt)
|
116
|
+
end
|
117
|
+
|
118
|
+
def add_document_request_operation(factory, soapaction, name, param_def, opt = {})
|
119
|
+
@router.add_document_request_operation(factory, soapaction, name, param_def, opt)
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
private
|
124
|
+
def run
|
125
|
+
@server.run.join
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'mongrel-soap/rpc/httpserver'
|
2
|
+
|
3
|
+
|
4
|
+
module MongrelSOAP
|
5
|
+
module RPC
|
6
|
+
|
7
|
+
|
8
|
+
class StandaloneServer < HTTPServer
|
9
|
+
|
10
|
+
def initialize(appname, default_namespace, host = "0.0.0.0", port = 8080)
|
11
|
+
@appname = appname
|
12
|
+
@default_namespace = default_namespace
|
13
|
+
@host = host
|
14
|
+
@port = port
|
15
|
+
super(create_config)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def create_config
|
20
|
+
{
|
21
|
+
:BindAddress => @host,
|
22
|
+
:Port => @port,
|
23
|
+
:SOAPHTTPServerApplicationName => @appname,
|
24
|
+
:SOAPDefaultNamespace => @default_namespace
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'mongrel'
|
2
|
+
require 'soap/rpc/router'
|
3
|
+
require 'soap/streamHandler'
|
4
|
+
|
5
|
+
|
6
|
+
module Mongrel
|
7
|
+
|
8
|
+
class SOAP4RHandler < HttpHandler
|
9
|
+
|
10
|
+
POST = "POST".freeze
|
11
|
+
ALLOW = "Allow".freeze
|
12
|
+
|
13
|
+
MONGREL_CONTENT_TYPE = "HTTP_CONTENT_TYPE".freeze
|
14
|
+
MONGREL_SOAP_ACTION = "HTTP_SOAPACTION".freeze
|
15
|
+
|
16
|
+
|
17
|
+
def initialize(router = nil)
|
18
|
+
@router = router || ::SOAP::RPC::Router.new(self.class.name)
|
19
|
+
end
|
20
|
+
|
21
|
+
def process(request, response)
|
22
|
+
req_method = request.params[Const::REQUEST_METHOD]
|
23
|
+
|
24
|
+
if req_method != POST
|
25
|
+
response.start(405) do |head,out|
|
26
|
+
head[ALLOW] = POST
|
27
|
+
out.write(HTTP_STATUS_CODES[405])
|
28
|
+
end
|
29
|
+
return
|
30
|
+
end
|
31
|
+
|
32
|
+
begin
|
33
|
+
conn_data = ::SOAP::StreamHandler::ConnectionData.new
|
34
|
+
setup_req(conn_data, request)
|
35
|
+
conn_data = @router.route(conn_data)
|
36
|
+
|
37
|
+
status = conn_data.is_fault ? 500 : 200
|
38
|
+
response.start(status) do |head,out|
|
39
|
+
head[Const::CONTENT_TYPE] = conn_data.send_contenttype
|
40
|
+
out.write(conn_data.send_string)
|
41
|
+
end
|
42
|
+
rescue Exception => e
|
43
|
+
conn_data = @router.create_fault_response(e)
|
44
|
+
response.start(500) do |head,out|
|
45
|
+
head[Const::CONTENT_TYPE] = conn_data.send_contenttype || "text/xml"
|
46
|
+
out.write(conn_data.send_string)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
def setup_req(conn_data, req)
|
54
|
+
conn_data.receive_string = req.body
|
55
|
+
conn_data.receive_contenttype = req.params[MONGREL_CONTENT_TYPE]
|
56
|
+
conn_data.soapaction = parse_soapaction(req.params[MONGREL_SOAP_ACTION])
|
57
|
+
end
|
58
|
+
|
59
|
+
def parse_soapaction(soapaction)
|
60
|
+
if !soapaction.nil? and !soapaction.empty?
|
61
|
+
if /^"(.+)"$/ =~ soapaction
|
62
|
+
return $1
|
63
|
+
end
|
64
|
+
end
|
65
|
+
nil
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.4
|
3
|
+
specification_version: 1
|
4
|
+
name: mongrel-soap4r
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.0.1
|
7
|
+
date: 2007-07-16 00:00:00 -07:00
|
8
|
+
summary: Host SOAP web services using Mongrel as the underlying HTTP server.
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: jaredhanson@gmail.com
|
12
|
+
homepage: http://mongrel-soap4r.rubyforge.org/
|
13
|
+
rubyforge_project: mongrel-soap4r
|
14
|
+
description:
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: false
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Jared Hanson
|
31
|
+
files:
|
32
|
+
- LICENSE
|
33
|
+
- Rakefile
|
34
|
+
- README
|
35
|
+
- lib/mongrel
|
36
|
+
- lib/mongrel-soap
|
37
|
+
- lib/mongrel/soap4r.rb
|
38
|
+
- lib/mongrel-soap/rpc
|
39
|
+
- lib/mongrel-soap/rpc/httpserver.rb
|
40
|
+
- lib/mongrel-soap/rpc/standaloneServer.rb
|
41
|
+
test_files: []
|
42
|
+
|
43
|
+
rdoc_options: []
|
44
|
+
|
45
|
+
extra_rdoc_files: []
|
46
|
+
|
47
|
+
executables: []
|
48
|
+
|
49
|
+
extensions: []
|
50
|
+
|
51
|
+
requirements: []
|
52
|
+
|
53
|
+
dependencies: []
|
54
|
+
|