# SOAP::FaultError in Ruby wsdl

**URL:** <https://www.ruby-forum.com/t/soap-faulterror-in-ruby-wsdl/184364>\
**Category:** Ruby\
**Created:** [March 1, 2010, 3:24pm UTC](https://www.ruby-forum.com/t/soap-faulterror-in-ruby-wsdl/184364 "2010-03-01T15:24:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vetrivel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/dc4da7/32.png) [@vetrivel](https://www.ruby-forum.com/u/vetrivel)\
**Post date:** [March 1, 2010, 3:24pm UTC](https://www.ruby-forum.com/t/soap-faulterror-in-ruby-wsdl/184364/1 "2010-03-01T15:24:25Z")

</div>

Dear Friends ,  
I am using ruby wsdl . Using wsdl2ruby I have generated client  
application . But the problem is that , I got the SOAP::FaultError if it  
is any error .

But the default.rb file has  
class NardaFault  
attr\_accessor :errorCode  
attr\_accessos :errorString

def initialize( errorCode , errorString)  
end  
end  
If there is no error i am getting proper reponse . But if i get any  
error from the server ,  
i am getting SOAP::FaultError only . But I need NardaFault Object , to  
fetch the errorCode and errorString.  
I have done one more thing also .

rescue =\> e  
puts e.inspect # SOAP::FaultError Object .  
puts e.faultcode.to\_s # I got SOAP::SOAPElement:0xb7cee264

My Question is that ,  
Whenever , error has come i need to rescue the error and i have to get  
the errorCode and errorString . But Always i am getting SOAP::FaultError  
only .

Thanks for Advance …

---

<div class="post-metadata">

**Author:** ![vetrivel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/dc4da7/32.png) [@vetrivel](https://www.ruby-forum.com/u/vetrivel)\
**Post date:** [March 1, 2010, 3:39pm UTC](https://www.ruby-forum.com/t/soap-faulterror-in-ruby-wsdl/184364/2 "2010-03-01T15:39:42Z")

</div>

Vetrivel Vaithilingam wrote:

> Dear Friends ,  
> I am using ruby wsdl . Using wsdl2ruby I have generated client  
> application . But the problem is that , I got the SOAP::FaultError if it  
> is any error .
> 
> But the default.rb file has  
> class NardaFault  
> attr\_accessor :errorCode  
> attr\_accessos :errorString
> 
> def initialize( errorCode , errorString)  
> end  
> end  
> If there is no error i am getting proper reponse . But if i get any  
> error from the server ,  
> i am getting SOAP::FaultError only . But I need NardaFault Object , to  
> fetch the errorCode and errorString.  
> I have done one more thing also .
> 
> rescue =\> e  
> puts e.inspect # SOAP::FaultError Object .  
> puts e.faultcode.to\_s # I got SOAP::SOAPElement:0xb7cee264
> 
> My Question is that ,  
> Whenever , error has come i need to rescue the error and i have to get  
> the errorCode and errorString . But Always i am getting SOAP::FaultError  
> only .
> 
> Thanks for Advance …

Sorry .  
I got the solution .  
The Solution is:-  
e.detail.fault.errorCode
