diff --git a/lib/savon/soap/xml.rb b/lib/savon/soap/xml.rb
index ec4de14e..de449eb8 100644
--- a/lib/savon/soap/xml.rb
+++ b/lib/savon/soap/xml.rb
@@ -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.
diff --git a/spec/savon/soap/xml_spec.rb b/spec/savon/soap/xml_spec.rb
index 5a1e46cd..81af6d34 100644
--- a/spec/savon/soap/xml_spec.rb
+++ b/spec/savon/soap/xml_spec.rb
@@ -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('secret')
+ end
+ end
+ context "as a string" do
+ it "should contain the given header" do
+ xml.header = %{secret}
- xml.to_xml.should include('secret')
+ xml.to_xml.should include('secret')
+ end
end
end