Skip to content

Commit

Permalink
fix for issue #107
Browse files Browse the repository at this point in the history
  • Loading branch information
rubiii committed Nov 10, 2010
1 parent 0aaca23 commit 1d6eda2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/savon/soap/fault.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def initialize(http)

# Returns whether a SOAP fault is present.
def present?
@present ||= http.body =~ /<soap:Fault>/
@present ||= http.body =~ /<(.+:)?Body>(\s*)<(.+:)?Fault>/
end

# Returns the SOAP fault message.
Expand Down
4 changes: 4 additions & 0 deletions spec/fixtures/response/response_fixture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def soap_fault12
@soap_fault12 ||= load_fixture :soap_fault12
end

def another_soap_fault
@another_soap_fault ||= load_fixture :another_soap_fault
end

def multi_ref
@multi_ref ||= load_fixture :multi_ref
end
Expand Down
14 changes: 14 additions & 0 deletions spec/fixtures/response/xml/another_soap_fault.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>ERR_NO_SESSION</faultcode>
<faultfactor>doGetItemsInfo - Wrong session</faultfactor>
<faultstring>Wrong session message</faultstring>
<detail><soapVal><ERRNO xsi:type="xsd:string">80:1289245853:55</ERRNO></soapVal></detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
9 changes: 9 additions & 0 deletions spec/savon/soap/fault_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
describe Savon::SOAP::Fault do
let(:soap_fault) { Savon::SOAP::Fault.new new_response(:body => ResponseFixture.soap_fault) }
let(:soap_fault2) { Savon::SOAP::Fault.new new_response(:body => ResponseFixture.soap_fault12) }
let(:another_soap_fault) { Savon::SOAP::Fault.new new_response(:body => ResponseFixture.another_soap_fault) }
let(:no_fault) { Savon::SOAP::Fault.new new_response }

it "should be a Savon::Error" do
Expand All @@ -24,6 +25,10 @@
soap_fault2.should be_present
end

it "should return true if the HTTP response contains a SOAP fault with different namespaces" do
another_soap_fault.should be_present
end

it "should return false unless the HTTP response contains a SOAP fault" do
no_fault.should_not be_present
end
Expand All @@ -42,6 +47,10 @@
it "should return a SOAP 1.2 fault message" do
soap_fault2.send(method).should == "(soap:Sender) Sender Timeout"
end

it "should return a SOAP fault message (with different namespaces)" do
another_soap_fault.send(method).should == "(ERR_NO_SESSION) Wrong session message"
end
end
end

Expand Down

0 comments on commit 1d6eda2

Please sign in to comment.