From bf89f2f1e5bdc48647d57951e488f22ff0e2be7a Mon Sep 17 00:00:00 2001 From: Abraham Barrera Date: Sun, 7 Jul 2019 22:20:51 -0400 Subject: [PATCH 1/6] WSDL format --- app/views/wash_out/document/wsdl.builder | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 From 646361b7769aec5277a7429c1096cb68aebdf15f Mon Sep 17 00:00:00 2001 From: Abraham Barrera Date: Sun, 7 Jul 2019 22:21:22 -0400 Subject: [PATCH 2/6] Custom action endpoint --- lib/wash_out.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 From 9e1a589c4e29db74348a21fa16f5714e3e347c79 Mon Sep 17 00:00:00 2001 From: Abraham Barrera Date: Sun, 7 Jul 2019 22:22:12 -0400 Subject: [PATCH 3/6] Ignores camelize wsdl option, and force response sufix Response --- lib/wash_out/soap.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From e229610363abd272bd11d8ed63747a6d7f3583cd Mon Sep 17 00:00:00 2001 From: Abraham Barrera Date: Sun, 7 Jul 2019 22:23:28 -0400 Subject: [PATCH 4/6] Use Soap action without entire path --- lib/wash_out/router.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) From 2f5ace05c7809bc14dd2e68b83a339051fa72461 Mon Sep 17 00:00:00 2001 From: Abraham Barrera Date: Mon, 8 Jul 2019 15:33:07 -0400 Subject: [PATCH 5/6] Support RAW XML format --- app/views/wash_out/document/response.builder | 22 +++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app/views/wash_out/document/response.builder b/app/views/wash_out/document/response.builder index 27bde38..4dce131 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,9 +12,14 @@ 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 - wsdl_data xml, result + xml.tag! "SOAP-ENV:Body" do + xml.tag! "ns1:#{@action_spec[:response_tag]}", { "xmlns:ns1" => "urn:TimeTracking"} do + first_result = result.first + if first_result && first_result.type == 'xml' + xml.<<(result.first.value) + else + wsdl_data xml, result + end end end end From 911e86d33634b63658328f2f38aa656d8961b81b Mon Sep 17 00:00:00 2001 From: Abraham Barrera Date: Wed, 10 Jul 2019 18:24:21 -0400 Subject: [PATCH 6/6] Better support for array elements --- app/helpers/wash_out_helper.rb | 14 +++++++++++--- app/views/wash_out/document/response.builder | 9 ++------- lib/wash_out/type.rb | 1 - 3 files changed, 13 insertions(+), 11 deletions(-) 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 4dce131..7db1bc9 100644 --- a/app/views/wash_out/document/response.builder +++ b/app/views/wash_out/document/response.builder @@ -13,13 +13,8 @@ xml.tag! "SOAP-ENV:Envelope", end end xml.tag! "SOAP-ENV:Body" do - xml.tag! "ns1:#{@action_spec[:response_tag]}", { "xmlns:ns1" => "urn:TimeTracking"} do - first_result = result.first - if first_result && first_result.type == 'xml' - xml.<<(result.first.value) - else - wsdl_data xml, result - end + xml.tag! "ns1:#{@action_spec[:response_tag]}", { "xmlns:ns1" => "#{@namespace}"} do + wsdl_data xml, result end end end 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