soybean 2.2.2 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/soybean/cli.rb +25 -10
- data/lib/soybean/complex_type.rb +7 -0
- data/lib/soybean/generators/service_generator.rb +1 -1
- data/lib/soybean/generators/templates/middleware.rb +1 -1
- data/lib/soybean/middleware.rb +181 -0
- data/soybean.gemspec +2 -1
- data/vendor/soap4r/soap/attachment.rb +1 -1
- data/vendor/soap4r/soap/element.rb +1 -1
- data/vendor/soap4r/soap/encodingstyle/handler.rb +1 -1
- data/vendor/soap4r/soap/generator.rb +1 -1
- data/vendor/soap4r/soap/mapping/mapping.rb +1 -1
- data/vendor/soap4r/soap/parser.rb +1 -1
- data/vendor/soap4r/soap/processor.rb +3 -3
- data/vendor/soap4r/soap/rpc/router.rb +1 -1
- data/vendor/soap4r/soap/stream_handler.rb +1 -1
- data/vendor/soap4r/wsdl/soap/mapping_registry_creator_support.rb +1 -1
- metadata +19 -18
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3.0
|
data/lib/soybean/cli.rb
CHANGED
@@ -10,7 +10,6 @@ class Soybean::CLI < Thor
|
|
10
10
|
|
11
11
|
|
12
12
|
desc "types [PATH_TO_XSD]", "Generate Ruby classes for xsd-schema from file_path.xsd"
|
13
|
-
|
14
13
|
def types(location, destination = '.')
|
15
14
|
Soybean::Generators::TypesGenerator.new(URI.parse(location)).generate do |filename, content|
|
16
15
|
if options[:remove]
|
@@ -22,27 +21,43 @@ class Soybean::CLI < Thor
|
|
22
21
|
end
|
23
22
|
|
24
23
|
desc "service [PATH_TO_WSDL] [DESTINATION_DIR]", "Generate classes for WebService from WSDL"
|
25
|
-
|
26
24
|
def service(wsdl, dir)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
opts = options
|
26
|
+
raise 'PATH_TO_WSDL should be a exists wsdl file or directory with wsdl`s' unless File.exists? wsdl
|
27
|
+
full_path = File.expand_path wsdl, FileUtils.pwd
|
28
|
+
if File.directory? full_path
|
29
|
+
Dir["#{full_path}/*.wsdl"].each do |file|
|
30
|
+
puts file.inspect
|
31
|
+
generate_service(file, dir, opts)
|
32
32
|
end
|
33
|
+
else
|
34
|
+
generate_service(full_path, dir, opts)
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
36
38
|
desc "version", "Show current version"
|
37
|
-
|
38
39
|
def version
|
39
40
|
puts Soybean::VERSION
|
40
41
|
end
|
41
42
|
|
42
43
|
no_tasks do
|
44
|
+
def generate_service(wsdl, dir, options)
|
45
|
+
Soybean::Generators::ServiceGenerator.new(dir, wsdl, spec_dir(dir)).generate do |filename, content, generator|
|
46
|
+
opts = options
|
47
|
+
if generator.is_a? Soybean::Generators::ModelGenerator
|
48
|
+
opts = opts.merge(:skip => true, :force => false)
|
49
|
+
end
|
50
|
+
if opts[:remove]
|
51
|
+
remove_file filename, opts
|
52
|
+
else
|
53
|
+
create_file filename, content, opts
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
43
58
|
def spec_dir(dir)
|
44
|
-
default_spec_dir = "spec/#{dir}
|
45
|
-
if options[:force]
|
59
|
+
default_spec_dir = "spec/#{dir}"
|
60
|
+
if options[:force] || File.exists?(default_spec_dir)
|
46
61
|
default_spec_dir
|
47
62
|
else
|
48
63
|
ask("Spec directory: '#{default_spec_dir}'? ").presence || default_spec_dir
|
data/lib/soybean/complex_type.rb
CHANGED
@@ -0,0 +1,181 @@
|
|
1
|
+
require 'soap/rpc/router'
|
2
|
+
|
3
|
+
module Soybean
|
4
|
+
class Middleware
|
5
|
+
include SOAP
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def setup
|
9
|
+
@router = ::SOAP::RPC::Router.new(self.class.name)
|
10
|
+
yield self
|
11
|
+
end
|
12
|
+
|
13
|
+
def router
|
14
|
+
@router
|
15
|
+
end
|
16
|
+
|
17
|
+
def endpoint=(regex)
|
18
|
+
@endpoint = regex
|
19
|
+
end
|
20
|
+
|
21
|
+
def endpoint
|
22
|
+
@endpoint
|
23
|
+
end
|
24
|
+
|
25
|
+
# SOAP interface
|
26
|
+
|
27
|
+
def mapping_registry
|
28
|
+
router.mapping_registry
|
29
|
+
end
|
30
|
+
|
31
|
+
def mapping_registry=(mapping_registry)
|
32
|
+
router.mapping_registry = mapping_registry
|
33
|
+
end
|
34
|
+
|
35
|
+
def literal_mapping_registry
|
36
|
+
router.literal_mapping_registry
|
37
|
+
end
|
38
|
+
|
39
|
+
def literal_mapping_registry=(literal_mapping_registry)
|
40
|
+
router.literal_mapping_registry = literal_mapping_registry
|
41
|
+
end
|
42
|
+
|
43
|
+
def generate_explicit_type
|
44
|
+
router.generate_explicit_type
|
45
|
+
end
|
46
|
+
|
47
|
+
def generate_explicit_type=(generate_explicit_type)
|
48
|
+
router.generate_explicit_type = generate_explicit_type
|
49
|
+
end
|
50
|
+
|
51
|
+
# servant entry interface
|
52
|
+
|
53
|
+
def add_rpc_servant(obj, namespace = self.default_namespace)
|
54
|
+
router.add_rpc_servant(obj, namespace)
|
55
|
+
end
|
56
|
+
|
57
|
+
alias add_servant add_rpc_servant
|
58
|
+
|
59
|
+
def add_headerhandler(obj)
|
60
|
+
router.add_headerhandler(obj)
|
61
|
+
end
|
62
|
+
|
63
|
+
alias add_rpc_headerhandler add_headerhandler
|
64
|
+
|
65
|
+
def filterchain
|
66
|
+
router.filterchain
|
67
|
+
end
|
68
|
+
|
69
|
+
# method entry interface
|
70
|
+
|
71
|
+
def add_rpc_method(obj, name, *param)
|
72
|
+
add_rpc_method_with_namespace_as(default_namespace, obj, name, name, *param)
|
73
|
+
end
|
74
|
+
|
75
|
+
alias add_method add_rpc_method
|
76
|
+
|
77
|
+
def add_rpc_method_as(obj, name, name_as, *param)
|
78
|
+
add_rpc_method_with_namespace_as(default_namespace, obj, name, name_as, *param)
|
79
|
+
end
|
80
|
+
|
81
|
+
alias add_method_as add_rpc_method_as
|
82
|
+
|
83
|
+
def add_rpc_method_with_namespace(namespace, obj, name, *param)
|
84
|
+
add_rpc_method_with_namespace_as(namespace, obj, name, name, *param)
|
85
|
+
end
|
86
|
+
|
87
|
+
alias add_method_with_namespace add_rpc_method_with_namespace
|
88
|
+
|
89
|
+
def add_rpc_method_with_namespace_as(namespace, obj, name, name_as, *param)
|
90
|
+
qname = XSD::QName.new(namespace, name_as)
|
91
|
+
soapaction = nil
|
92
|
+
param_def = SOAPMethod.derive_rpc_param_def(obj, name, *param)
|
93
|
+
router.add_rpc_operation(obj, qname, soapaction, name, param_def)
|
94
|
+
end
|
95
|
+
|
96
|
+
alias add_method_with_namespace_as add_rpc_method_with_namespace_as
|
97
|
+
|
98
|
+
def add_rpc_operation(receiver, qname, soapaction, name, param_def, opt = {})
|
99
|
+
router.add_rpc_operation(receiver, qname, soapaction, name, param_def, opt)
|
100
|
+
end
|
101
|
+
|
102
|
+
def add_document_operation(receiver, soapaction, name, param_def, opt = {})
|
103
|
+
router.add_document_operation(receiver, soapaction, name, param_def, opt)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
extend ClassMethods
|
108
|
+
|
109
|
+
def initialize(app = nil)
|
110
|
+
@app = app
|
111
|
+
end
|
112
|
+
|
113
|
+
def call(env)
|
114
|
+
if env['PATH_INFO'].match(self.class.endpoint)
|
115
|
+
handle(env)
|
116
|
+
else
|
117
|
+
# we can act as both a middleware and an app
|
118
|
+
@app ?
|
119
|
+
@app.call(env) :
|
120
|
+
(return 404, {"Content-Type" => "text/plain"}, ["404 - Not Found"])
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def handle(env)
|
125
|
+
# yeah, all soap calls are over POST
|
126
|
+
if env['REQUEST_METHOD'] != 'POST'
|
127
|
+
return 405, {
|
128
|
+
'Allow' => 'POST',
|
129
|
+
'Content-Type' => 'text/plain'}, ["405 - Method Not Allowed"]
|
130
|
+
end
|
131
|
+
|
132
|
+
conn_data = ::SOAP::StreamHandler::ConnectionData.new
|
133
|
+
setup_request(conn_data, env)
|
134
|
+
conn_data = self.class.router.route(conn_data)
|
135
|
+
status, headers, body = setup_response(conn_data, env)
|
136
|
+
[status, headers, body]
|
137
|
+
rescue
|
138
|
+
raise # TODO -- do we 500 right here, or let the exception bubble up?
|
139
|
+
end
|
140
|
+
|
141
|
+
def setup_request(conn_data, env)
|
142
|
+
# TODO: we're reading the whole input here, which kind of stinks if rack is
|
143
|
+
# reading from the client on demand. We can't just pass in the rack input
|
144
|
+
# object, since REXML needs an IO that responds to :eof? -- we'd need a
|
145
|
+
# wrapper IO-like object.
|
146
|
+
conn_data.receive_string = env['rack.input'].read
|
147
|
+
conn_data.receive_contenttype = env['CONTENT_TYPE']
|
148
|
+
conn_data.soapaction = parse_soapaction(env['HTTP_SOAPAction'])
|
149
|
+
end
|
150
|
+
|
151
|
+
def setup_response(conn_data, env)
|
152
|
+
status = 200
|
153
|
+
headers = {}
|
154
|
+
body = []
|
155
|
+
headers['content-type'] = conn_data.send_contenttype
|
156
|
+
# TODO: cookies?
|
157
|
+
if conn_data.is_nocontent
|
158
|
+
status = 202 # ACCEPTED
|
159
|
+
elsif conn_data.is_fault
|
160
|
+
# rather than sending the 500 here, let's bubble up the exception so the
|
161
|
+
# parent application can do with it what it will. The only downside is
|
162
|
+
# soap4r has already converted the exception into a soap response body at
|
163
|
+
# this point, which isn't what we want at all.
|
164
|
+
# maybe someday i'll re-parse the response or something. but not today.
|
165
|
+
raise conn_data.send_string
|
166
|
+
else
|
167
|
+
body << conn_data.send_string
|
168
|
+
end
|
169
|
+
return status, headers, body
|
170
|
+
end
|
171
|
+
|
172
|
+
def parse_soapaction(soapaction)
|
173
|
+
if !soapaction.nil? and !soapaction.empty?
|
174
|
+
if /\A"(.+)"\z/ =~ soapaction
|
175
|
+
return $1
|
176
|
+
end
|
177
|
+
end
|
178
|
+
nil
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
data/soybean.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{soybean}
|
8
|
-
s.version = "2.
|
8
|
+
s.version = "2.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Anton Sozontov"]
|
@@ -46,6 +46,7 @@ Gem::Specification.new do |s|
|
|
46
46
|
"lib/soybean/interface.rb",
|
47
47
|
"lib/soybean/interface_builder.rb",
|
48
48
|
"lib/soybean/literal_mapping_registry_creator.rb",
|
49
|
+
"lib/soybean/middleware.rb",
|
49
50
|
"soybean.gemspec",
|
50
51
|
"spec/soybean_spec.rb",
|
51
52
|
"spec/spec_helper.rb",
|
@@ -517,7 +517,7 @@ module Mapping
|
|
517
517
|
elename = XSD::QName.new(default_ns, varname)
|
518
518
|
end
|
519
519
|
SchemaElementDefinition.new(
|
520
|
-
varname, mapped_class, elename, minoccurs, maxoccurs, as_any, as_array)
|
520
|
+
varname.underscore, mapped_class, elename, minoccurs, maxoccurs, as_any, as_array)
|
521
521
|
end
|
522
522
|
end
|
523
523
|
|
@@ -12,9 +12,9 @@ require 'soap/soap'
|
|
12
12
|
require 'soap/element'
|
13
13
|
require 'soap/parser'
|
14
14
|
require 'soap/generator'
|
15
|
-
require 'soap/encodingstyle/
|
16
|
-
require 'soap/encodingstyle/
|
17
|
-
require 'soap/encodingstyle/
|
15
|
+
require 'soap/encodingstyle/soap_handler'
|
16
|
+
require 'soap/encodingstyle/literal_handler'
|
17
|
+
require 'soap/encodingstyle/asp_dot_net_handler'
|
18
18
|
|
19
19
|
|
20
20
|
module SOAP
|
@@ -106,7 +106,7 @@ class HTTPStreamHandler < StreamHandler
|
|
106
106
|
RETRYABLE = true
|
107
107
|
rescue LoadError
|
108
108
|
warn("Loading http-access2 failed. Net/http is used.") if $DEBUG
|
109
|
-
require 'soap/
|
109
|
+
require 'soap/net_http_client'
|
110
110
|
Client = SOAP::NetHttpClient
|
111
111
|
RETRYABLE = false
|
112
112
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soybean
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ default_executable: soybean
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: thor
|
17
|
-
requirement: &
|
17
|
+
requirement: &4642340 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *4642340
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: activesupport
|
28
|
-
requirement: &
|
28
|
+
requirement: &4641260 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '3.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *4641260
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: i18n
|
39
|
-
requirement: &
|
39
|
+
requirement: &4639600 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *4639600
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rspec
|
50
|
-
requirement: &
|
50
|
+
requirement: &4638200 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: 2.3.0
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *4638200
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: yard
|
61
|
-
requirement: &
|
61
|
+
requirement: &4637120 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ~>
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: 0.6.0
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *4637120
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: bundler
|
72
|
-
requirement: &
|
72
|
+
requirement: &4635500 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: 1.0.0
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *4635500
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: jeweler
|
83
|
-
requirement: &
|
83
|
+
requirement: &4634520 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ~>
|
@@ -88,10 +88,10 @@ dependencies:
|
|
88
88
|
version: 1.6.4
|
89
89
|
type: :development
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *4634520
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: rcov
|
94
|
-
requirement: &
|
94
|
+
requirement: &4633360 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|
97
97
|
- - ! '>='
|
@@ -99,7 +99,7 @@ dependencies:
|
|
99
99
|
version: '0'
|
100
100
|
type: :development
|
101
101
|
prerelease: false
|
102
|
-
version_requirements: *
|
102
|
+
version_requirements: *4633360
|
103
103
|
description: ! 'Generate soap web-services from you wsdl. Generate: all classes from
|
104
104
|
xsd, and other.'
|
105
105
|
email: a.sozontov@gmail.com
|
@@ -137,6 +137,7 @@ files:
|
|
137
137
|
- lib/soybean/interface.rb
|
138
138
|
- lib/soybean/interface_builder.rb
|
139
139
|
- lib/soybean/literal_mapping_registry_creator.rb
|
140
|
+
- lib/soybean/middleware.rb
|
140
141
|
- soybean.gemspec
|
141
142
|
- spec/soybean_spec.rb
|
142
143
|
- spec/spec_helper.rb
|
@@ -315,7 +316,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
315
316
|
version: '0'
|
316
317
|
segments:
|
317
318
|
- 0
|
318
|
-
hash: -
|
319
|
+
hash: -1409596823364250190
|
319
320
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
320
321
|
none: false
|
321
322
|
requirements:
|