railsware-soap4r 1.5.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +5 -0
- data/TODO +0 -0
- data/bin/wsdl2ruby.rb +137 -0
- data/bin/xsd2ruby.rb +90 -0
- data/lib/soap/XMLSchemaDatatypes.rb +9 -0
- data/lib/soap/XMLSchemaDatatypes1999.rb +10 -0
- data/lib/soap/attachment.rb +108 -0
- data/lib/soap/baseData.rb +1092 -0
- data/lib/soap/cgistub.rb +9 -0
- data/lib/soap/charset.rb +9 -0
- data/lib/soap/compat.rb +182 -0
- data/lib/soap/driver.rb +9 -0
- data/lib/soap/element.rb +277 -0
- data/lib/soap/encodingstyle/aspDotNetHandler.rb +207 -0
- data/lib/soap/encodingstyle/handler.rb +120 -0
- data/lib/soap/encodingstyle/literalHandler.rb +192 -0
- data/lib/soap/encodingstyle/soapHandler.rb +559 -0
- data/lib/soap/filter.rb +13 -0
- data/lib/soap/filter/filterchain.rb +51 -0
- data/lib/soap/filter/handler.rb +31 -0
- data/lib/soap/filter/streamhandler.rb +29 -0
- data/lib/soap/generator.rb +304 -0
- data/lib/soap/header/handler.rb +61 -0
- data/lib/soap/header/handlerset.rb +70 -0
- data/lib/soap/header/mappinghandler.rb +47 -0
- data/lib/soap/header/simplehandler.rb +44 -0
- data/lib/soap/httpconfigloader.rb +139 -0
- data/lib/soap/mapping.rb +12 -0
- data/lib/soap/mapping/encodedregistry.rb +548 -0
- data/lib/soap/mapping/factory.rb +388 -0
- data/lib/soap/mapping/literalregistry.rb +388 -0
- data/lib/soap/mapping/mapping.rb +609 -0
- data/lib/soap/mapping/registry.rb +295 -0
- data/lib/soap/mapping/rubytypeFactory.rb +478 -0
- data/lib/soap/mapping/schemadefinition.rb +170 -0
- data/lib/soap/mapping/typeMap.rb +106 -0
- data/lib/soap/mapping/wsdlencodedregistry.rb +211 -0
- data/lib/soap/mapping/wsdlliteralregistry.rb +243 -0
- data/lib/soap/mappingRegistry.rb +9 -0
- data/lib/soap/marshal.rb +59 -0
- data/lib/soap/mimemessage.rb +241 -0
- data/lib/soap/namespace.rb +9 -0
- data/lib/soap/nestedexception.rb +42 -0
- data/lib/soap/netHttpClient.rb +241 -0
- data/lib/soap/ns.rb +34 -0
- data/lib/soap/parser.rb +252 -0
- data/lib/soap/processor.rb +66 -0
- data/lib/soap/property.rb +333 -0
- data/lib/soap/proxy.rb +14 -0
- data/lib/soap/qname.rb +9 -0
- data/lib/soap/rpc/cgistub.rb +247 -0
- data/lib/soap/rpc/driver.rb +247 -0
- data/lib/soap/rpc/element.rb +369 -0
- data/lib/soap/rpc/httpserver.rb +169 -0
- data/lib/soap/rpc/proxy.rb +576 -0
- data/lib/soap/rpc/router.rb +669 -0
- data/lib/soap/rpc/rpc.rb +25 -0
- data/lib/soap/rpc/soaplet.rb +210 -0
- data/lib/soap/rpc/standaloneServer.rb +43 -0
- data/lib/soap/rpcRouter.rb +9 -0
- data/lib/soap/rpcUtils.rb +9 -0
- data/lib/soap/server.rb +9 -0
- data/lib/soap/soap.rb +151 -0
- data/lib/soap/standaloneServer.rb +9 -0
- data/lib/soap/streamHandler.rb +302 -0
- data/lib/soap/wsdlDriver.rb +597 -0
- data/lib/tags +5690 -0
- data/lib/wsdl/binding.rb +65 -0
- data/lib/wsdl/data.rb +64 -0
- data/lib/wsdl/definitions.rb +236 -0
- data/lib/wsdl/documentation.rb +32 -0
- data/lib/wsdl/import.rb +80 -0
- data/lib/wsdl/importer.rb +38 -0
- data/lib/wsdl/info.rb +50 -0
- data/lib/wsdl/message.rb +54 -0
- data/lib/wsdl/operation.rb +178 -0
- data/lib/wsdl/operationBinding.rb +130 -0
- data/lib/wsdl/param.rb +93 -0
- data/lib/wsdl/parser.rb +164 -0
- data/lib/wsdl/part.rb +52 -0
- data/lib/wsdl/port.rb +84 -0
- data/lib/wsdl/portType.rb +75 -0
- data/lib/wsdl/service.rb +61 -0
- data/lib/wsdl/soap/address.rb +40 -0
- data/lib/wsdl/soap/binding.rb +49 -0
- data/lib/wsdl/soap/body.rb +58 -0
- data/lib/wsdl/soap/cgiStubCreator.rb +93 -0
- data/lib/wsdl/soap/classDefCreator.rb +433 -0
- data/lib/wsdl/soap/classDefCreatorSupport.rb +230 -0
- data/lib/wsdl/soap/classNameCreator.rb +54 -0
- data/lib/wsdl/soap/clientSkeltonCreator.rb +95 -0
- data/lib/wsdl/soap/complexType.rb +172 -0
- data/lib/wsdl/soap/data.rb +42 -0
- data/lib/wsdl/soap/definitions.rb +200 -0
- data/lib/wsdl/soap/driverCreator.rb +118 -0
- data/lib/wsdl/soap/element.rb +33 -0
- data/lib/wsdl/soap/encodedMappingRegistryCreator.rb +73 -0
- data/lib/wsdl/soap/fault.rb +56 -0
- data/lib/wsdl/soap/header.rb +86 -0
- data/lib/wsdl/soap/headerfault.rb +56 -0
- data/lib/wsdl/soap/literalMappingRegistryCreator.rb +115 -0
- data/lib/wsdl/soap/mappingRegistryCreator.rb +58 -0
- data/lib/wsdl/soap/mappingRegistryCreatorSupport.rb +376 -0
- data/lib/wsdl/soap/methodDefCreator.rb +263 -0
- data/lib/wsdl/soap/operation.rb +122 -0
- data/lib/wsdl/soap/servantSkeltonCreator.rb +80 -0
- data/lib/wsdl/soap/servletStubCreator.rb +107 -0
- data/lib/wsdl/soap/standaloneServerStubCreator.rb +103 -0
- data/lib/wsdl/soap/wsdl2ruby.rb +217 -0
- data/lib/wsdl/types.rb +44 -0
- data/lib/wsdl/wsdl.rb +24 -0
- data/lib/wsdl/xmlSchema/all.rb +24 -0
- data/lib/wsdl/xmlSchema/annotation.rb +34 -0
- data/lib/wsdl/xmlSchema/any.rb +61 -0
- data/lib/wsdl/xmlSchema/anyAttribute.rb +48 -0
- data/lib/wsdl/xmlSchema/attribute.rb +123 -0
- data/lib/wsdl/xmlSchema/attributeGroup.rb +86 -0
- data/lib/wsdl/xmlSchema/choice.rb +58 -0
- data/lib/wsdl/xmlSchema/complexContent.rb +97 -0
- data/lib/wsdl/xmlSchema/complexExtension.rb +119 -0
- data/lib/wsdl/xmlSchema/complexRestriction.rb +104 -0
- data/lib/wsdl/xmlSchema/complexType.rb +193 -0
- data/lib/wsdl/xmlSchema/content.rb +95 -0
- data/lib/wsdl/xmlSchema/data.rb +116 -0
- data/lib/wsdl/xmlSchema/element.rb +173 -0
- data/lib/wsdl/xmlSchema/enumeration.rb +36 -0
- data/lib/wsdl/xmlSchema/fractiondigits.rb +37 -0
- data/lib/wsdl/xmlSchema/group.rb +118 -0
- data/lib/wsdl/xmlSchema/import.rb +53 -0
- data/lib/wsdl/xmlSchema/importHandler.rb +45 -0
- data/lib/wsdl/xmlSchema/importer.rb +102 -0
- data/lib/wsdl/xmlSchema/include.rb +48 -0
- data/lib/wsdl/xmlSchema/length.rb +37 -0
- data/lib/wsdl/xmlSchema/list.rb +48 -0
- data/lib/wsdl/xmlSchema/maxexclusive.rb +37 -0
- data/lib/wsdl/xmlSchema/maxinclusive.rb +37 -0
- data/lib/wsdl/xmlSchema/maxlength.rb +37 -0
- data/lib/wsdl/xmlSchema/minexclusive.rb +37 -0
- data/lib/wsdl/xmlSchema/mininclusive.rb +37 -0
- data/lib/wsdl/xmlSchema/minlength.rb +37 -0
- data/lib/wsdl/xmlSchema/parser.rb +167 -0
- data/lib/wsdl/xmlSchema/pattern.rb +36 -0
- data/lib/wsdl/xmlSchema/schema.rb +178 -0
- data/lib/wsdl/xmlSchema/sequence.rb +54 -0
- data/lib/wsdl/xmlSchema/simpleContent.rb +69 -0
- data/lib/wsdl/xmlSchema/simpleExtension.rb +62 -0
- data/lib/wsdl/xmlSchema/simpleRestriction.rb +132 -0
- data/lib/wsdl/xmlSchema/simpleType.rb +87 -0
- data/lib/wsdl/xmlSchema/totaldigits.rb +37 -0
- data/lib/wsdl/xmlSchema/union.rb +35 -0
- data/lib/wsdl/xmlSchema/unique.rb +34 -0
- data/lib/wsdl/xmlSchema/whitespace.rb +37 -0
- data/lib/wsdl/xmlSchema/xsd2ruby.rb +174 -0
- data/lib/xsd/charset.rb +189 -0
- data/lib/xsd/codegen.rb +12 -0
- data/lib/xsd/codegen/classdef.rb +208 -0
- data/lib/xsd/codegen/commentdef.rb +34 -0
- data/lib/xsd/codegen/gensupport.rb +273 -0
- data/lib/xsd/codegen/methoddef.rb +70 -0
- data/lib/xsd/codegen/moduledef.rb +208 -0
- data/lib/xsd/datatypes.rb +1466 -0
- data/lib/xsd/datatypes1999.rb +20 -0
- data/lib/xsd/iconvcharset.rb +33 -0
- data/lib/xsd/mapping.rb +67 -0
- data/lib/xsd/namedelements.rb +132 -0
- data/lib/xsd/ns.rb +182 -0
- data/lib/xsd/qname.rb +79 -0
- data/lib/xsd/xmlparser.rb +75 -0
- data/lib/xsd/xmlparser/parser.rb +100 -0
- data/lib/xsd/xmlparser/rexmlparser.rb +58 -0
- data/lib/xsd/xmlparser/xmlparser.rb +50 -0
- data/lib/xsd/xmlparser/xmlscanner.rb +149 -0
- data/soap4r.gemspec +218 -0
- metadata +233 -0
@@ -0,0 +1,9 @@
|
|
1
|
+
# SOAP4R - Standalone Server
|
2
|
+
# Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
3
|
+
|
4
|
+
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
5
|
+
# redistribute it and/or modify it under the same terms of Ruby's license;
|
6
|
+
# either the dual license version in 2003, or any later version.
|
7
|
+
|
8
|
+
|
9
|
+
require 'soap/compat'
|
@@ -0,0 +1,302 @@
|
|
1
|
+
# SOAP4R - Stream handler.
|
2
|
+
# Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
3
|
+
|
4
|
+
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
5
|
+
# redistribute it and/or modify it under the same terms of Ruby's license;
|
6
|
+
# either the dual license version in 2003, or any later version.
|
7
|
+
|
8
|
+
|
9
|
+
require 'soap/soap'
|
10
|
+
require 'soap/httpconfigloader'
|
11
|
+
require 'soap/filter/filterchain'
|
12
|
+
begin
|
13
|
+
require 'stringio'
|
14
|
+
require 'zlib'
|
15
|
+
rescue LoadError
|
16
|
+
warn("Loading stringio or zlib failed. No gzipped response support.") if $DEBUG
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
module SOAP
|
21
|
+
|
22
|
+
|
23
|
+
class StreamHandler
|
24
|
+
RUBY_VERSION_STRING = "ruby #{ RUBY_VERSION } (#{ RUBY_RELEASE_DATE }) [#{ RUBY_PLATFORM }]"
|
25
|
+
|
26
|
+
attr_reader :filterchain
|
27
|
+
|
28
|
+
class ConnectionData
|
29
|
+
attr_accessor :send_string
|
30
|
+
attr_accessor :send_contenttype
|
31
|
+
attr_accessor :receive_string
|
32
|
+
attr_accessor :receive_contenttype
|
33
|
+
attr_accessor :is_fault
|
34
|
+
attr_accessor :is_nocontent
|
35
|
+
attr_accessor :soapaction
|
36
|
+
|
37
|
+
def initialize(send_string = nil)
|
38
|
+
@send_string = send_string
|
39
|
+
@send_contenttype = nil
|
40
|
+
@receive_string = nil
|
41
|
+
@receive_contenttype = nil
|
42
|
+
@is_fault = false
|
43
|
+
@is_nocontent = false
|
44
|
+
@soapaction = nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def initialize
|
49
|
+
@filterchain = Filter::FilterChain.new
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.parse_media_type(str)
|
53
|
+
if /^#{ MediaType }(?:\s*;\s*charset=([^"]+|"[^"]+"))?$/i !~ str
|
54
|
+
return nil
|
55
|
+
end
|
56
|
+
charset = $1
|
57
|
+
charset.gsub!(/"/, '') if charset
|
58
|
+
charset || 'us-ascii'
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.create_media_type(charset)
|
62
|
+
"#{ MediaType }; charset=#{ charset }"
|
63
|
+
end
|
64
|
+
|
65
|
+
def send(url, conn_data, soapaction = nil, charset = nil)
|
66
|
+
# send a ConnectionData to specified url.
|
67
|
+
# return value is a ConnectionData with receive_* property filled.
|
68
|
+
# You can fill values of given conn_data and return it.
|
69
|
+
end
|
70
|
+
|
71
|
+
def reset(url = nil)
|
72
|
+
# for initializing connection status if needed.
|
73
|
+
# return value is not expected.
|
74
|
+
end
|
75
|
+
|
76
|
+
def set_wiredump_file_base(wiredump_file_base)
|
77
|
+
# for logging. return value is not expected.
|
78
|
+
# Override it when you want.
|
79
|
+
raise NotImplementedError
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_loopback_response
|
83
|
+
# for loopback testing. see HTTPStreamHandler for more detail.
|
84
|
+
# return value is an Array of loopback responses.
|
85
|
+
# Override it when you want.
|
86
|
+
raise NotImplementedError
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
class HTTPStreamHandler < StreamHandler
|
92
|
+
include SOAP
|
93
|
+
|
94
|
+
begin
|
95
|
+
require 'httpclient'
|
96
|
+
Client = HTTPClient
|
97
|
+
RETRYABLE = true
|
98
|
+
rescue LoadError
|
99
|
+
begin
|
100
|
+
require 'http-access2'
|
101
|
+
if HTTPAccess2::VERSION < "2.0"
|
102
|
+
raise LoadError.new("http-access/2.0 or later is required.")
|
103
|
+
end
|
104
|
+
Client = HTTPAccess2::Client
|
105
|
+
RETRYABLE = true
|
106
|
+
rescue LoadError
|
107
|
+
warn("Loading http-access2 failed. Net/http is used.") if $DEBUG
|
108
|
+
require 'soap/netHttpClient'
|
109
|
+
Client = SOAP::NetHttpClient
|
110
|
+
RETRYABLE = false
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
class HttpPostRequestFilter
|
115
|
+
def initialize(filterchain)
|
116
|
+
@filterchain = filterchain
|
117
|
+
end
|
118
|
+
|
119
|
+
def filter_request(req)
|
120
|
+
@filterchain.each do |filter|
|
121
|
+
filter.on_http_outbound(req)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def filter_response(req, res)
|
126
|
+
@filterchain.each do |filter|
|
127
|
+
filter.on_http_inbound(req, res)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
public
|
133
|
+
|
134
|
+
attr_reader :client
|
135
|
+
attr_accessor :wiredump_file_base
|
136
|
+
|
137
|
+
MAX_RETRY_COUNT = 10 # [times]
|
138
|
+
|
139
|
+
def self.create(options)
|
140
|
+
new(options)
|
141
|
+
end
|
142
|
+
|
143
|
+
def initialize(options)
|
144
|
+
super()
|
145
|
+
@client = Client.new(nil, "SOAP4R/#{ Version }")
|
146
|
+
if @client.respond_to?(:request_filter)
|
147
|
+
@client.request_filter << HttpPostRequestFilter.new(@filterchain)
|
148
|
+
end
|
149
|
+
@wiredump_file_base = nil
|
150
|
+
@charset = @wiredump_dev = nil
|
151
|
+
@options = options
|
152
|
+
set_options
|
153
|
+
@client.debug_dev = @wiredump_dev
|
154
|
+
@cookie_store = nil
|
155
|
+
@accept_encoding_gzip = false
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_loopback_response
|
159
|
+
@client.test_loopback_response
|
160
|
+
end
|
161
|
+
|
162
|
+
def accept_encoding_gzip=(allow)
|
163
|
+
@accept_encoding_gzip = allow
|
164
|
+
end
|
165
|
+
|
166
|
+
def inspect
|
167
|
+
"#<#{self.class}>"
|
168
|
+
end
|
169
|
+
|
170
|
+
def send(url, conn_data, soapaction = nil, charset = @charset)
|
171
|
+
conn_data.soapaction ||= soapaction # for backward conpatibility
|
172
|
+
conn_data = send_post(url, conn_data, charset)
|
173
|
+
@client.save_cookie_store if @cookie_store
|
174
|
+
conn_data
|
175
|
+
end
|
176
|
+
|
177
|
+
def reset(url = nil)
|
178
|
+
if url.nil?
|
179
|
+
@client.reset_all
|
180
|
+
else
|
181
|
+
@client.reset(url)
|
182
|
+
end
|
183
|
+
@client.save_cookie_store if @cookie_store
|
184
|
+
end
|
185
|
+
|
186
|
+
private
|
187
|
+
|
188
|
+
def set_options
|
189
|
+
@options["http"] ||= ::SOAP::Property.new
|
190
|
+
HTTPConfigLoader.set_options(@client, @options["http"])
|
191
|
+
@charset = @options["http.charset"] || XSD::Charset.xml_encoding_label
|
192
|
+
@options.add_hook("http.charset") do |key, value|
|
193
|
+
@charset = value
|
194
|
+
end
|
195
|
+
@wiredump_dev = @options["http.wiredump_dev"]
|
196
|
+
@options.add_hook("http.wiredump_dev") do |key, value|
|
197
|
+
@wiredump_dev = value
|
198
|
+
@client.debug_dev = @wiredump_dev
|
199
|
+
end
|
200
|
+
set_cookie_store_file(@options["http.cookie_store_file"])
|
201
|
+
@options.add_hook("http.cookie_store_file") do |key, value|
|
202
|
+
set_cookie_store_file(value)
|
203
|
+
end
|
204
|
+
ssl_config = @options["http.ssl_config"]
|
205
|
+
basic_auth = @options["http.basic_auth"]
|
206
|
+
auth = @options["http.auth"]
|
207
|
+
@options["http"].lock(true)
|
208
|
+
ssl_config.unlock
|
209
|
+
basic_auth.unlock
|
210
|
+
auth.unlock
|
211
|
+
end
|
212
|
+
|
213
|
+
def set_cookie_store_file(value)
|
214
|
+
value = nil if value and value.empty?
|
215
|
+
@cookie_store = value
|
216
|
+
@client.set_cookie_store(@cookie_store) if @cookie_store
|
217
|
+
end
|
218
|
+
|
219
|
+
def send_post(url, conn_data, charset)
|
220
|
+
conn_data.send_contenttype ||= StreamHandler.create_media_type(charset)
|
221
|
+
|
222
|
+
if @wiredump_file_base
|
223
|
+
filename = @wiredump_file_base + '_request.xml'
|
224
|
+
f = File.open(filename, "w")
|
225
|
+
f << conn_data.send_string
|
226
|
+
f.close
|
227
|
+
end
|
228
|
+
|
229
|
+
extheader = {}
|
230
|
+
extheader['Content-Type'] = conn_data.send_contenttype
|
231
|
+
extheader['SOAPAction'] = "\"#{ conn_data.soapaction }\""
|
232
|
+
extheader['Accept-Encoding'] = 'gzip' if send_accept_encoding_gzip?
|
233
|
+
send_string = conn_data.send_string
|
234
|
+
@wiredump_dev << "Wire dump:\n\n" if @wiredump_dev
|
235
|
+
begin
|
236
|
+
retry_count = 0
|
237
|
+
while true
|
238
|
+
res = @client.post(url, send_string, extheader)
|
239
|
+
if RETRYABLE and HTTP::Status.redirect?(res.status)
|
240
|
+
retry_count += 1
|
241
|
+
if retry_count >= MAX_RETRY_COUNT
|
242
|
+
raise HTTPStreamError.new("redirect count exceeded")
|
243
|
+
end
|
244
|
+
url = res.header["location"][0]
|
245
|
+
puts "redirected to #{url}" if $DEBUG
|
246
|
+
else
|
247
|
+
break
|
248
|
+
end
|
249
|
+
end
|
250
|
+
rescue
|
251
|
+
@client.reset(url)
|
252
|
+
raise
|
253
|
+
end
|
254
|
+
@wiredump_dev << "\n\n" if @wiredump_dev
|
255
|
+
receive_string = res.content
|
256
|
+
if @wiredump_file_base
|
257
|
+
filename = @wiredump_file_base + '_response.xml'
|
258
|
+
f = File.open(filename, "w")
|
259
|
+
f << receive_string
|
260
|
+
f.close
|
261
|
+
end
|
262
|
+
case res.status
|
263
|
+
when 405
|
264
|
+
raise PostUnavailableError.new("#{ res.status }: #{ res.reason }")
|
265
|
+
when 200, 202, 500
|
266
|
+
# Nothing to do. 202 is for oneway service.
|
267
|
+
else
|
268
|
+
raise HTTPStreamError.new("#{ res.status }: #{ res.reason }")
|
269
|
+
end
|
270
|
+
|
271
|
+
# decode gzipped content, if we know it's there from the headers
|
272
|
+
if res.respond_to?(:header) and !res.header['content-encoding'].empty? and
|
273
|
+
res.header['content-encoding'][0].downcase == 'gzip'
|
274
|
+
receive_string = decode_gzip(receive_string)
|
275
|
+
# otherwise check for the gzip header
|
276
|
+
elsif @accept_encoding_gzip && receive_string[0..1] == "\x1f\x8b"
|
277
|
+
receive_string = decode_gzip(receive_string)
|
278
|
+
end
|
279
|
+
conn_data.receive_string = receive_string
|
280
|
+
conn_data.receive_contenttype = res.contenttype
|
281
|
+
conn_data
|
282
|
+
end
|
283
|
+
|
284
|
+
def send_accept_encoding_gzip?
|
285
|
+
@accept_encoding_gzip and defined?(::Zlib)
|
286
|
+
end
|
287
|
+
|
288
|
+
def decode_gzip(instring)
|
289
|
+
unless send_accept_encoding_gzip?
|
290
|
+
raise HTTPStreamError.new("Gzipped response content.")
|
291
|
+
end
|
292
|
+
begin
|
293
|
+
gz = Zlib::GzipReader.new(StringIO.new(instring))
|
294
|
+
gz.read
|
295
|
+
ensure
|
296
|
+
gz.close
|
297
|
+
end
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
|
302
|
+
end
|
@@ -0,0 +1,597 @@
|
|
1
|
+
# SOAP4R - SOAP WSDL driver
|
2
|
+
# Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
3
|
+
|
4
|
+
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
5
|
+
# redistribute it and/or modify it under the same terms of Ruby's license;
|
6
|
+
# either the dual license version in 2003, or any later version.
|
7
|
+
|
8
|
+
|
9
|
+
require 'wsdl/parser'
|
10
|
+
require 'wsdl/importer'
|
11
|
+
require 'xsd/qname'
|
12
|
+
require 'xsd/codegen/gensupport'
|
13
|
+
require 'soap/mapping/wsdlencodedregistry'
|
14
|
+
require 'soap/mapping/wsdlliteralregistry'
|
15
|
+
require 'soap/rpc/driver'
|
16
|
+
require 'wsdl/soap/methodDefCreator'
|
17
|
+
require 'wsdl/soap/classDefCreatorSupport'
|
18
|
+
require 'wsdl/soap/classNameCreator'
|
19
|
+
|
20
|
+
|
21
|
+
module SOAP
|
22
|
+
|
23
|
+
|
24
|
+
class WSDLDriverFactory
|
25
|
+
include WSDL::SOAP::ClassDefCreatorSupport
|
26
|
+
|
27
|
+
class FactoryError < StandardError; end
|
28
|
+
|
29
|
+
attr_reader :wsdl
|
30
|
+
|
31
|
+
def initialize(wsdl)
|
32
|
+
@wsdl = import(wsdl)
|
33
|
+
name_creator = WSDL::SOAP::ClassNameCreator.new
|
34
|
+
@modulepath = 'WSDLDriverFactory'
|
35
|
+
@methoddefcreator =
|
36
|
+
WSDL::SOAP::MethodDefCreator.new(@wsdl, name_creator, @modulepath, {})
|
37
|
+
end
|
38
|
+
|
39
|
+
def inspect
|
40
|
+
sprintf("#<%s:%s:0x%x\n\n%s>", self.class.name, @wsdl.name, __id__, dump_method_signatures)
|
41
|
+
end
|
42
|
+
|
43
|
+
def create_rpc_driver(servicename = nil, portname = nil)
|
44
|
+
port = find_port(servicename, portname)
|
45
|
+
drv = SOAP::RPC::Driver.new(port.soap_address.location)
|
46
|
+
init_driver(drv, port)
|
47
|
+
add_operation(drv, port)
|
48
|
+
drv
|
49
|
+
end
|
50
|
+
|
51
|
+
# deprecated old interface
|
52
|
+
def create_driver(servicename = nil, portname = nil)
|
53
|
+
warn("WSDLDriverFactory#create_driver is deprecated. Use create_rpc_driver instead.")
|
54
|
+
port = find_port(servicename, portname)
|
55
|
+
WSDLDriver.new(@wsdl, port, nil)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Backward compatibility.
|
59
|
+
alias createDriver create_driver
|
60
|
+
|
61
|
+
def dump_method_signatures(servicename = nil, portname = nil)
|
62
|
+
targetservice = XSD::QName.new(@wsdl.targetnamespace, servicename) if servicename
|
63
|
+
targetport = XSD::QName.new(@wsdl.targetnamespace, portname) if portname
|
64
|
+
sig = []
|
65
|
+
element_definitions = @wsdl.collect_elements
|
66
|
+
@wsdl.services.each do |service|
|
67
|
+
next if targetservice and service.name != targetservice
|
68
|
+
service.ports.each do |port|
|
69
|
+
next if targetport and port.name != targetport
|
70
|
+
sig << port.porttype.operations.collect { |operation|
|
71
|
+
dump_method_signature(operation, element_definitions).gsub(/^#/, ' ')
|
72
|
+
}.join("\n")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
sig.join("\n")
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def find_port(servicename = nil, portname = nil)
|
81
|
+
service = port = nil
|
82
|
+
if servicename
|
83
|
+
service = @wsdl.service(
|
84
|
+
XSD::QName.new(@wsdl.targetnamespace, servicename))
|
85
|
+
else
|
86
|
+
service = @wsdl.services[0]
|
87
|
+
end
|
88
|
+
if service.nil?
|
89
|
+
raise FactoryError.new("service #{servicename} not found in WSDL")
|
90
|
+
end
|
91
|
+
if portname
|
92
|
+
port = service.ports[XSD::QName.new(@wsdl.targetnamespace, portname)]
|
93
|
+
if port.nil?
|
94
|
+
raise FactoryError.new("port #{portname} not found in WSDL")
|
95
|
+
end
|
96
|
+
else
|
97
|
+
port = service.ports.find { |port| !port.soap_address.nil? }
|
98
|
+
if port.nil?
|
99
|
+
raise FactoryError.new("no ports have soap:address")
|
100
|
+
end
|
101
|
+
end
|
102
|
+
if port.soap_address.nil?
|
103
|
+
raise FactoryError.new("soap:address element not found in WSDL")
|
104
|
+
end
|
105
|
+
port
|
106
|
+
end
|
107
|
+
|
108
|
+
def init_driver(drv, port)
|
109
|
+
wsdl_elements = @wsdl.collect_elements
|
110
|
+
wsdl_types = @wsdl.collect_complextypes + @wsdl.collect_simpletypes
|
111
|
+
rpc_decode_typemap = wsdl_types +
|
112
|
+
@wsdl.soap_rpc_complextypes(port.find_binding)
|
113
|
+
drv.proxy.mapping_registry =
|
114
|
+
Mapping::WSDLEncodedRegistry.new(rpc_decode_typemap)
|
115
|
+
drv.proxy.literal_mapping_registry =
|
116
|
+
Mapping::WSDLLiteralRegistry.new(wsdl_types, wsdl_elements)
|
117
|
+
end
|
118
|
+
|
119
|
+
def add_operation(drv, port)
|
120
|
+
port.find_binding.operations.each do |op_bind|
|
121
|
+
op_name = op_bind.soapoperation_name
|
122
|
+
soapaction = op_bind.soapaction || ''
|
123
|
+
orgname = op_name.name
|
124
|
+
name = XSD::CodeGen::GenSupport.safemethodname(orgname)
|
125
|
+
param_def = create_param_def(op_bind)
|
126
|
+
opt = {
|
127
|
+
:request_style => op_bind.soapoperation_style,
|
128
|
+
:response_style => op_bind.soapoperation_style,
|
129
|
+
:request_use => op_bind.soapbody_use_input,
|
130
|
+
:response_use => op_bind.soapbody_use_output
|
131
|
+
}
|
132
|
+
if op_bind.soapoperation_style == :rpc
|
133
|
+
drv.add_rpc_operation(op_name, soapaction, name, param_def, opt)
|
134
|
+
else
|
135
|
+
drv.add_document_operation(soapaction, name, param_def, opt)
|
136
|
+
end
|
137
|
+
if orgname != name and orgname.capitalize == name.capitalize
|
138
|
+
::SOAP::Mapping.define_singleton_method(drv, orgname) do |*arg|
|
139
|
+
__send__(name, *arg)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def import(location)
|
146
|
+
WSDL::Importer.import(location)
|
147
|
+
end
|
148
|
+
|
149
|
+
def create_param_def(op_bind)
|
150
|
+
op = op_bind.find_operation
|
151
|
+
if op_bind.soapoperation_style == :rpc
|
152
|
+
param_def = @methoddefcreator.collect_rpcparameter(op)
|
153
|
+
else
|
154
|
+
param_def = @methoddefcreator.collect_documentparameter(op)
|
155
|
+
end
|
156
|
+
# the first element of typedef in param_def is a String like
|
157
|
+
# "::SOAP::SOAPStruct". turn this String to a class.
|
158
|
+
param_def.collect { |io_type, name, param_type|
|
159
|
+
[io_type, name, ::SOAP::RPC::SOAPMethod.parse_param_type(param_type)]
|
160
|
+
}
|
161
|
+
end
|
162
|
+
|
163
|
+
def partqname(part)
|
164
|
+
if part.type
|
165
|
+
part.type
|
166
|
+
else
|
167
|
+
part.element
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def param_def(type, name, klass, partqname)
|
172
|
+
[type, name, [klass, partqname.namespace, partqname.name]]
|
173
|
+
end
|
174
|
+
|
175
|
+
def filter_parts(partsdef, partssource)
|
176
|
+
parts = partsdef.split(/\s+/)
|
177
|
+
partssource.find_all { |part| parts.include?(part.name) }
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
|
182
|
+
class WSDLDriver
|
183
|
+
class << self
|
184
|
+
if RUBY_VERSION >= "1.7.0"
|
185
|
+
def __attr_proxy(symbol, assignable = false)
|
186
|
+
name = symbol.to_s
|
187
|
+
define_method(name) {
|
188
|
+
@servant.__send__(name)
|
189
|
+
}
|
190
|
+
if assignable
|
191
|
+
aname = name + '='
|
192
|
+
define_method(aname) { |rhs|
|
193
|
+
@servant.__send__(aname, rhs)
|
194
|
+
}
|
195
|
+
end
|
196
|
+
end
|
197
|
+
else
|
198
|
+
def __attr_proxy(symbol, assignable = false)
|
199
|
+
name = symbol.to_s
|
200
|
+
module_eval <<-EOS
|
201
|
+
def #{name}
|
202
|
+
@servant.#{name}
|
203
|
+
end
|
204
|
+
EOS
|
205
|
+
if assignable
|
206
|
+
module_eval <<-EOS
|
207
|
+
def #{name}=(value)
|
208
|
+
@servant.#{name} = value
|
209
|
+
end
|
210
|
+
EOS
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
__attr_proxy :options
|
217
|
+
__attr_proxy :headerhandler
|
218
|
+
__attr_proxy :streamhandler
|
219
|
+
__attr_proxy :test_loopback_response
|
220
|
+
__attr_proxy :endpoint_url, true
|
221
|
+
__attr_proxy :mapping_registry, true # for RPC unmarshal
|
222
|
+
__attr_proxy :wsdl_mapping_registry, true # for RPC marshal
|
223
|
+
__attr_proxy :default_encodingstyle, true
|
224
|
+
__attr_proxy :generate_explicit_type, true
|
225
|
+
__attr_proxy :allow_unqualified_element, true
|
226
|
+
|
227
|
+
def httpproxy
|
228
|
+
@servant.options["protocol.http.proxy"]
|
229
|
+
end
|
230
|
+
|
231
|
+
def httpproxy=(httpproxy)
|
232
|
+
@servant.options["protocol.http.proxy"] = httpproxy
|
233
|
+
end
|
234
|
+
|
235
|
+
def wiredump_dev
|
236
|
+
@servant.options["protocol.http.wiredump_dev"]
|
237
|
+
end
|
238
|
+
|
239
|
+
def wiredump_dev=(wiredump_dev)
|
240
|
+
@servant.options["protocol.http.wiredump_dev"] = wiredump_dev
|
241
|
+
end
|
242
|
+
|
243
|
+
def mandatorycharset
|
244
|
+
@servant.options["protocol.mandatorycharset"]
|
245
|
+
end
|
246
|
+
|
247
|
+
def mandatorycharset=(mandatorycharset)
|
248
|
+
@servant.options["protocol.mandatorycharset"] = mandatorycharset
|
249
|
+
end
|
250
|
+
|
251
|
+
def wiredump_file_base
|
252
|
+
@servant.options["protocol.wiredump_file_base"]
|
253
|
+
end
|
254
|
+
|
255
|
+
def wiredump_file_base=(wiredump_file_base)
|
256
|
+
@servant.options["protocol.wiredump_file_base"] = wiredump_file_base
|
257
|
+
end
|
258
|
+
|
259
|
+
def initialize(wsdl, port, logdev)
|
260
|
+
@servant = Servant__.new(self, wsdl, port, logdev)
|
261
|
+
end
|
262
|
+
|
263
|
+
def inspect
|
264
|
+
"#<#{self.class}:#{@servant.port.name}>"
|
265
|
+
end
|
266
|
+
|
267
|
+
def reset_stream
|
268
|
+
@servant.reset_stream
|
269
|
+
end
|
270
|
+
|
271
|
+
# Backward compatibility.
|
272
|
+
alias generateEncodeType= generate_explicit_type=
|
273
|
+
|
274
|
+
class Servant__
|
275
|
+
include SOAP
|
276
|
+
|
277
|
+
attr_reader :options
|
278
|
+
attr_reader :port
|
279
|
+
|
280
|
+
attr_accessor :soapaction
|
281
|
+
attr_accessor :default_encodingstyle
|
282
|
+
attr_accessor :allow_unqualified_element
|
283
|
+
attr_accessor :generate_explicit_type
|
284
|
+
attr_accessor :mapping_registry
|
285
|
+
attr_accessor :wsdl_mapping_registry
|
286
|
+
|
287
|
+
def initialize(host, wsdl, port, logdev)
|
288
|
+
@host = host
|
289
|
+
@wsdl = wsdl
|
290
|
+
@port = port
|
291
|
+
@logdev = logdev
|
292
|
+
@soapaction = nil
|
293
|
+
@options = setup_options
|
294
|
+
@default_encodingstyle = nil
|
295
|
+
@allow_unqualified_element = nil
|
296
|
+
@generate_explicit_type = false
|
297
|
+
@mapping_registry = nil # for rpc unmarshal
|
298
|
+
@wsdl_mapping_registry = nil # for rpc marshal
|
299
|
+
@wiredump_file_base = nil
|
300
|
+
@mandatorycharset = nil
|
301
|
+
@wsdl_elements = @wsdl.collect_elements
|
302
|
+
@wsdl_types = @wsdl.collect_complextypes + @wsdl.collect_simpletypes
|
303
|
+
@rpc_decode_typemap = @wsdl_types +
|
304
|
+
@wsdl.soap_rpc_complextypes(port.find_binding)
|
305
|
+
@wsdl_mapping_registry = Mapping::WSDLEncodedRegistry.new(
|
306
|
+
@rpc_decode_typemap)
|
307
|
+
@doc_mapper = Mapping::WSDLLiteralRegistry.new(
|
308
|
+
@wsdl_types, @wsdl_elements)
|
309
|
+
endpoint_url = @port.soap_address.location
|
310
|
+
# Convert a map which key is QName, to a Hash which key is String.
|
311
|
+
@operation = {}
|
312
|
+
@port.inputoperation_map.each do |op_name, op_info|
|
313
|
+
orgname = op_name.name
|
314
|
+
name = XSD::CodeGen::GenSupport.safemethodname(orgname)
|
315
|
+
@operation[name] = @operation[orgname] = op_info
|
316
|
+
add_method_interface(op_info)
|
317
|
+
end
|
318
|
+
@proxy = ::SOAP::RPC::Proxy.new(endpoint_url, @soapaction, @options)
|
319
|
+
end
|
320
|
+
|
321
|
+
def inspect
|
322
|
+
"#<#{self.class}:#{@proxy.inspect}>"
|
323
|
+
end
|
324
|
+
|
325
|
+
def endpoint_url
|
326
|
+
@proxy.endpoint_url
|
327
|
+
end
|
328
|
+
|
329
|
+
def endpoint_url=(endpoint_url)
|
330
|
+
@proxy.endpoint_url = endpoint_url
|
331
|
+
end
|
332
|
+
|
333
|
+
def headerhandler
|
334
|
+
@proxy.headerhandler
|
335
|
+
end
|
336
|
+
|
337
|
+
def streamhandler
|
338
|
+
@proxy.streamhandler
|
339
|
+
end
|
340
|
+
|
341
|
+
def test_loopback_response
|
342
|
+
@proxy.test_loopback_response
|
343
|
+
end
|
344
|
+
|
345
|
+
def reset_stream
|
346
|
+
@proxy.reset_stream
|
347
|
+
end
|
348
|
+
|
349
|
+
def rpc_call(name, *values)
|
350
|
+
set_wiredump_file_base(name)
|
351
|
+
unless op_info = @operation[name]
|
352
|
+
raise RuntimeError, "method: #{name} not defined"
|
353
|
+
end
|
354
|
+
req_header = create_request_header
|
355
|
+
req_body = create_request_body(op_info, *values)
|
356
|
+
reqopt = create_options({
|
357
|
+
:soapaction => op_info.soapaction || @soapaction})
|
358
|
+
resopt = create_options({
|
359
|
+
:decode_typemap => @rpc_decode_typemap})
|
360
|
+
env = @proxy.route(req_header, req_body, reqopt, resopt)
|
361
|
+
raise EmptyResponseError unless env
|
362
|
+
receive_headers(env.header)
|
363
|
+
begin
|
364
|
+
@proxy.check_fault(env.body)
|
365
|
+
rescue ::SOAP::FaultError => e
|
366
|
+
Mapping.fault2exception(e)
|
367
|
+
end
|
368
|
+
ret = env.body.response ?
|
369
|
+
Mapping.soap2obj(env.body.response, @mapping_registry) : nil
|
370
|
+
if env.body.outparams
|
371
|
+
outparams = env.body.outparams.collect { |outparam|
|
372
|
+
Mapping.soap2obj(outparam)
|
373
|
+
}
|
374
|
+
return [ret].concat(outparams)
|
375
|
+
else
|
376
|
+
return ret
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
# req_header: [[element, mustunderstand, encodingstyle(QName/String)], ...]
|
381
|
+
# req_body: SOAPBasetype/SOAPCompoundtype
|
382
|
+
def document_send(name, header_obj, body_obj)
|
383
|
+
set_wiredump_file_base(name)
|
384
|
+
unless op_info = @operation[name]
|
385
|
+
raise RuntimeError, "method: #{name} not defined"
|
386
|
+
end
|
387
|
+
req_header = header_obj ? header_from_obj(header_obj, op_info) : nil
|
388
|
+
req_body = body_from_obj(body_obj, op_info)
|
389
|
+
opt = create_options({
|
390
|
+
:soapaction => op_info.soapaction || @soapaction,
|
391
|
+
:decode_typemap => @wsdl_types})
|
392
|
+
env = @proxy.invoke(req_header, req_body, opt)
|
393
|
+
raise EmptyResponseError unless env
|
394
|
+
if env.body.fault
|
395
|
+
raise ::SOAP::FaultError.new(env.body.fault)
|
396
|
+
end
|
397
|
+
res_body_obj = env.body.response ?
|
398
|
+
Mapping.soap2obj(env.body.response, @mapping_registry) : nil
|
399
|
+
return env.header, res_body_obj
|
400
|
+
end
|
401
|
+
|
402
|
+
private
|
403
|
+
|
404
|
+
def create_options(hash = nil)
|
405
|
+
opt = {}
|
406
|
+
opt[:default_encodingstyle] = @default_encodingstyle
|
407
|
+
opt[:allow_unqualified_element] = @allow_unqualified_element
|
408
|
+
opt[:generate_explicit_type] = @generate_explicit_type
|
409
|
+
opt.update(hash) if hash
|
410
|
+
opt
|
411
|
+
end
|
412
|
+
|
413
|
+
def set_wiredump_file_base(name)
|
414
|
+
if @wiredump_file_base
|
415
|
+
@proxy.set_wiredump_file_base(@wiredump_file_base + "_#{name}")
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
419
|
+
def create_request_header
|
420
|
+
header = SOAPHeader.new
|
421
|
+
items = @proxy.headerhandler.on_outbound(header)
|
422
|
+
items.each do |item|
|
423
|
+
header.add(item.elename.name, item)
|
424
|
+
end
|
425
|
+
header
|
426
|
+
end
|
427
|
+
|
428
|
+
def receive_headers(header)
|
429
|
+
@proxy.headerhandler.on_inbound(header) if header
|
430
|
+
end
|
431
|
+
|
432
|
+
def create_request_body(op_info, *values)
|
433
|
+
method = create_method_struct(op_info, *values)
|
434
|
+
SOAPBody.new(method)
|
435
|
+
end
|
436
|
+
|
437
|
+
def create_method_struct(op_info, *params)
|
438
|
+
parts_names = op_info.bodyparts.collect { |part| part.name }
|
439
|
+
obj = create_method_obj(parts_names, params)
|
440
|
+
method = Mapping.obj2soap(obj, @wsdl_mapping_registry, op_info.op_name)
|
441
|
+
if method.members.size != parts_names.size
|
442
|
+
new_method = SOAPStruct.new
|
443
|
+
method.each do |key, value|
|
444
|
+
if parts_names.include?(key)
|
445
|
+
new_method.add(key, value)
|
446
|
+
end
|
447
|
+
end
|
448
|
+
method = new_method
|
449
|
+
end
|
450
|
+
method.elename = op_info.op_name
|
451
|
+
method.type = XSD::QName.new # Request should not be typed.
|
452
|
+
method
|
453
|
+
end
|
454
|
+
|
455
|
+
def create_method_obj(names, params)
|
456
|
+
o = Object.new
|
457
|
+
idx = 0
|
458
|
+
while idx < params.length
|
459
|
+
o.instance_variable_set('@' + names[idx], params[idx])
|
460
|
+
idx += 1
|
461
|
+
end
|
462
|
+
o
|
463
|
+
end
|
464
|
+
|
465
|
+
def header_from_obj(obj, op_info)
|
466
|
+
if obj.is_a?(SOAPHeader)
|
467
|
+
obj
|
468
|
+
elsif op_info.headerparts.empty?
|
469
|
+
if obj.nil?
|
470
|
+
nil
|
471
|
+
else
|
472
|
+
raise RuntimeError.new("no header definition in schema: #{obj}")
|
473
|
+
end
|
474
|
+
elsif op_info.headerparts.size == 1
|
475
|
+
part = op_info.headerparts[0]
|
476
|
+
header = SOAPHeader.new()
|
477
|
+
header.add(headeritem_from_obj(obj, part.element || part.eletype))
|
478
|
+
header
|
479
|
+
else
|
480
|
+
header = SOAPHeader.new()
|
481
|
+
op_info.headerparts.each do |part|
|
482
|
+
child = Mapping.get_attribute(obj, part.name)
|
483
|
+
ele = headeritem_from_obj(child, part.element || part.eletype)
|
484
|
+
header.add(part.name, ele)
|
485
|
+
end
|
486
|
+
header
|
487
|
+
end
|
488
|
+
end
|
489
|
+
|
490
|
+
def headeritem_from_obj(obj, name)
|
491
|
+
if obj.nil?
|
492
|
+
SOAPElement.new(name)
|
493
|
+
elsif obj.is_a?(SOAPHeaderItem)
|
494
|
+
obj
|
495
|
+
else
|
496
|
+
Mapping.obj2soap(obj, @doc_mapper, name)
|
497
|
+
end
|
498
|
+
end
|
499
|
+
|
500
|
+
def body_from_obj(obj, op_info)
|
501
|
+
if obj.is_a?(SOAPBody)
|
502
|
+
obj
|
503
|
+
elsif op_info.bodyparts.empty?
|
504
|
+
if obj.nil?
|
505
|
+
nil
|
506
|
+
else
|
507
|
+
raise RuntimeError.new("no body found in schema")
|
508
|
+
end
|
509
|
+
elsif op_info.bodyparts.size == 1
|
510
|
+
part = op_info.bodyparts[0]
|
511
|
+
ele = bodyitem_from_obj(obj, part.element || part.type)
|
512
|
+
SOAPBody.new(ele)
|
513
|
+
else
|
514
|
+
body = SOAPBody.new
|
515
|
+
op_info.bodyparts.each do |part|
|
516
|
+
child = Mapping.get_attribute(obj, part.name)
|
517
|
+
ele = bodyitem_from_obj(child, part.element || part.type)
|
518
|
+
body.add(ele.elename.name, ele)
|
519
|
+
end
|
520
|
+
body
|
521
|
+
end
|
522
|
+
end
|
523
|
+
|
524
|
+
def bodyitem_from_obj(obj, name)
|
525
|
+
if obj.nil?
|
526
|
+
SOAPElement.new(name)
|
527
|
+
elsif obj.is_a?(SOAPElement)
|
528
|
+
obj
|
529
|
+
else
|
530
|
+
Mapping.obj2soap(obj, @doc_mapper, name)
|
531
|
+
end
|
532
|
+
end
|
533
|
+
|
534
|
+
def add_method_interface(op_info)
|
535
|
+
name = XSD::CodeGen::GenSupport.safemethodname(op_info.op_name.name)
|
536
|
+
orgname = op_info.op_name.name
|
537
|
+
parts_names = op_info.bodyparts.collect { |part| part.name }
|
538
|
+
case op_info.style
|
539
|
+
when :document
|
540
|
+
if orgname != name and orgname.capitalize == name.capitalize
|
541
|
+
add_document_method_interface(orgname, parts_names)
|
542
|
+
end
|
543
|
+
add_document_method_interface(name, parts_names)
|
544
|
+
when :rpc
|
545
|
+
if orgname != name and orgname.capitalize == name.capitalize
|
546
|
+
add_rpc_method_interface(orgname, parts_names)
|
547
|
+
end
|
548
|
+
add_rpc_method_interface(name, parts_names)
|
549
|
+
else
|
550
|
+
raise RuntimeError.new("unknown style: #{op_info.style}")
|
551
|
+
end
|
552
|
+
end
|
553
|
+
|
554
|
+
def add_rpc_method_interface(name, parts_names)
|
555
|
+
param_count = parts_names.size
|
556
|
+
@host.instance_eval <<-EOS
|
557
|
+
def #{name}(*arg)
|
558
|
+
unless arg.size == #{param_count}
|
559
|
+
raise ArgumentError.new(
|
560
|
+
"wrong number of arguments (\#{arg.size} for #{param_count})")
|
561
|
+
end
|
562
|
+
@servant.rpc_call(#{name.dump}, *arg)
|
563
|
+
end
|
564
|
+
EOS
|
565
|
+
@host.method(name)
|
566
|
+
end
|
567
|
+
|
568
|
+
def add_document_method_interface(name, parts_names)
|
569
|
+
@host.instance_eval <<-EOS
|
570
|
+
def #{name}(h, b)
|
571
|
+
@servant.document_send(#{name.dump}, h, b)
|
572
|
+
end
|
573
|
+
EOS
|
574
|
+
@host.method(name)
|
575
|
+
end
|
576
|
+
|
577
|
+
def setup_options
|
578
|
+
if opt = Property.loadproperty(::SOAP::PropertyName)
|
579
|
+
opt = opt["client"]
|
580
|
+
end
|
581
|
+
opt ||= Property.new
|
582
|
+
opt.add_hook("protocol.mandatorycharset") do |key, value|
|
583
|
+
@mandatorycharset = value
|
584
|
+
end
|
585
|
+
opt.add_hook("protocol.wiredump_file_base") do |key, value|
|
586
|
+
@wiredump_file_base = value
|
587
|
+
end
|
588
|
+
opt["protocol.http.charset"] ||= XSD::Charset.xml_encoding_label
|
589
|
+
opt["protocol.http.proxy"] ||= Env::HTTP_PROXY
|
590
|
+
opt["protocol.http.no_proxy"] ||= Env::NO_PROXY
|
591
|
+
opt
|
592
|
+
end
|
593
|
+
end
|
594
|
+
end
|
595
|
+
|
596
|
+
|
597
|
+
end
|