diff --git a/app/helpers/wash_out_helper.rb b/app/helpers/wash_out_helper.rb index 7a6008b..8170563 100644 --- a/app/helpers/wash_out_helper.rb +++ b/app/helpers/wash_out_helper.rb @@ -2,14 +2,22 @@ module WashOutHelper def wsdl_data_options(param) case controller.soap_config.wsdl_style - when 'rpc' + when :rpc if param.map.present? || !param.value.nil? { :"xsi:type" => param.namespaced_type } else { :"xsi:nil" => true } end - when 'document' - {} + when :document + if param.map && param.map.first.try(:multiplied) + count = param.map.first.map.count + { + :"xsi:type" => "SOAP-ENC:Array", + :"SOAP-ENC:arrayType" => "#{param.map.first.namespaced_type}[#{count}]" + } + else + { :"xsi:type" => param.namespaced_type } + end else {} end diff --git a/app/views/wash_out/document/response.builder b/app/views/wash_out/document/response.builder index 27bde38..7db1bc9 100644 --- a/app/views/wash_out/document/response.builder +++ b/app/views/wash_out/document/response.builder @@ -1,7 +1,10 @@ -xml.instruct! -xml.tag! "soap:Envelope", "xmlns:soap" => 'http://schemas.xmlsoap.org/soap/envelope/', - "xmlns:xsd" => 'http://www.w3.org/2001/XMLSchema', - "xmlns:tns" => @namespace do +xml.instruct! :xml, :version=>"1.0" +xml.tag! "SOAP-ENV:Envelope", + "xmlns:SOAP-ENV" => 'http://schemas.xmlsoap.org/soap/envelope/', + "xmlns:xsd" => 'http://www.w3.org/2001/XMLSchema', + "xmlns:xsi" => 'http://www.w3.org/2001/XMLSchema-instance', + "xmlns:SOAP-ENC" => "http://schemas.xmlsoap.org/soap/encoding/", + "xmlns:tns" => @namespace do if !header.nil? xml.tag! "soap:Header" do xml.tag! "tns:#{@action_spec[:response_tag]}" do @@ -9,8 +12,8 @@ xml.tag! "soap:Envelope", "xmlns:soap" => 'http://schemas.xmlsoap.org/soap/envel end end end - xml.tag! "soap:Body" do - xml.tag! "tns:#{@action_spec[:response_tag]}" do + xml.tag! "SOAP-ENV:Body" do + xml.tag! "ns1:#{@action_spec[:response_tag]}", { "xmlns:ns1" => "#{@namespace}"} do wsdl_data xml, result end end diff --git a/app/views/wash_out/document/wsdl.builder b/app/views/wash_out/document/wsdl.builder index b9e6546..53fbda8 100644 --- a/app/views/wash_out/document/wsdl.builder +++ b/app/views/wash_out/document/wsdl.builder @@ -20,28 +20,28 @@ xml.definitions 'xmlns' => 'http://schemas.xmlsoap.org/wsdl/', end @map.each do |operation, formats| - xml.message :name => "#{operation}" do + xml.message :name => "#{operation}Request" do formats[:in].each do |p| xml.part wsdl_occurence(p, false, :name => p.name, :type => p.namespaced_type) end end - xml.message :name => formats[:response_tag] do + xml.message :name => "#{operation}Response" do formats[:out].each do |p| xml.part wsdl_occurence(p, false, :name => p.name, :type => p.namespaced_type) end end end - xml.portType :name => "#{@name}_port" do + xml.portType :name => "#{@service_name}PortType" do @map.each do |operation, formats| xml.operation :name => operation do - xml.input :message => "tns:#{operation}" - xml.output :message => "tns:#{formats[:response_tag]}" + xml.input :message => "tns:#{operation}Request" + xml.output :message => "tns:#{operation}Response" end end end - xml.binding :name => "#{@name}_binding", :type => "tns:#{@name}_port" do + xml.binding :name => "#{@service_name}Binding", :type => "tns:#{@service_name}PortType" do xml.tag! "soap:binding", :style => 'document', :transport => 'http://schemas.xmlsoap.org/soap/http' @map.keys.each do |operation| xml.operation :name => operation do @@ -61,7 +61,7 @@ xml.definitions 'xmlns' => 'http://schemas.xmlsoap.org/wsdl/', end xml.service :name => @service_name do - xml.port :name => "#{@name}_port", :binding => "tns:#{@name}_binding" do + xml.port :name => "#{@service_name}Port", :binding => "tns:#{@service_name}Binding" do xml.tag! "soap:address", :location => WashOut::Router.url(request, @name) end end diff --git a/lib/wash_out.rb b/lib/wash_out.rb index b6952c3..d7f2e2c 100644 --- a/lib/wash_out.rb +++ b/lib/wash_out.rb @@ -26,11 +26,13 @@ def wash_out(controller_name, options={}) options.each{ |key, value| scope_frame[key] = value } end + action_path = options[:action_path] || "#{controller_name}/action" + controller_class_name = [scope_frame[:module], controller_name].compact.join("/").underscore match "#{controller_name}/wsdl" => "#{controller_name}#_generate_wsdl", :via => :get, :format => false, :as => "#{controller_class_name}_wsdl" - match "#{controller_name}/action" => WashOut::Router.new(controller_class_name), :via => [:get, :post], + match action_path => WashOut::Router.new(controller_class_name), :via => [:get, :post], :defaults => { :controller => controller_class_name, :action => 'soap' }, :format => false, :as => "#{controller_class_name}_soap" end diff --git a/lib/wash_out/router.rb b/lib/wash_out/router.rb index a066033..408f851 100644 --- a/lib/wash_out/router.rb +++ b/lib/wash_out/router.rb @@ -1,4 +1,5 @@ require 'nori' +require 'uri' module WashOut # This class is a Rack middleware used to route SOAP requests to a proper @@ -68,7 +69,7 @@ def parse_soap_action(env) soap_action.gsub!(/^(#{namespace}(\/|#)?)?([^"]*)$/, '\3') end - env['wash_out.soap_action'] = soap_action + env['wash_out.soap_action'] = URI(soap_action).path.split('/').last end def nori(snakecase=false) diff --git a/lib/wash_out/soap.rb b/lib/wash_out/soap.rb index ec5e25d..96bf788 100644 --- a/lib/wash_out/soap.rb +++ b/lib/wash_out/soap.rb @@ -33,7 +33,7 @@ def soap_action(action, options={}) end - default_response_tag = soap_config.camelize_wsdl ? 'Response' : '_response' + default_response_tag = 'Response' default_response_tag = action+default_response_tag diff --git a/lib/wash_out/type.rb b/lib/wash_out/type.rb index 043544d..40d0fe0 100644 --- a/lib/wash_out/type.rb +++ b/lib/wash_out/type.rb @@ -1,6 +1,5 @@ module WashOut class Type - def self.type_name(value) @param_type_name = value.to_s end