Skip to content

Commit

Permalink
savonrb#546 making request with raw xml using xml_envelope() ( shortc…
Browse files Browse the repository at this point in the history
…utting operation.build() )
  • Loading branch information
solidlight committed Feb 9, 2014
1 parent f47b5c6 commit 9c70aac
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## 3.0.0 (branch)
* Fix: [#546] (https://github.com/savonrb/savon/issues/546) Making request with raw xml, shortcutting the build method: `operation.xml_envelope`

* Fix: [#539] (https://github.com/savonrb/savon/issues/539) Implement element form 'qualified' or 'unqualified' correctly

* This version requires Ruby 1.9.2 or higher. Ruby 1.8 is no longer supported!
Expand Down
7 changes: 6 additions & 1 deletion lib/savon/operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,14 @@ def build
Envelope.new(@operation, header, body).to_s
end

# Public: Sets the request envelope XML. Use in place of body().
attr_accessor :xml_envelope

# Public: Call the operation.
def call
raw_response = @http.post(endpoint, http_headers, build)
message = (xml_envelope != nil ? xml_envelope : build)

raw_response = @http.post(endpoint, http_headers, message)
Response.new(raw_response)
end

Expand Down
29 changes: 29 additions & 0 deletions spec/savon/operation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,35 @@
end
end

describe '#xml_envelope' do
let(:xml) do
'<?xml version="1.0" encoding="UTF-8"?>
<Envelope>
<Body>
<VerifySignature>
<UrlEndPoint></UrlEndPoint>
<HttpParameters></HttpParameters>
</VerifySignature>
</Body>
</Envelope>'
end

it 'returns the xml request' do
http_mock.fake_request('http://www.webservicex.net/ConvertTemperature.asmx')
operation.xml_envelope = xml

expect(operation.xml_envelope).to eq(xml)
end

it 'returns a Savon response object' do
http_mock.fake_request('http://www.webservicex.net/ConvertTemperature.asmx')
operation.xml_envelope = xml

response = operation.call
expect(response).to be_a(Savon::Response)
end
end

describe '#call' do
it 'calls the operation with a Hash of options and returns a Response' do
http_mock.fake_request('http://www.webservicex.net/ConvertTemperature.asmx')
Expand Down

0 comments on commit 9c70aac

Please sign in to comment.