-
-
Save speedmax/9cc616c94f366c599df0 to your computer and use it in GitHub Desktop.
shameful hack to add default namespace to handsoap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Handsoap | |
class Service | |
def invoke(action, options = { :soap_action => :auto }, &block) # :yields: Handsoap::XmlMason::Element | |
if action | |
if options.kind_of? String | |
options = { :soap_action => options } | |
end | |
if options[:soap_action] == :auto | |
options[:soap_action] = action.gsub(/^.+:/, "") | |
elsif options[:soap_action] == :none | |
options[:soap_action] = nil | |
end | |
doc = make_envelope do |body,header| | |
if options[:soap_header] | |
iterate_hash_array(header, options[:soap_header]) | |
end | |
if options[:soap_body] | |
action_hash = { action => options[:soap_body] } | |
iterate_hash_array(body, action_hash) | |
else | |
body.add(action) | |
end | |
begin | |
if default = body.get_namespace('xmlns') | |
body.set_attr('xmlns', default) | |
end | |
rescue | |
nil | |
end | |
end | |
if block_given? | |
yield doc.find(action) | |
end | |
# ready to dispatch | |
headers = { | |
"Content-Type" => "#{self.request_content_type};charset=UTF-8" | |
} | |
headers["SOAPAction"] = options[:soap_action] unless options[:soap_action].nil? | |
on_before_dispatch | |
request = make_http_request(self.uri, doc.to_s, headers,options[:http_options]) | |
response = http_driver_instance.send_http_request(request) | |
parse_http_response(response) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this operation register with your default namespace