Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions app/helpers/wash_out_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions app/views/wash_out/document/response.builder
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
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
wsdl_data xml, header
end
end
end
xml.tag! "soap:Body" do
xml.tag! "tns:#{@action_spec[:response_tag]}" do
xml.tag! "SOAP-ENV:Body" do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Estamos exponiendo el Body del tag SOAP-ENV y esto pudiera ofender al tag por hacer Body Shamming

xml.tag! "ns1:#{@action_spec[:response_tag]}", { "xmlns:ns1" => "#{@namespace}"} do
wsdl_data xml, result
end
end
Expand Down
14 changes: 7 additions & 7 deletions app/views/wash_out/document/wsdl.builder
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/wash_out.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/wash_out/router.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'nori'
require 'uri'

module WashOut
# This class is a Rack middleware used to route SOAP requests to a proper
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/wash_out/soap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def soap_action(action, options={})

end

default_response_tag = soap_config.camelize_wsdl ? 'Response' : '_response'
default_response_tag = 'Response'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creo que esto debería estar freeze o ser un sym, si no se crean objetos en memoria que el GC de ruby va a tener que salir a allocar en tiempo de request.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default_response_tag = action+default_response_tag


Expand Down
1 change: 0 additions & 1 deletion lib/wash_out/type.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module WashOut
class Type

def self.type_name(value)
@param_type_name = value.to_s
end
Expand Down