summaryrefslogtreecommitdiff
path: root/lib/soap/streamHandler.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/soap/streamHandler.rb')
-rw-r--r--lib/soap/streamHandler.rb119
1 files changed, 16 insertions, 103 deletions
diff --git a/lib/soap/streamHandler.rb b/lib/soap/streamHandler.rb
index ac2f54d5c9..3890ac263f 100644
--- a/lib/soap/streamHandler.rb
+++ b/lib/soap/streamHandler.rb
@@ -7,12 +7,12 @@
require 'soap/soap'
-require 'soap/property'
+require 'soap/httpconfigloader'
begin
require 'stringio'
require 'zlib'
rescue LoadError
- STDERR.puts "Loading stringio or zlib failed. No gzipped response support." if $DEBUG
+ warn("Loading stringio or zlib failed. No gzipped response support.") if $DEBUG
end
@@ -27,7 +27,7 @@ class StreamHandler
end
HTTPAccess2::Client
rescue LoadError
- STDERR.puts "Loading http-access2 failed. Net/http is used." if $DEBUG
+ warn("Loading http-access2 failed. Net/http is used.") if $DEBUG
require 'soap/netHttpClient'
SOAP::NetHttpClient
end
@@ -40,6 +40,7 @@ class StreamHandler
attr_accessor :receive_string
attr_accessor :receive_contenttype
attr_accessor :is_fault
+ attr_accessor :soapaction
def initialize(send_string = nil)
@send_string = send_string
@@ -47,6 +48,7 @@ class StreamHandler
@receive_string = nil
@receive_contenttype = nil
@is_fault = false
+ @soapaction = nil
end
end
@@ -79,7 +81,7 @@ public
super()
@client = Client.new(nil, "SOAP4R/#{ Version }")
@wiredump_file_base = nil
- @charset = @wiredump_dev = @nil
+ @charset = @wiredump_dev = nil
@options = options
set_options
@client.debug_dev = @wiredump_dev
@@ -100,7 +102,8 @@ public
end
def send(endpoint_url, conn_data, soapaction = nil, charset = @charset)
- send_post(endpoint_url, conn_data, soapaction, charset)
+ conn_data.soapaction ||= soapaction # for backward conpatibility
+ send_post(endpoint_url, conn_data, charset)
end
def reset(endpoint_url = nil)
@@ -115,24 +118,7 @@ public
private
def set_options
- @client.proxy = @options["proxy"]
- @options.add_hook("proxy") do |key, value|
- @client.proxy = value
- end
- @client.no_proxy = @options["no_proxy"]
- @options.add_hook("no_proxy") do |key, value|
- @client.no_proxy = value
- end
- if @client.respond_to?(:protocol_version=)
- @client.protocol_version = @options["protocol_version"]
- @options.add_hook("protocol_version") do |key, value|
- @client.protocol_version = value
- end
- end
- set_cookie_store_file(@options["cookie_store_file"])
- @options.add_hook("cookie_store_file") do |key, value|
- set_cookie_store_file(value)
- end
+ HTTPConfigLoader.set_options(@client, @options)
@charset = @options["charset"] || XSD::Charset.charset_label($KCODE)
@options.add_hook("charset") do |key, value|
@charset = value
@@ -142,96 +128,23 @@ private
@wiredump_dev = value
@client.debug_dev = @wiredump_dev
end
- ssl_config = @options["ssl_config"] ||= ::SOAP::Property.new
- set_ssl_config(ssl_config)
- ssl_config.add_hook(true) do |key, value|
- set_ssl_config(ssl_config)
- end
- basic_auth = @options["basic_auth"] ||= ::SOAP::Property.new
- set_basic_auth(basic_auth)
- basic_auth.add_hook do |key, value|
- set_basic_auth(basic_auth)
- end
- @options.add_hook("connect_timeout") do |key, value|
- @client.connect_timeout = value
- end
- @options.add_hook("send_timeout") do |key, value|
- @client.send_timeout = value
- end
- @options.add_hook("receive_timeout") do |key, value|
- @client.receive_timeout = value
+ set_cookie_store_file(@options["cookie_store_file"])
+ @options.add_hook("cookie_store_file") do |key, value|
+ set_cookie_store_file(value)
end
+ ssl_config = @options["ssl_config"]
+ basic_auth = @options["basic_auth"]
@options.lock(true)
ssl_config.unlock
basic_auth.unlock
end
- def set_basic_auth(basic_auth)
- basic_auth.values.each do |url, userid, passwd|
- @client.set_basic_auth(url, userid, passwd)
- end
- end
-
def set_cookie_store_file(value)
@cookie_store = value
@client.set_cookie_store(@cookie_store) if @cookie_store
end
- def set_ssl_config(ssl_config)
- ssl_config.each do |key, value|
- cfg = @client.ssl_config
- case key
- when 'client_cert'
- cfg.client_cert = cert_from_file(value)
- when 'client_key'
- cfg.client_key = key_from_file(value)
- when 'client_ca'
- cfg.client_ca = value
- when 'ca_path'
- cfg.set_trust_ca(value)
- when 'ca_file'
- cfg.set_trust_ca(value)
- when 'crl'
- cfg.set_crl(value)
- when 'verify_mode'
- cfg.verify_mode = ssl_config_int(value)
- when 'verify_depth'
- cfg.verify_depth = ssl_config_int(value)
- when 'options'
- cfg.options = value
- when 'ciphers'
- cfg.ciphers = value
- when 'verify_callback'
- cfg.verify_callback = value
- when 'cert_store'
- cfg.cert_store = value
- else
- raise ArgumentError.new("unknown ssl_config property #{key}")
- end
- end
- end
-
- def ssl_config_int(value)
- if value.nil? or value.empty?
- nil
- else
- begin
- Integer(value)
- rescue ArgumentError
- ::SOAP::Property::Util.const_from_name(value)
- end
- end
- end
-
- def cert_from_file(filename)
- OpenSSL::X509::Certificate.new(File.open(filename) { |f| f.read })
- end
-
- def key_from_file(filename)
- OpenSSL::PKey::RSA.new(File.open(filename) { |f| f.read })
- end
-
- def send_post(endpoint_url, conn_data, soapaction, charset)
+ def send_post(endpoint_url, conn_data, charset)
conn_data.send_contenttype ||= StreamHandler.create_media_type(charset)
if @wiredump_file_base
@@ -243,7 +156,7 @@ private
extra = {}
extra['Content-Type'] = conn_data.send_contenttype
- extra['SOAPAction'] = "\"#{ soapaction }\""
+ extra['SOAPAction'] = "\"#{ conn_data.soapaction }\""
extra['Accept-Encoding'] = 'gzip' if send_accept_encoding_gzip?
send_string = conn_data.send_string
@wiredump_dev << "Wire dump:\n\n" if @wiredump_dev