Namespace

Files

Class Index [+]

Quicksearch

SOAP

This program is copyrighted free software by NAKAMURA, Hiroshi. You can redistribute it and/or modify it under the same terms of Ruby’s license; either the dual license version in 2003, or any later version.


This program is copyrighted free software by NAKAMURA, Hiroshi. You can redistribute it and/or modify it under the same terms of Ruby’s license; either the dual license version in 2003, or any later version.


This program is copyrighted free software by NAKAMURA, Hiroshi. You can redistribute it and/or modify it under the same terms of Ruby’s license; either the dual license version in 2003, or any later version.


This program is copyrighted free software by NAKAMURA, Hiroshi. You can redistribute it and/or modify it under the same terms of Ruby’s license; either the dual license version in 2003, or any later version.


This program is copyrighted free software by NAKAMURA, Hiroshi. You can redistribute it and/or modify it under the same terms of Ruby’s license; either the dual license version in 2003, or any later version.


This program is copyrighted free software by NAKAMURA, Hiroshi. You can redistribute it and/or modify it under the same terms of Ruby’s license; either the dual license version in 2003, or any later version.


This program is copyrighted free software by NAKAMURA, Hiroshi. You can redistribute it and/or modify it under the same terms of Ruby’s license; either the dual license version in 2003, or any later version.


This program is copyrighted free software by NAKAMURA, Hiroshi. You can redistribute it and/or modify it under the same terms of Ruby’s license; either the dual license version in 2003, or any later version.

Constants

TypeMap
EMPTY_ATTRIBUTES
Registry
DefaultRegistry
RubyOriginalRegistry
NO_PROXY_HOSTS
SOAPProxy
SOAPGenerator
NS
Charset
RPCUtils
RPCServerException
RPCRouter
VERSION
PropertyName
EnvelopeNamespace
EncodingNamespace
LiteralNamespace
NextActor
EleEnvelope
EleHeader
EleBody
EleFault
EleFaultString
EleFaultActor
EleFaultCode
EleFaultDetail
AttrMustUnderstand
AttrEncodingStyle
AttrActor
AttrRoot
AttrArrayType
AttrOffset
AttrPosition
AttrHref
AttrId
ValueArray
EleEnvelopeName
EleHeaderName
EleBodyName
EleFaultName
EleFaultStringName
EleFaultActorName
EleFaultCodeName
EleFaultDetailName
AttrActorName
AttrMustUnderstandName
AttrEncodingStyleName
AttrRootName
AttrArrayTypeName
AttrOffsetName
AttrPositionName
AttrHrefName
AttrIdName
ValueArrayName
Base64Literal
MediaType

Attributes

proxy[R]
no_proxy[RW]
debug_dev[RW]
ssl_config[RW]
protocol_version[RW]
connect_timeout[RW]
send_timeout[RW]
receive_timeout[RW]
test_loopback_response[R]
request_filter[R]

Public Class Methods

create_schema_definition(klass, definition) click to toggle source
     # File lib/soap/mapping/mapping.rb, line 466
466:   def self.create_schema_definition(klass, definition)
467:     schema_ns = definition[:schema_ns]
468:     schema_name = definition[:schema_name]
469:     schema_type = definition[:schema_type]
470:     is_anonymous = definition[:is_anonymous]
471:     schema_basetype = definition[:schema_basetype]
472:     # wrap if needed for backward compatibility
473:     if schema_ns
474:       schema_name = Mapping.to_qname(schema_name, schema_ns) if schema_name
475:       schema_type = Mapping.to_qname(schema_type, schema_ns) if schema_type
476:       # no need for schema_basetype bacause it's introduced later
477:     end
478:     schema_qualified = definition[:schema_qualified]
479:     schema_element = definition[:schema_element]
480:     schema_attributes = definition[:schema_attribute]
481:     definition = SchemaDefinition.new(klass, schema_name, schema_type, is_anonymous, schema_qualified)
482:     definition.basetype = schema_basetype
483:     definition.attributes = schema_attributes
484:     if schema_element
485:       if schema_element.respond_to?(:is_concrete_definition) and
486:           schema_element.is_concrete_definition
487:         definition.elements = schema_element
488:       else
489:         default_ns = schema_name.namespace if schema_name
490:         default_ns ||= schema_type.namespace if schema_type
491:         definition.elements = parse_schema_definition(schema_element, default_ns)
492:         if klass < ::Array
493:           definition.elements.set_array
494:         end
495:       end
496:     end
497:     definition
498:   end
external_ces() click to toggle source
     # File lib/soap/mapping/mapping.rb, line 413
