From: Nate Imaqaguy Date: 2006-08-04T23:42:13+09:00 Subject: Re: How to capture a SOAP exception w/ ruby? Hello. = ) I know I'm close on this one--I can feel it. Can anyone help? I'd appreciate it a lot. Thanks, -nate Nate Imaqaguy wrote: > Hmmm… > > **If** I understand what you were trying to tell me, I **think** I > adapted your example to my code and came up with this. BTW, “param” is > an int I’m passing to the method. > > ---------------------------- > if results = soap.FindPatientById( param ) > then puts results.first_name > puts results.last_name > else > begin > rescue ::SOAP::FaultError => e > # rescue ::XSD::ValueSpaceError => e > puts e.to_s > end > end > ----------------------------- > > I had something pretty similar to this already. …but it’s not > working. > > The way I’m doing it, I don’t think I needed the “assert equal” > statement—right? The most confusing parts to me are the “rescue” lines. > Specifically, which one to use (I went with SOAP, but tried both) and > how you knew to put “FaultError” there. > > Like I said, I’m a total n00b to ruby. I haven’t even tried programming > anything since my last C class about 6 years ago, so please be patient > if I’m missing something obvious. > > = ) > > Thanks again, > > -nate > > > > > > Chris McMahon wrote: >> begin >> @query = @soap.apiFunction( >> {'Key'=>'Value','Key2'=>Value2'} >> ) >> #rescue ::SOAP::FaultError => e >> rescue ::XSD::ValueSpaceError => e >> assert_equal("{http://www.foo.com/api}FooBarEnum: cannot accept >> 'foo'",e.to_s) >> end >> >> Hope that helps... >> -Chris -- Posted via http://www.ruby-forum.com/.