# What if a webservice is not available = "execution expired"

**URL:** <https://www.ruby-forum.com/t/what-if-a-webservice-is-not-available-execution-expired/56103>\
**Category:** Rails\
**Created:** [March 28, 2006, 6:16am UTC](https://www.ruby-forum.com/t/what-if-a-webservice-is-not-available-execution-expired/56103 "2006-03-28T06:16:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dracos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ea666f/32.png) [@dracos](https://www.ruby-forum.com/u/dracos)\
**Post date:** [March 28, 2006, 6:16am UTC](https://www.ruby-forum.com/t/what-if-a-webservice-is-not-available-execution-expired/56103/1 "2006-03-28T06:16:40Z")

</div>

Hi,

I’m using a webservice in my application. How can I make it so that my  
application will only try to connect to the webservice for a certain  
period of time and then give up?

Right now my code is using a begin-rescue-else but sometimes I get a  
“execution expired” error if the webservice is not available or takes  
too long to respond.

Thanks,  
Peter

begin  
service =  
SOAP::RPC::Driver.new(“[http://www.webservicex.net/CurrencyConvertor.asmx","http://www.webserviceX.NET/](http://www.webservicex.net/CurrencyConvertor.asmx%22,%22http://www.webserviceX.NET/)”)  
service.default\_encodingstyle =  
SOAP::EncodingStyle::ASPDotNetHandler::Namespace  
service.add\_method\_with\_soapaction(“ConversionRate”,  
“[http://www.webserviceX.NET/ConversionRate](http://www.webserviceX.NET/ConversionRate)”, “FromCurrency”,  
“ToCurrency”)

rate = service.ConversionRate(“CAD”,current\_currency).to\_f  
rescue  
sprintf(“$%0.2f CAN”, can\_amt)  
else  
case current\_currency  
when “USD”  
sprintf(“$%0.2f US”, can\_amt_rate)  
when “GBP”  
sprintf(“£%0.2f”, can\_amt_rate)  
when “EUR”  
sprintf(“?%0.2f”, can\_amt_rate)  
when “AUD”  
sprintf(“$%0.2f AUS”, can\_amt_rate)  
when “MXN”  
sprintf(“%0.2f Mx Pesos”, can\_amt\*rate)  
end  
end

---

<div class="post-metadata">

**Author:** ![dracos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ea666f/32.png) [@dracos](https://www.ruby-forum.com/u/dracos)\
**Post date:** [March 28, 2006, 6:46am UTC](https://www.ruby-forum.com/t/what-if-a-webservice-is-not-available-execution-expired/56103/2 "2006-03-28T06:46:54Z")

</div>

Resolved. I found Timeout.

Thanks,  
Peter