413:   def self.external_ces
414:     Thread.current[:SOAPMapping][:ExternalCES]
415:   end
get_attribute(obj, attr_name) click to toggle source
     # File lib/soap/mapping/mapping.rb, line 328
328:   def self.get_attribute(obj, attr_name)
329:     case obj
330:     when ::SOAP::Mapping::Object
331:       return obj[attr_name]
332:     when ::Hash
333:       return obj[attr_name] || obj[attr_name.intern]
334:     else
335:       if obj.respond_to?(attr_name)
336:         return obj.__send__(attr_name)
337:       end
338:       iv = obj.instance_variables
339:       name = Mapping.safevarname(attr_name)
340:       if iv.include?("@#{name}")
341:         return obj.instance_variable_get("@#{name}")
342:       elsif iv.include?("@#{attr_name}")
343:         return obj.instance_variable_get("@#{attr_name}")
344:       end
345:       if obj.respond_to?(name)
346:         return obj.__send__(name)
347:       end
348:       nil
349:     end
350:   end
get_attributes(obj) click to toggle source
     # File lib/soap/mapping/mapping.rb, line 307
307:   def self.get_attributes(obj)
308:     if obj.is_a?(::Hash)
309:       obj
310:     else
311:       rs = {}
312:       obj.instance_variables.each do |ele|
313:         rs[ele.sub(/^@/, '')] = obj.instance_variable_get(ele)
314:       end
315:       rs
316:     end
317:   end
get_attributes_for_any(obj) click to toggle source
     # File lib/soap/mapping/mapping.rb, line 320
320:   def self.get_attributes_for_any(obj)
321:     if obj.respond_to?(:__xmlele_any)
322:       obj.__xmlele_any || EMPTY_ATTRIBUTES
323:     else
324:       get_attributes(obj)
325:     end
326:   end
new(proxy = nil, agent = nil) click to toggle source
    # File lib/soap/netHttpClient.rb, line 36
36:   def initialize(proxy = nil, agent = nil)
37:     @proxy = proxy ? URI.parse(proxy) : nil
38:     @agent = agent
39:     @debug_dev = nil
40:     @test_loopback_response = []
41:     @request_filter = Filter::FilterChain.new
42:     @session_manager = SessionManager.new
43:     @no_proxy = @ssl_config = @protocol_version = nil
44:     @connect_timeout = @send_timeout = @receive_timeout = nil
45:   end
parse_schema_definition(schema_element, default_ns) click to toggle source

for backward compatibility returns SchemaComplexTypeDefinition

     # File lib/soap/mapping/mapping.rb, line 502
502:   def self.parse_schema_definition(schema_element, default_ns)
503:     definition = nil
504:     if schema_element[0] == :choice
505:       schema_element.shift
506:       definition = SchemaChoiceDefinition.new
507:     else
508:       definition = SchemaSequenceDefinition.new
509:     end
510:     schema_element.each do |ele|
511:       element_definition = parse_schema_element_definition(ele, default_ns)
512:       definition << element_definition
513:     end
514:     definition
515:   end
parse_schema_element_definition(schema_element, default_ns) click to toggle source

returns SchemaElementDefinition

     # File lib/soap/mapping/mapping.rb, line 518
