Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the option to generate an XML /SOAP in document mode without the 'tns:' prefix #277

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ To override the values on a specific controller just add an override as part of
Available properties are:

* **parser**: XML parser to use – `:rexml` or `:nokogiri`. The first one is default but the latter is much faster. Be sure to add `gem nokogiri` if you want to use it.
* **wsdl_style**: sets WSDL style. Supported values are: 'document' and 'rpc'.
* **wsdl_style**: sets WSDL style. Supported values are: 'rpc', 'document' or 'document_without_tns_prefix'.
* **catch_xml_errors**: intercept Rails parsing exceptions to return correct XML response for corrupt XML input. Default is `false`.
* **namespace**: SOAP namespace to use. Default is `urn:WashOut`.
* **snakecase_input**: Determines if WashOut should modify parameters keys to snakecase. Default is `false`.
Expand Down
9 changes: 9 additions & 0 deletions app/views/wash_out/document_without_tns_prefix/error.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
xml.instruct!
xml.tag! "soap:Envelope", "xmlns:soap" => 'http://schemas.xmlsoap.org/soap/envelope/' do
xml.tag! "soap:Body" do
xml.tag! "soap:Fault" do
xml.faultcode error_code
xml.faultstring error_message
end
end
end
17 changes: 17 additions & 0 deletions app/views/wash_out/document_without_tns_prefix/response.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
xml.instruct!
xml.tag! "soap:Envelope",
"xmlns:soap" => 'http://schemas.xmlsoap.org/soap/envelope/',
"xmlns:xsd" => 'http://www.w3.org/2001/XMLSchema' do
if !header.nil?
xml.tag! "soap:Header" do
xml.tag! "#{@action_spec[:response_tag]}" do
wsdl_data xml, header
end
end
end
xml.tag! "soap:Body" do
xml.tag! "#{@action_spec[:response_tag]}" do
wsdl_data xml, result
end
end
end
67 changes: 67 additions & 0 deletions app/views/wash_out/document_without_tns_prefix/wsdl.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
xml.instruct!
xml.definitions 'xmlns' => 'http://schemas.xmlsoap.org/wsdl/',
'xmlns:soap' => 'http://schemas.xmlsoap.org/wsdl/soap/',
'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
'xmlns:soap-enc' => 'http://schemas.xmlsoap.org/soap/encoding/',
'xmlns:wsdl' => 'http://schemas.xmlsoap.org/wsdl/',
'name' => @name,
'targetNamespace' => @namespace do

xml.types do
xml.tag! "schema", :targetNamespace => @namespace, :xmlns => 'http://www.w3.org/2001/XMLSchema' do
defined = []
@map.each do |operation, formats|
(formats[:in] + formats[:out]).each do |p|
wsdl_type xml, p, defined
end
end
end
end

@map.each do |operation, formats|
xml.message :name => "#{operation}" 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
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
@map.each do |operation, formats|
xml.operation :name => operation do
xml.input :message => "#{operation}"
xml.output :message => "#{formats[:response_tag]}"
end
end
end

xml.binding :name => "#{@name}_binding", :type => "#{@name}_port" do
xml.tag! "soap:binding", :style => 'document', :transport => 'http://schemas.xmlsoap.org/soap/http'
@map.keys.each do |operation|
xml.operation :name => operation do
xml.tag! "soap:operation", :soapAction => operation
xml.input do
xml.tag! "soap:body",
:use => "literal",
:namespace => @namespace
end
xml.output do
xml.tag! "soap:body",
:use => "literal",
:namespace => @namespace
end
end
end
end

xml.service :name => @service_name do
xml.port :name => "#{@name}_port", :binding => "#{@name}_binding" do
xml.tag! "soap:address", :location => WashOut::Router.url(request, @name)
end
end
end