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

Allow the SOAP envelope header to be set as a String #289

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 8 additions & 1 deletion lib/savon/soap/xml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,14 @@ def complete_namespaces

# Returns the SOAP header as an XML String.
def header_for_xml
@header_for_xml ||= Gyoku.xml(header) + wsse_header
@header_for_xml ||=
begin
if Hash === header
Gyoku.xml(header)
else
header
end + wsse_header
end
end

# Returns the WSSE header or an empty String in case WSSE was not set.
Expand Down
21 changes: 15 additions & 6 deletions spec/savon/soap/xml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,22 @@
end

context "with a SOAP header" do
it "should contain the given header" do
xml.header = {
:token => "secret",
:attributes! => { :token => { :xmlns => "http://example.com" } }
}
context "as a hash" do
it "should contain the given header" do
xml.header = {
:token => "secret",
:attributes! => { :token => { :xmlns => "http://example.com" } }
}

xml.to_xml.should include('<env:Header><token xmlns="http://example.com">secret</token></env:Header>')
end
end
context "as a string" do
it "should contain the given header" do
xml.header = %{<token xmlns="http://example.com">secret</token>}

xml.to_xml.should include('<env:Header><token xmlns="http://example.com">secret</token></env:Header>')
xml.to_xml.should include('<env:Header><token xmlns="http://example.com">secret</token></env:Header>')
end
end
end

Expand Down