518:   def self.parse_schema_element_definition(schema_element, default_ns)
519:     if schema_element[0] == :choice
520:       parse_schema_definition(schema_element, default_ns)
521:     elsif schema_element[0].is_a?(Array)
522:       parse_schema_definition(schema_element, default_ns)
523:     else
524:       varname, info, occurrence = schema_element
525:       mapped_class_str, elename = info
526:       if occurrence
527:         minoccurs, maxoccurs = occurrence
528:       else
529:         # for backward compatibility
530:         minoccurs, maxoccurs = 1, 1
531:       end
532:       as_any = as_array = false
533:       if /\[\]$/ =~ mapped_class_str
534:         mapped_class_str = mapped_class_str.sub(/\[\]$/, '')
535:         if mapped_class_str.empty?
536:           mapped_class_str = nil
537:         end
538:         as_array = true
539:       end
540:       if mapped_class_str
541:         mapped_class = Mapping.class_from_name(mapped_class_str)
542:         if mapped_class.nil?
543:           warn("cannot find mapped class: #{mapped_class_str}")
544:         end
545:       end
546:       if elename == XSD::AnyTypeName
547:         as_any = true
548:       elsif elename.nil?
549:         elename = XSD::QName.new(default_ns, varname)
550:       end
551:       SchemaElementDefinition.new(
552:         varname, mapped_class, elename, minoccurs, maxoccurs, as_any, as_array)
553:     end
554:   end
reset_root_type_hint() click to toggle source
     # File lib/soap/mapping/mapping.rb, line 409
409:   def self.reset_root_type_hint
410:     Thread.current[:SOAPMapping][:RootTypeHint] = false
411:   end
root_type_hint() click to toggle source
     # File lib/soap/mapping/mapping.rb, line 405
405:   def self.root_type_hint
406:     Thread.current[:SOAPMapping][:RootTypeHint]
407:   end
safeconstname(name) click to toggle source
     # File lib/soap/mapping/mapping.rb, line 390
390:   def self.safeconstname(name)
391:     Thread.current[:SOAPMapping][:SafeConstName][name] ||=
392:       XSD::CodeGen::GenSupport.safeconstname(name)
393:   end
safemethodname(name) click to toggle source
     # File lib/soap/mapping/mapping.rb, line 395
395:   def self.safemethodname(name)
396:     Thread.current[:SOAPMapping][:SafeMethodName][name] ||=
397:       XSD::CodeGen::GenSupport.safemethodname(name)
398:   end
safevarname(name) click to toggle source
     # File lib/soap/mapping/mapping.rb, line 400
400:   def self.safevarname(name)
401:     Thread.current[:SOAPMapping][:SafeVarName][name] ||=
402:       XSD::CodeGen::GenSupport.safevarname(name)
403:   end
schema_attribute_definition(klass) click to toggle source
     # File lib/soap/mapping/mapping.rb, line 437
437:   def self.schema_attribute_definition(klass)
438:     class_schema_variable(:schema_attribute, klass)
439:   end
schema_definition_classdef(klass) click to toggle source
     # File lib/soap/mapping/mapping.rb, line 441
441:   def self.schema_definition_classdef(klass)
442:     if Thread.current[:SOAPMapping][:SchemaDefinition].key?(klass)
443:       return Thread.current[:SOAPMapping][:SchemaDefinition][klass]
444:     end
445:     schema_ns = schema_ns_definition(klass)
446:     schema_name = schema_name_definition(klass)
447:     schema_type = schema_type_definition(klass)
448:     qualified = schema_qualified_definition(klass)
449:     elements = schema_element_definition(klass)
450:     attributes = schema_attribute_definition(klass)
451:     return nil if schema_name.nil? and schema_type.nil?
452:     schema_name = Mapping.to_qname(schema_name, schema_ns) if schema_name
453:     schema_type = Mapping.to_qname(schema_type, schema_ns) if schema_type
454:     definition = create_schema_definition(klass,
455:       :schema_name => schema_name,
456:       :schema_type => schema_type,
457:       :is_anonymous => false,
458:       :schema_qualified => qualified,
459:       :schema_element => elements,
460:       :schema_attribute => attributes
461:     )
462:     Thread.current[:SOAPMapping][:SchemaDefinition][klass] = definition
463:     definition
464:   end
schema_element_definition(klass) click to toggle source
     # File lib/soap/mapping/mapping.rb, line 433
