soybean 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +38 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +44 -0
- data/VERSION +1 -0
- data/bin/soybean +22 -0
- data/bin/xsd2ruby +90 -0
- data/lib/soybean.rb +11 -0
- data/lib/soybean/actions/generate_classes.rb +33 -0
- data/soybean.gemspec +236 -0
- data/spec/soybean_spec.rb +5 -0
- data/spec/spec_helper.rb +12 -0
- data/vendor/soap4r/soap/attachment.rb +109 -0
- data/vendor/soap4r/soap/attrproxy.rb +35 -0
- data/vendor/soap4r/soap/base_data.rb +1095 -0
- data/vendor/soap4r/soap/element.rb +278 -0
- data/vendor/soap4r/soap/encodingstyle/asp_dot_net_handler.rb +208 -0
- data/vendor/soap4r/soap/encodingstyle/handler.rb +121 -0
- data/vendor/soap4r/soap/encodingstyle/literal_handler.rb +196 -0
- data/vendor/soap4r/soap/encodingstyle/soap_handler.rb +560 -0
- data/vendor/soap4r/soap/filter.rb +14 -0
- data/vendor/soap4r/soap/filter/filterchain.rb +52 -0
- data/vendor/soap4r/soap/filter/handler.rb +32 -0
- data/vendor/soap4r/soap/filter/streamhandler.rb +30 -0
- data/vendor/soap4r/soap/generator.rb +299 -0
- data/vendor/soap4r/soap/header/handler.rb +62 -0
- data/vendor/soap4r/soap/header/handlerset.rb +71 -0
- data/vendor/soap4r/soap/header/mappinghandler.rb +48 -0
- data/vendor/soap4r/soap/header/simplehandler.rb +45 -0
- data/vendor/soap4r/soap/httpconfigloader.rb +140 -0
- data/vendor/soap4r/soap/mapping.rb +13 -0
- data/vendor/soap4r/soap/mapping/encodedregistry.rb +539 -0
- data/vendor/soap4r/soap/mapping/factory.rb +389 -0
- data/vendor/soap4r/soap/mapping/literalregistry.rb +392 -0
- data/vendor/soap4r/soap/mapping/mapping.rb +577 -0
- data/vendor/soap4r/soap/mapping/registry.rb +296 -0
- data/vendor/soap4r/soap/mapping/rubytype_factory.rb +446 -0
- data/vendor/soap4r/soap/mapping/schemadefinition.rb +171 -0
- data/vendor/soap4r/soap/mapping/type_map.rb +107 -0
- data/vendor/soap4r/soap/mapping/wsdlencodedregistry.rb +212 -0
- data/vendor/soap4r/soap/mapping/wsdlliteralregistry.rb +249 -0
- data/vendor/soap4r/soap/marshal.rb +60 -0
- data/vendor/soap4r/soap/mimemessage.rb +243 -0
- data/vendor/soap4r/soap/nestedexception.rb +43 -0
- data/vendor/soap4r/soap/net_http_client.rb +242 -0
- data/vendor/soap4r/soap/ns.rb +39 -0
- data/vendor/soap4r/soap/parser.rb +253 -0
- data/vendor/soap4r/soap/processor.rb +67 -0
- data/vendor/soap4r/soap/property.rb +340 -0
- data/vendor/soap4r/soap/proxy.rb +15 -0
- data/vendor/soap4r/soap/rpc/cgistub.rb +248 -0
- data/vendor/soap4r/soap/rpc/driver.rb +222 -0
- data/vendor/soap4r/soap/rpc/element.rb +375 -0
- data/vendor/soap4r/soap/rpc/httpserver.rb +143 -0
- data/vendor/soap4r/soap/rpc/method_def.rb +69 -0
- data/vendor/soap4r/soap/rpc/proxy.rb +573 -0
- data/vendor/soap4r/soap/rpc/router.rb +663 -0
- data/vendor/soap4r/soap/rpc/rpc.rb +26 -0
- data/vendor/soap4r/soap/rpc/soaplet.rb +201 -0
- data/vendor/soap4r/soap/rpc/standalone_server.rb +44 -0
- data/vendor/soap4r/soap/soap.rb +154 -0
- data/vendor/soap4r/soap/stream_handler.rb +302 -0
- data/vendor/soap4r/soap/version.rb +9 -0
- data/vendor/soap4r/soap/wsdl_driver.rb +165 -0
- data/vendor/soap4r/wsdl/binding.rb +66 -0
- data/vendor/soap4r/wsdl/data.rb +65 -0
- data/vendor/soap4r/wsdl/definitions.rb +237 -0
- data/vendor/soap4r/wsdl/documentation.rb +33 -0
- data/vendor/soap4r/wsdl/import.rb +81 -0
- data/vendor/soap4r/wsdl/importer.rb +39 -0
- data/vendor/soap4r/wsdl/info.rb +51 -0
- data/vendor/soap4r/wsdl/message.rb +55 -0
- data/vendor/soap4r/wsdl/operation.rb +152 -0
- data/vendor/soap4r/wsdl/operation_binding.rb +241 -0
- data/vendor/soap4r/wsdl/param.rb +94 -0
- data/vendor/soap4r/wsdl/parser.rb +165 -0
- data/vendor/soap4r/wsdl/part.rb +53 -0
- data/vendor/soap4r/wsdl/port.rb +67 -0
- data/vendor/soap4r/wsdl/port_type.rb +76 -0
- data/vendor/soap4r/wsdl/service.rb +62 -0
- data/vendor/soap4r/wsdl/soap/address.rb +41 -0
- data/vendor/soap4r/wsdl/soap/binding.rb +50 -0
- data/vendor/soap4r/wsdl/soap/body.rb +59 -0
- data/vendor/soap4r/wsdl/soap/cgi_stub_creator.rb +93 -0
- data/vendor/soap4r/wsdl/soap/class_def_creator.rb +437 -0
- data/vendor/soap4r/wsdl/soap/class_def_creator_support.rb +241 -0
- data/vendor/soap4r/wsdl/soap/class_name_creator.rb +55 -0
- data/vendor/soap4r/wsdl/soap/client_skelton_creator.rb +107 -0
- data/vendor/soap4r/wsdl/soap/complex_type.rb +174 -0
- data/vendor/soap4r/wsdl/soap/data.rb +43 -0
- data/vendor/soap4r/wsdl/soap/definitions.rb +201 -0
- data/vendor/soap4r/wsdl/soap/driver_creator.rb +121 -0
- data/vendor/soap4r/wsdl/soap/element.rb +34 -0
- data/vendor/soap4r/wsdl/soap/encoded_mapping_registry_creator.rb +74 -0
- data/vendor/soap4r/wsdl/soap/fault.rb +57 -0
- data/vendor/soap4r/wsdl/soap/header.rb +87 -0
- data/vendor/soap4r/wsdl/soap/headerfault.rb +57 -0
- data/vendor/soap4r/wsdl/soap/literal_mapping_registry_creator.rb +116 -0
- data/vendor/soap4r/wsdl/soap/mapping_registry_creator.rb +59 -0
- data/vendor/soap4r/wsdl/soap/mapping_registry_creator_support.rb +377 -0
- data/vendor/soap4r/wsdl/soap/method_def_creator.rb +200 -0
- data/vendor/soap4r/wsdl/soap/operation.rb +113 -0
- data/vendor/soap4r/wsdl/soap/servant_skelton_creator.rb +92 -0
- data/vendor/soap4r/wsdl/soap/servlet_stub_creator.rb +105 -0
- data/vendor/soap4r/wsdl/soap/standalone_server_stub_creator.rb +101 -0
- data/vendor/soap4r/wsdl/soap/wsdl2ruby.rb +226 -0
- data/vendor/soap4r/wsdl/types.rb +45 -0
- data/vendor/soap4r/wsdl/wsdl.rb +25 -0
- data/vendor/soap4r/wsdl/xml_schema/all.rb +25 -0
- data/vendor/soap4r/wsdl/xml_schema/annotation.rb +35 -0
- data/vendor/soap4r/wsdl/xml_schema/any.rb +62 -0
- data/vendor/soap4r/wsdl/xml_schema/any_attribute.rb +49 -0
- data/vendor/soap4r/wsdl/xml_schema/attribute.rb +105 -0
- data/vendor/soap4r/wsdl/xml_schema/attribute_group.rb +69 -0
- data/vendor/soap4r/wsdl/xml_schema/choice.rb +59 -0
- data/vendor/soap4r/wsdl/xml_schema/complex_content.rb +98 -0
- data/vendor/soap4r/wsdl/xml_schema/complex_extension.rb +120 -0
- data/vendor/soap4r/wsdl/xml_schema/complex_restriction.rb +105 -0
- data/vendor/soap4r/wsdl/xml_schema/complex_type.rb +194 -0
- data/vendor/soap4r/wsdl/xml_schema/content.rb +96 -0
- data/vendor/soap4r/wsdl/xml_schema/data.rb +117 -0
- data/vendor/soap4r/wsdl/xml_schema/element.rb +154 -0
- data/vendor/soap4r/wsdl/xml_schema/enumeration.rb +37 -0
- data/vendor/soap4r/wsdl/xml_schema/fractiondigits.rb +38 -0
- data/vendor/soap4r/wsdl/xml_schema/group.rb +101 -0
- data/vendor/soap4r/wsdl/xml_schema/import.rb +54 -0
- data/vendor/soap4r/wsdl/xml_schema/import_handler.rb +46 -0
- data/vendor/soap4r/wsdl/xml_schema/importer.rb +103 -0
- data/vendor/soap4r/wsdl/xml_schema/include.rb +49 -0
- data/vendor/soap4r/wsdl/xml_schema/length.rb +38 -0
- data/vendor/soap4r/wsdl/xml_schema/list.rb +49 -0
- data/vendor/soap4r/wsdl/xml_schema/maxexclusive.rb +38 -0
- data/vendor/soap4r/wsdl/xml_schema/maxinclusive.rb +38 -0
- data/vendor/soap4r/wsdl/xml_schema/maxlength.rb +38 -0
- data/vendor/soap4r/wsdl/xml_schema/minexclusive.rb +38 -0
- data/vendor/soap4r/wsdl/xml_schema/mininclusive.rb +38 -0
- data/vendor/soap4r/wsdl/xml_schema/minlength.rb +38 -0
- data/vendor/soap4r/wsdl/xml_schema/parser.rb +168 -0
- data/vendor/soap4r/wsdl/xml_schema/pattern.rb +37 -0
- data/vendor/soap4r/wsdl/xml_schema/ref.rb +34 -0
- data/vendor/soap4r/wsdl/xml_schema/schema.rb +179 -0
- data/vendor/soap4r/wsdl/xml_schema/sequence.rb +55 -0
- data/vendor/soap4r/wsdl/xml_schema/simple_content.rb +70 -0
- data/vendor/soap4r/wsdl/xml_schema/simple_extension.rb +63 -0
- data/vendor/soap4r/wsdl/xml_schema/simple_restriction.rb +133 -0
- data/vendor/soap4r/wsdl/xml_schema/simple_type.rb +88 -0
- data/vendor/soap4r/wsdl/xml_schema/totaldigits.rb +38 -0
- data/vendor/soap4r/wsdl/xml_schema/union.rb +36 -0
- data/vendor/soap4r/wsdl/xml_schema/unique.rb +35 -0
- data/vendor/soap4r/wsdl/xml_schema/whitespace.rb +38 -0
- data/vendor/soap4r/wsdl/xml_schema/xsd2ruby.rb +176 -0
- data/vendor/soap4r/xsd/charset.rb +190 -0
- data/vendor/soap4r/xsd/codegen.rb +13 -0
- data/vendor/soap4r/xsd/codegen/classdef.rb +209 -0
- data/vendor/soap4r/xsd/codegen/commentdef.rb +35 -0
- data/vendor/soap4r/xsd/codegen/gensupport.rb +277 -0
- data/vendor/soap4r/xsd/codegen/methoddef.rb +71 -0
- data/vendor/soap4r/xsd/codegen/moduledef.rb +209 -0
- data/vendor/soap4r/xsd/datatypes.rb +1466 -0
- data/vendor/soap4r/xsd/datatypes1999.rb +21 -0
- data/vendor/soap4r/xsd/iconvcharset.rb +34 -0
- data/vendor/soap4r/xsd/mapping.rb +69 -0
- data/vendor/soap4r/xsd/namedelements.rb +133 -0
- data/vendor/soap4r/xsd/ns.rb +183 -0
- data/vendor/soap4r/xsd/qname.rb +80 -0
- data/vendor/soap4r/xsd/xmlparser.rb +77 -0
- data/vendor/soap4r/xsd/xmlparser/libxmlparser.rb +116 -0
- data/vendor/soap4r/xsd/xmlparser/parser.rb +101 -0
- data/vendor/soap4r/xsd/xmlparser/rexmlparser.rb +59 -0
- data/vendor/soap4r/xsd/xmlparser/xmlparser.rb +51 -0
- data/vendor/soap4r/xsd/xmlparser/xmlscanner.rb +150 -0
- metadata +316 -0
@@ -0,0 +1,200 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
# WSDL4R - Creating method definition from WSDL
|
3
|
+
# Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
4
|
+
|
5
|
+
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
6
|
+
# redistribute it and/or modify it under the same terms of Ruby's license;
|
7
|
+
# either the dual license version in 2003, or any later version.
|
8
|
+
|
9
|
+
|
10
|
+
require 'wsdl/info'
|
11
|
+
require 'wsdl/soap/class_def_creator_support'
|
12
|
+
require 'soap/rpc/element'
|
13
|
+
require 'soap/rpc/method_def'
|
14
|
+
|
15
|
+
|
16
|
+
module WSDL
|
17
|
+
module SOAP
|
18
|
+
|
19
|
+
|
20
|
+
class MethodDefCreator
|
21
|
+
include ClassDefCreatorSupport
|
22
|
+
|
23
|
+
attr_reader :definitions
|
24
|
+
# TODO: should not export this kind of stateful information.
|
25
|
+
# will be rewwritten in 1.6.1
|
26
|
+
attr_reader :assigned_method
|
27
|
+
|
28
|
+
def initialize(definitions, name_creator, modulepath, defined_const)
|
29
|
+
@definitions = definitions
|
30
|
+
@name_creator = name_creator
|
31
|
+
@modulepath = modulepath
|
32
|
+
@simpletypes = @definitions.collect_simpletypes
|
33
|
+
@complextypes = @definitions.collect_complextypes
|
34
|
+
@elements = @definitions.collect_elements
|
35
|
+
@defined_const = defined_const
|
36
|
+
@assigned_method = {}
|
37
|
+
end
|
38
|
+
|
39
|
+
def dump(name)
|
40
|
+
methoddef = ""
|
41
|
+
porttype = @definitions.porttype(name)
|
42
|
+
binding = porttype.find_binding
|
43
|
+
if binding
|
44
|
+
create(binding.name).each do |mdef|
|
45
|
+
methoddef << ",\n" unless methoddef.empty?
|
46
|
+
methoddef << dump_method(mdef).chomp
|
47
|
+
end
|
48
|
+
end
|
49
|
+
methoddef
|
50
|
+
end
|
51
|
+
|
52
|
+
def create(bindingname)
|
53
|
+
binding = @definitions.binding(bindingname)
|
54
|
+
if binding
|
55
|
+
return binding.operations.collect { |op_bind|
|
56
|
+
next unless op_bind.soapoperation # not a SOAP operation binding
|
57
|
+
create_methoddef(op_bind)
|
58
|
+
}
|
59
|
+
end
|
60
|
+
nil
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def create_methoddef(op_bind)
|
66
|
+
op_info = op_bind.operation_info
|
67
|
+
name = assign_method_name(op_bind)
|
68
|
+
soapaction = op_info.boundid.soapaction
|
69
|
+
qname = op_bind.soapoperation_name
|
70
|
+
mdef = ::SOAP::RPC::MethodDef.new(name, soapaction, qname)
|
71
|
+
op_info.parts.each do |part|
|
72
|
+
if op_info.style == :rpc
|
73
|
+
mapped_class, qname = rpcdefinedtype(part)
|
74
|
+
else
|
75
|
+
mapped_class, qname = documentdefinedtype(part)
|
76
|
+
end
|
77
|
+
mdef.add_parameter(part.io_type, part.name, qname, mapped_class)
|
78
|
+
end
|
79
|
+
op_info.faults.each do |name, faultinfo|
|
80
|
+
faultclass = mapped_class_name(name, @modulepath)
|
81
|
+
mdef.faults[faultclass] = faultinfo
|
82
|
+
end
|
83
|
+
mdef.style = op_info.style
|
84
|
+
mdef.inputuse = op_info.inputuse
|
85
|
+
mdef.outputuse = op_info.outputuse
|
86
|
+
mdef
|
87
|
+
end
|
88
|
+
|
89
|
+
def dump_method(mdef)
|
90
|
+
style = mdef.style
|
91
|
+
inputuse = mdef.inputuse
|
92
|
+
outputuse = mdef.outputuse
|
93
|
+
paramstr = param2str(mdef.parameters)
|
94
|
+
if paramstr.empty?
|
95
|
+
paramstr = '[]'
|
96
|
+
else
|
97
|
+
paramstr = "[ " << paramstr.split(/\r?\n/).join("\n ") << " ]"
|
98
|
+
end
|
99
|
+
definitions = <<__EOD__
|
100
|
+
#{ndq(mdef.soapaction)},
|
101
|
+
#{dq(mdef.name)},
|
102
|
+
#{paramstr},
|
103
|
+
{ :request_style => #{nsym(style)}, :request_use => #{nsym(inputuse)},
|
104
|
+
:response_style => #{nsym(style)}, :response_use => #{nsym(outputuse)},
|
105
|
+
:faults => #{mdef.faults.inspect} }
|
106
|
+
__EOD__
|
107
|
+
if style == :rpc
|
108
|
+
assign_const(mdef.qname.namespace, 'Ns')
|
109
|
+
return <<__EOD__
|
110
|
+
[ #{dqname(mdef.qname)},
|
111
|
+
#{definitions}]
|
112
|
+
__EOD__
|
113
|
+
else
|
114
|
+
return <<__EOD__
|
115
|
+
[ #{definitions}]
|
116
|
+
__EOD__
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def assign_method_name(op_bind)
|
121
|
+
method_name = safemethodname(op_bind.name)
|
122
|
+
i = 1 # starts from _2
|
123
|
+
while @assigned_method.value?(method_name)
|
124
|
+
i += 1
|
125
|
+
method_name = safemethodname("#{op_bind.name}_#{i}")
|
126
|
+
end
|
127
|
+
@assigned_method[op_bind.boundid] = method_name
|
128
|
+
method_name
|
129
|
+
end
|
130
|
+
|
131
|
+
def rpcdefinedtype(part)
|
132
|
+
if mapped = basetype_mapped_class(part.type)
|
133
|
+
return ['::' + mapped.name, nil]
|
134
|
+
elsif definedtype = @simpletypes[part.type]
|
135
|
+
return [nil, definedtype.name]
|
136
|
+
elsif definedtype = @elements[part.element]
|
137
|
+
return [nil, part.element]
|
138
|
+
elsif definedtype = @complextypes[part.type]
|
139
|
+
case definedtype.compoundtype
|
140
|
+
when :TYPE_STRUCT, :TYPE_EMPTY, :TYPE_ARRAY, :TYPE_SIMPLE
|
141
|
+
type = mapped_class_name(part.type, @modulepath)
|
142
|
+
return [type, part.type]
|
143
|
+
when :TYPE_MAP
|
144
|
+
return [Hash.name, part.type]
|
145
|
+
else
|
146
|
+
raise NotImplementedError.new("must not reach here: #{definedtype.compoundtype}")
|
147
|
+
end
|
148
|
+
elsif part.type == XSD::AnyTypeName
|
149
|
+
return [nil, nil]
|
150
|
+
else
|
151
|
+
raise RuntimeError.new("part: #{part.name} cannot be resolved")
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def documentdefinedtype(part)
|
156
|
+
if mapped = basetype_mapped_class(part.type)
|
157
|
+
return ['::' + mapped.name, XSD::QName.new(nil, part.name)]
|
158
|
+
elsif definedtype = @simpletypes[part.type]
|
159
|
+
if definedtype.base
|
160
|
+
return ['::' + basetype_mapped_class(definedtype.base).name, XSD::QName.new(nil, part.name)]
|
161
|
+
else
|
162
|
+
raise RuntimeError.new("unsupported simpleType: #{definedtype}")
|
163
|
+
end
|
164
|
+
elsif definedtype = @elements[part.element]
|
165
|
+
return ['::SOAP::SOAPElement', part.element]
|
166
|
+
elsif definedtype = @complextypes[part.type]
|
167
|
+
return ['::SOAP::SOAPElement', part.type]
|
168
|
+
else
|
169
|
+
raise RuntimeError.new("part: #{part.name} cannot be resolved")
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def param2str(params)
|
174
|
+
params.collect { |param|
|
175
|
+
mappingstr = mapping_info2str(param.mapped_class, param.qname)
|
176
|
+
"[:#{param.io_type.id2name}, #{dq(param.name)}, #{mappingstr}]"
|
177
|
+
}.join(",\n")
|
178
|
+
end
|
179
|
+
|
180
|
+
def mapping_info2str(mapped_class, qname)
|
181
|
+
if qname.nil?
|
182
|
+
"[#{ndq(mapped_class)}]"
|
183
|
+
else
|
184
|
+
"[#{ndq(mapped_class)}, #{ndq(qname.namespace)}, #{dq(qname.name)}]"
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def ele2str(ele)
|
189
|
+
qualified = ele
|
190
|
+
if qualified
|
191
|
+
"true"
|
192
|
+
else
|
193
|
+
"false"
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
|
199
|
+
end
|
200
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
# WSDL4R - WSDL SOAP operation definition.
|
3
|
+
# Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
4
|
+
|
5
|
+
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
6
|
+
# redistribute it and/or modify it under the same terms of Ruby's license;
|
7
|
+
# either the dual license version in 2003, or any later version.
|
8
|
+
|
9
|
+
|
10
|
+
require 'wsdl/info'
|
11
|
+
|
12
|
+
|
13
|
+
module WSDL
|
14
|
+
module SOAP
|
15
|
+
|
16
|
+
|
17
|
+
class Operation < Info
|
18
|
+
class ParamInfo
|
19
|
+
attr_reader :style
|
20
|
+
attr_reader :op_name
|
21
|
+
attr_reader :optype_name
|
22
|
+
attr_reader :encodingstyle
|
23
|
+
attr_reader :headerparts
|
24
|
+
attr_reader :bodyparts
|
25
|
+
attr_reader :faultpart
|
26
|
+
attr_reader :soapaction
|
27
|
+
|
28
|
+
def initialize(style, use, encodingstyle, op_name, optype_name,
|
29
|
+
headerparts, bodyparts, faultpart, soapaction)
|
30
|
+
@style = style
|
31
|
+
@use = use
|
32
|
+
@encodingstyle = encodingstyle
|
33
|
+
@op_name = op_name
|
34
|
+
@optype_name = optype_name
|
35
|
+
@headerparts = headerparts
|
36
|
+
@bodyparts = bodyparts
|
37
|
+
@faultpart = faultpart
|
38
|
+
@soapaction = soapaction
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
attr_reader :soapaction
|
43
|
+
attr_reader :style
|
44
|
+
|
45
|
+
def initialize
|
46
|
+
super
|
47
|
+
@soapaction = nil
|
48
|
+
@style = nil
|
49
|
+
end
|
50
|
+
|
51
|
+
def parse_element(element)
|
52
|
+
nil
|
53
|
+
end
|
54
|
+
|
55
|
+
def parse_attr(attr, value)
|
56
|
+
case attr
|
57
|
+
when StyleAttrName
|
58
|
+
if ["document", "rpc"].include?(value.source)
|
59
|
+
@style = value.source.intern
|
60
|
+
else
|
61
|
+
raise Parser::AttributeConstraintError.new(
|
62
|
+
"Unexpected value #{ value }.")
|
63
|
+
end
|
64
|
+
when SOAPActionAttrName
|
65
|
+
@soapaction = value.source
|
66
|
+
else
|
67
|
+
nil
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def operation_style
|
72
|
+
return @style if @style
|
73
|
+
if parent_binding.soapbinding
|
74
|
+
return parent_binding.soapbinding.style
|
75
|
+
end
|
76
|
+
nil
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def parent_binding
|
82
|
+
parent.parent
|
83
|
+
end
|
84
|
+
|
85
|
+
def create_param_info(name_info, param)
|
86
|
+
op_style = operation_style()
|
87
|
+
op_use = param.soapbody_use
|
88
|
+
op_encodingstyle = param.soapbody_encodingstyle
|
89
|
+
op_name = name_info.op_name
|
90
|
+
optype_name = name_info.optype_name
|
91
|
+
soapheader = param.soapheader
|
92
|
+
headerparts = soapheader.collect { |item| item.find_part }
|
93
|
+
soapbody = param.soapbody
|
94
|
+
if soapbody.namespace
|
95
|
+
op_name = XSD::QName.new(soapbody.namespace, op_name.name)
|
96
|
+
end
|
97
|
+
if soapbody.parts
|
98
|
+
target = soapbody.parts.split(/\s+/)
|
99
|
+
bodyparts = name_info.parts.find_all { |part|
|
100
|
+
target.include?(part.name)
|
101
|
+
}
|
102
|
+
else
|
103
|
+
bodyparts = name_info.parts
|
104
|
+
end
|
105
|
+
faultpart = nil
|
106
|
+
ParamInfo.new(op_style, op_use, op_encodingstyle, op_name, optype_name,
|
107
|
+
headerparts, bodyparts, faultpart, parent.soapaction)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
# WSDL4R - Creating servant skelton code from WSDL.
|
3
|
+
# Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
4
|
+
|
5
|
+
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
6
|
+
# redistribute it and/or modify it under the same terms of Ruby's license;
|
7
|
+
# either the dual license version in 2003, or any later version.
|
8
|
+
|
9
|
+
|
10
|
+
require 'wsdl/info'
|
11
|
+
require 'wsdl/soap/class_def_creator_support'
|
12
|
+
require 'xsd/codegen'
|
13
|
+
|
14
|
+
|
15
|
+
module WSDL
|
16
|
+
module SOAP
|
17
|
+
|
18
|
+
|
19
|
+
class ServantSkeltonCreator
|
20
|
+
include ClassDefCreatorSupport
|
21
|
+
include XSD::CodeGen::GenSupport
|
22
|
+
|
23
|
+
attr_reader :definitions
|
24
|
+
|
25
|
+
def initialize(definitions, name_creator, modulepath = nil)
|
26
|
+
@definitions = definitions
|
27
|
+
@name_creator = name_creator
|
28
|
+
@modulepath = modulepath
|
29
|
+
end
|
30
|
+
|
31
|
+
def dump(porttype = nil)
|
32
|
+
result = ""
|
33
|
+
if @modulepath
|
34
|
+
result << "\n"
|
35
|
+
modulepath = @modulepath.respond_to?(:lines) ? @modulepath.lines : @modulepath # RubyJedi: compatible with Ruby 1.8.6 and above
|
36
|
+
result << modulepath.collect { |ele| "module #{ele}" }.join("; ")
|
37
|
+
result << "\n\n"
|
38
|
+
end
|
39
|
+
if porttype.nil?
|
40
|
+
@definitions.porttypes.each do |porttype|
|
41
|
+
result << dump_porttype(porttype)
|
42
|
+
result << "\n"
|
43
|
+
end
|
44
|
+
else
|
45
|
+
result << dump_porttype(porttype)
|
46
|
+
end
|
47
|
+
if @modulepath
|
48
|
+
result << "\n\n"
|
49
|
+
modulepath = @modulepath.respond_to?(:lines) ? @modulepath.lines : @modulepath # RubyJedi: compatible with Ruby 1.8.6 and above
|
50
|
+
result << modulepath.collect { |ele| "end" }.join("; ")
|
51
|
+
result << "\n"
|
52
|
+
end
|
53
|
+
result
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def dump_porttype(porttype)
|
59
|
+
assigned_method = collect_assigned_method(@definitions, porttype.name, @modulepath)
|
60
|
+
class_name = mapped_class_basename(porttype.name, @modulepath)
|
61
|
+
c = XSD::CodeGen::ClassDef.new(class_name)
|
62
|
+
element_definitions = @definitions.collect_elements
|
63
|
+
binding = porttype.find_binding
|
64
|
+
if binding
|
65
|
+
binding.operations.each do |op_bind|
|
66
|
+
operation = op_bind.find_operation
|
67
|
+
if operation.nil?
|
68
|
+
warn("operation not found for binding: #{op_bind}")
|
69
|
+
next
|
70
|
+
end
|
71
|
+
name = assigned_method[op_bind.boundid] || operation.name
|
72
|
+
methodname = safemethodname(name)
|
73
|
+
input = operation.input
|
74
|
+
params = input.find_message.parts.collect { |part|
|
75
|
+
safevarname(part.name)
|
76
|
+
}
|
77
|
+
m = XSD::CodeGen::MethodDef.new(methodname, params) do <<-EOD
|
78
|
+
p [#{params.join(", ")}]
|
79
|
+
raise NotImplementedError.new
|
80
|
+
EOD
|
81
|
+
end
|
82
|
+
m.comment = dump_method_signature(methodname, operation, element_definitions)
|
83
|
+
c.add_method(m)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
c.dump
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
# WSDL4R - Creating servlet stub code from WSDL.
|
3
|
+
# Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
4
|
+
|
5
|
+
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
6
|
+
# redistribute it and/or modify it under the same terms of Ruby's license;
|
7
|
+
# either the dual license version in 2003, or any later version.
|
8
|
+
|
9
|
+
|
10
|
+
require 'wsdl/info'
|
11
|
+
require 'wsdl/soap/mapping_registry_creator'
|
12
|
+
require 'wsdl/soap/method_def_creator'
|
13
|
+
require 'wsdl/soap/class_def_creator_support'
|
14
|
+
|
15
|
+
|
16
|
+
module WSDL
|
17
|
+
module SOAP
|
18
|
+
|
19
|
+
|
20
|
+
class ServletStubCreator
|
21
|
+
include ClassDefCreatorSupport
|
22
|
+
|
23
|
+
attr_reader :definitions
|
24
|
+
|
25
|
+
def initialize(definitions, name_creator, modulepath = nil)
|
26
|
+
@definitions = definitions
|
27
|
+
@name_creator = name_creator
|
28
|
+
@modulepath = modulepath
|
29
|
+
end
|
30
|
+
|
31
|
+
def dump(service_name)
|
32
|
+
warn("- Servlet stub can have only 1 port for now. So creating stub for the first port and rests are ignored.")
|
33
|
+
services = @definitions.service(service_name)
|
34
|
+
unless services
|
35
|
+
raise RuntimeError.new("service not defined: #{service_name}")
|
36
|
+
end
|
37
|
+
ports = services.ports
|
38
|
+
if ports.empty?
|
39
|
+
raise RuntimeError.new("ports not found for #{service_name}")
|
40
|
+
end
|
41
|
+
port = ports[0]
|
42
|
+
if port.porttype.nil?
|
43
|
+
raise RuntimeError.new("porttype not found for #{port}")
|
44
|
+
end
|
45
|
+
dump_porttype(port.porttype)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def dump_porttype(porttype)
|
51
|
+
class_name = mapped_class_name(porttype.name, @modulepath)
|
52
|
+
defined_const = {}
|
53
|
+
methoddef = MethodDefCreator.new(@definitions, @name_creator, @modulepath, defined_const).dump(porttype.name)
|
54
|
+
wsdl_name = @definitions.name ? @definitions.name.name : 'default'
|
55
|
+
mrname = safeconstname(wsdl_name + 'MappingRegistry')
|
56
|
+
c1 = XSD::CodeGen::ClassDef.new(class_name)
|
57
|
+
c1.def_require("soap/rpc/soaplet")
|
58
|
+
c1.def_code <<-EOD
|
59
|
+
Methods = [
|
60
|
+
#{methoddef.gsub(/^/, " ")}
|
61
|
+
]
|
62
|
+
EOD
|
63
|
+
defined_const.each do |ns, tag|
|
64
|
+
c1.def_const(tag, dq(ns))
|
65
|
+
end
|
66
|
+
c2 = XSD::CodeGen::ClassDef.new(class_name + "Servlet",
|
67
|
+
"::SOAP::RPC::SOAPlet")
|
68
|
+
c2.def_method("initialize", "router = nil") do
|
69
|
+
<<-EOD
|
70
|
+
super(router)
|
71
|
+
servant = #{class_name}.new
|
72
|
+
#{class_name}::Methods.each do |definitions|
|
73
|
+
opt = definitions.last
|
74
|
+
if opt[:request_style] == :document
|
75
|
+
@router.add_document_operation(servant, *definitions)
|
76
|
+
else
|
77
|
+
@router.add_rpc_operation(servant, *definitions)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
@router.mapping_registry = #{mrname}::EncodedRegistry
|
81
|
+
@router.literal_mapping_registry = #{mrname}::LiteralRegistry
|
82
|
+
EOD
|
83
|
+
end
|
84
|
+
c1.dump + "\n" + c2.dump + format(<<-EOD)
|
85
|
+
|
86
|
+
if $0 == __FILE__
|
87
|
+
require 'webrick'
|
88
|
+
server = WEBrick::HTTPServer.new(
|
89
|
+
:BindAddress => "0.0.0.0",
|
90
|
+
:Port => 10080,
|
91
|
+
:DocumentRoot => "."
|
92
|
+
)
|
93
|
+
server.mount("/", #{c2.name}.new)
|
94
|
+
trap(:INT) do
|
95
|
+
server.shutdown
|
96
|
+
end
|
97
|
+
server.start
|
98
|
+
end
|
99
|
+
EOD
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|