433:   def self.schema_element_definition(klass)
434:     class_schema_variable(:schema_element, klass)
435:   end
schema_name_definition(klass) click to toggle source
     # File lib/soap/mapping/mapping.rb, line 421
421:   def self.schema_name_definition(klass)
422:     class_schema_variable(:schema_name, klass)
423:   end
schema_ns_definition(klass) click to toggle source
     # File lib/soap/mapping/mapping.rb, line 417
417:   def self.schema_ns_definition(klass)
418:     class_schema_variable(:schema_ns, klass)
419:   end
schema_qualified_definition(klass) click to toggle source
     # File lib/soap/mapping/mapping.rb, line 429
429:   def self.schema_qualified_definition(klass)
430:     class_schema_variable(:schema_qualified, klass)
431:   end
schema_type_definition(klass) click to toggle source
     # File lib/soap/mapping/mapping.rb, line 425
425:   def self.schema_type_definition(klass)
426:     class_schema_variable(:schema_type, klass)
427:   end
set_attributes(obj, values) click to toggle source
     # File lib/soap/mapping/mapping.rb, line 352
352:   def self.set_attributes(obj, values)
353:     case obj
354:     when ::SOAP::Mapping::Object
355:       values.each do |attr_name, value|
356:         obj.__add_xmlele_value(attr_name, value)
357:       end
358:     else
359:       values.each do |attr_name, value|
360:         # untaint depends GenSupport.safevarname
361:         name = Mapping.safevarname(attr_name).untaint
362:         setter = name + "="
363:         if obj.respond_to?(setter)
364:           obj.__send__(setter, value)
365:         else
366:           obj.instance_variable_set('@' + name, value)
367:           begin
368:             unless obj.respond_to?(name)
369:               obj.instance_eval                 def #{name}                  @#{name}                end
370:             end
371:             unless self.respond_to?(name + "=")
372:               obj.instance_eval                 def #{name}=(value)                  @#{name} = value                end
373:             end
374:           rescue TypeError
375:             # singleton class may not exist (e.g. Float)
376:           end
377:         end
378:       end
379:     end
380:   end

Public Instance Methods

get_content(url, header = {}) click to toggle source
     # File lib/soap/netHttpClient.rb, line 95
 95:   def get_content(url, header = {})
 96:     if str = @test_loopback_response.shift
 97:       return str
 98:     end
 99:     unless url.is_a?(URI)
100:       url = URI.parse(url)
101:     end
102:     extra = header.dup
103:     extra['User-Agent'] = @agent if @agent
104:     res = start(url) { |http|
105:         http.get(url.request_uri, extra)
106:       }
107:     res.body
108:   end
post(url, req_body, header = {}) click to toggle source
    # File lib/soap/netHttpClient.rb, line 91
91:   def post(url, req_body, header = {})
92:     post_redirect(url, req_body, header, 10)
93:   end
proxy=(proxy) click to toggle source
    # File lib/soap/netHttpClient.rb, line 47
47:   def proxy=(proxy)
48:     if proxy.nil?
49:       @proxy = nil
50:     else
51:       if proxy.is_a?(URI)
52:         @proxy = proxy
53:       else
54:         @proxy = URI.parse(proxy)
55:       end
56:       if @proxy.scheme == nil or @proxy.scheme.downcase != 'http' or
57:           @proxy.host == nil or @proxy.port == nil
58:         raise ArgumentError.new("unsupported proxy `#{proxy}'")
59:       end
60:     end
61:     reset_all
62:     @proxy
63:   end
reset(url) click to toggle source
    # File lib/soap/netHttpClient.rb, line 83
83:   def reset(url)
84:     # no persistent connection.  ignored.
85:   end
reset_all() click to toggle source
    # File lib/soap/netHttpClient.rb, line 87
87:   def reset_all
88:     # no persistent connection.  ignored.
89:   end
set_auth(uri, user_id, passwd) click to toggle source
    # File lib/soap/netHttpClient.rb, line 65
65:   def set_auth(uri, user_id, passwd)
66:     raise NotImplementedError.new("auth is not supported under soap4r + net/http.")
67:   end
set_basic_auth(uri, user_id, passwd) click to toggle source
    # File lib/soap/netHttpClient.rb, line 69
69:   def set_basic_auth(uri, user_id, passwd)
70:     # net/http does not handle url.
71:     @basic_auth = [user_id, passwd]
72:     raise NotImplementedError.new("basic_auth is not supported under soap4r + net/http.")
73:   end

Private Instance Methods

create_connection(url) click to toggle source
     # File lib/soap/netHttpClient.rb, line 166
166:   def create_connection(url)
167:     proxy_host = proxy_port = nil
168:     unless no_proxy?(url)
169:       proxy_host = @proxy.host
170:       proxy_port = @proxy.port
171:     end
172:     http = Net::HTTP::Proxy(proxy_host, proxy_port).new(url.host, url.port)
173:     if http.respond_to?(:set_debug_output)
174:       http.set_debug_output(@debug_dev)
175:     end
176:     http.open_timeout = @connect_timeout if @connect_timeout
177:     http.read_timeout = @receive_timeout if @receive_timeout
178:     case url
179:     when URI::HTTPS
180:       if SSLEnabled
181:         http.use_ssl = true
182:       else
183:         raise RuntimeError.new("Cannot connect to #{url} (OpenSSL is not installed.)")
184:       end
185:     when URI::HTTP
186:       # OK
187:     else
188:       raise RuntimeError.new("Cannot connect to #{url} (Not HTTP.)")
189:     end
190:     http
191:   end
no_proxy?(uri) click to toggle source
     # File lib/soap/netHttpClient.rb, line 195
195:   def no_proxy?(uri)
196:     if !@proxy or NO_PROXY_HOSTS.include?(uri.host)
197:       return true
198:     end
199:     unless @no_proxy
200:       return false
201:     end
202:     @no_proxy.scan(/([^:,]+)(?::(\d+))?/) do |host, port|
203:       if /(\A|\.)#{Regexp.quote(host)}\z/ =~ uri.host &&
204:           (!port || uri.port == port.to_i)
205:         return true
206:       end
207:     end
208:     false
209:   end
post_redirect(url, req_body, header, redirect_count) click to toggle source
     # File lib/soap/netHttpClient.rb, line 112
112:   def post_redirect(url, req_body, header, redirect_count)
113:     if str = @test_loopback_response.shift
114:       if @debug_dev
115:         @debug_dev << "= Request\n\n"
116:         @debug_dev << req_body
117:         @debug_dev << "\n\n= Response\n\n"
118:         @debug_dev << str
119:       end
120:       status = 200
121:       reason = nil
122:       contenttype = 'text/xml'
123:       content = str
124:       return Response.new(status, reason, contenttype, content)
125:       return str
126:     end
127:     unless url.is_a?(URI)
128:       url = URI.parse(url)
129:     end
130:     extra = header.dup
131:     extra['User-Agent'] = @agent if @agent
132:     res = start(url) { |http|
133:       if @debug_dev
134:         @debug_dev << "= Request\n\n"
135:         @debug_dev << req_body << "\n"
136:       end
137:       http.post(url.request_uri, req_body, extra)
138:     }
139:     case res
140:     when Net::HTTPRedirection 
141:       if redirect_count > 0
142:         post_redirect(res['location'], req_body, header,
143:           redirect_count - 1) 
144:       else
145:        raise ArgumentError.new("Too many redirects")
146:       end
147:     else
148:       Response.from_httpresponse(res)
149:     end
150:   end
start(url) click to toggle source
     # File lib/soap/netHttpClient.rb, line 152
152:   def start(url)
153:     http = create_connection(url)
154:     response = nil
155:     http.start { |worker|
156:       response = yield(worker)
157:       worker.finish
158:     }
159:     if @debug_dev
160:       @debug_dev << "\n\n= Response\n\n"
161:       @debug_dev << response.body << "\n"
162:     end
163:     response
164:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.