# Realise a web service with ruby on rails

**URL:** <https://www.ruby-forum.com/t/realise-a-web-service-with-ruby-on-rails/123038>\
**Category:** Rails\
**Created:** [December 13, 2007, 4:22pm UTC](https://www.ruby-forum.com/t/realise-a-web-service-with-ruby-on-rails/123038 "2007-12-13T16:22:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fafarun](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/2bfe46/32.png) [@fafarun](https://www.ruby-forum.com/u/fafarun)\
**Post date:** [December 13, 2007, 4:22pm UTC](https://www.ruby-forum.com/t/realise-a-web-service-with-ruby-on-rails/123038/1 "2007-12-13T16:22:33Z")

</div>

Hi ,  
I want realize a web service with rails, but it’s the response it’s  
very slow. I want only saw all element present in my base.  
I did a base Customers (with element like id, name, phone,…). I  
added two elements.  
I did a model customer, a web\_service customer.

In the file /app/apis/customer\_api.rb  
class CustomerApi \< ActionWebService::API::Base  
api\_method :listid, :expects =\> [:int], :returns =\> [Customer]  
api\_method :listall, :returns =\> [[:int]]

In the file /app/controller/customer\_controller.rb

class CustomerController \< ApplicationController  
wsdl\_service\_name ‘Customer’  
web\_service\_scaffold :invoke

def listid(id)  
Customer.find(id)  
end

def listall  
Customer.find(:all).map{ |customer| customer.id }  
end  
end

I finished my server web\_service.  
I realised a client  
I generated a controller client  
/app/controller/client\_controller.rb

class ClientController \< ApplicationController  
web\_client\_api :customer,  
:soap,  
“[http://localhost:3000/customer/api](http://localhost:3000/customer/api)”  
def list  
customer.listall.map do |id|  
@customers = customer.listid(id)  
end  
end  
end

But when I do  
[http://localhost:3000/client/list](http://localhost:3000/client/list)  
my firefox search and send my mongrel server send :  
Timeout::Error in ClientController#list2

execution expired

RAILS\_ROOT: /var/www/fabdev/config/…  
Application Trace | Framework Trace | Full Trace

/usr/lib/ruby/1.8/timeout.rb:54:in `rbuf_fill' /usr/lib/ruby/1.8/timeout.rb:56:in `timeout’  
/usr/lib/ruby/1.8/timeout.rb:76:in `timeout' /usr/lib/ruby/1.8/net/protocol.rb:132:in `rbuf\_fill’  
/usr/lib/ruby/1.8/net/protocol.rb:116:in `readuntil' /usr/lib/ruby/1.8/net/protocol.rb:126:in `readline’  
/usr/lib/ruby/1.8/net/http.rb:2020:in `read_status_line' /usr/lib/ruby/1.8/net/http.rb:2009:in `read\_new’  
/usr/lib/ruby/1.8/net/http.rb:1050:in `request' /usr/lib/ruby/1.8/net/http.rb:845:in `post’  
/usr/lib/ruby/1.8/soap/netHttpClient.rb:93:in `post' /usr/lib/ruby/1.8/soap/netHttpClient.rb:116:in `start’  
/usr/lib/ruby/1.8/net/http.rb:543:in `start' /usr/lib/ruby/1.8/soap/netHttpClient.rb:115:in `start’  
/usr/lib/ruby/1.8/soap/netHttpClient.rb:92:in `post' /usr/lib/ruby/1.8/soap/streamHandler.rb:170:in `send\_post’  
/usr/lib/ruby/1.8/soap/streamHandler.rb:109:in `send' /usr/lib/ruby/1.8/soap/rpc/proxy.rb:170:in `route’  
/usr/lib/ruby/1.8/soap/rpc/proxy.rb:141:in `call' /usr/lib/ruby/1.8/soap/rpc/driver.rb:178:in `call’  
(eval):6:in `listid' /var/www/fabdev/app/controllers/client_controller.rb:11:in `list2’  
/usr/bin/mongrel\_rails:19:in `load’  
/usr/bin/mongrel\_rails:19

/usr/lib/ruby/1.8/timeout.rb:54:in `rbuf_fill' /usr/lib/ruby/1.8/timeout.rb:56:in `timeout’  
/usr/lib/ruby/1.8/timeout.rb:76:in `timeout' /usr/lib/ruby/1.8/net/protocol.rb:132:in `rbuf\_fill’  
/usr/lib/ruby/1.8/net/protocol.rb:116:in `readuntil' /usr/lib/ruby/1.8/net/protocol.rb:126:in `readline’  
/usr/lib/ruby/1.8/net/http.rb:2020:in `read_status_line' /usr/lib/ruby/1.8/net/http.rb:2009:in `read\_new’  
/usr/lib/ruby/1.8/net/http.rb:1050:in `request' /usr/lib/ruby/1.8/net/http.rb:845:in `post’  
/usr/lib/ruby/1.8/soap/netHttpClient.rb:93:in `post' /usr/lib/ruby/1.8/soap/netHttpClient.rb:116:in `start’  
/usr/lib/ruby/1.8/net/http.rb:543:in `start' /usr/lib/ruby/1.8/soap/netHttpClient.rb:115:in `start’  
/usr/lib/ruby/1.8/soap/netHttpClient.rb:92:in `post' /usr/lib/ruby/1.8/soap/streamHandler.rb:170:in `send\_post’  
/usr/lib/ruby/1.8/soap/streamHandler.rb:109:in `send' /usr/lib/ruby/1.8/soap/rpc/proxy.rb:170:in `route’  
/usr/lib/ruby/1.8/soap/rpc/proxy.rb:141:in `call' /usr/lib/ruby/1.8/soap/rpc/driver.rb:178:in `call’  
/usr/lib/ruby/gems/1.8/gems/actionwebservice-1.2.6/lib/  
action\_web\_service/client/soap\_client.rb:63:in `send' /usr/lib/ruby/gems/1.8/gems/actionwebservice-1.2.6/lib/ action_web_service/client/soap_client.rb:63:in `perform\_invocation’  
/usr/lib/ruby/gems/1.8/gems/actionwebservice-1.2.6/lib/  
action\_web\_service/client/base.rb:15:in `method_missing' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/ base.rb:1101:in `send’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action\_controller/  
base.rb:1101:in `perform_action_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/ filters.rb:696:in `call\_filters’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action\_controller/  
filters.rb:688:in `perform_action_without_benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/ benchmarking.rb:66:in `perform\_action\_without\_rescue’  
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/ benchmarking.rb:66:in `perform\_action\_without\_rescue’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action\_controller/  
rescue.rb:83:in `perform_action' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/ base.rb:435:in `send’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action\_controller/  
base.rb:435:in `process_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/ filters.rb:684:in `process\_without\_session\_management\_support’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action\_controller/  
session\_management.rb:114:in `process' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/ base.rb:334:in `process’  
/usr/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/dispatcher.rb:41:in  
`dispatch' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/rails.rb:76:in `process’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/rails.rb:74:in  
`synchronize' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/rails.rb:74:in `process’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:155:in  
`process_client' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:154:in `each’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:154:in  
`process_client' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:281:in `run’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:281:in  
`initialize' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:281:in `new’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:281:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:264:in `initialize’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:264:in `new' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:264:in `run’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/configurator.rb:  
282:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/configurator.rb: 281:in `each’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/configurator.rb:  
281:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/mongrel_rails:128:in `run’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/command.rb:  
212:in `run’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/mongrel\_rails:281

/usr/lib/ruby/1.8/timeout.rb:54:in `rbuf_fill' /usr/lib/ruby/1.8/timeout.rb:56:in `timeout’  
/usr/lib/ruby/1.8/timeout.rb:76:in `timeout' /usr/lib/ruby/1.8/net/protocol.rb:132:in `rbuf\_fill’  
/usr/lib/ruby/1.8/net/protocol.rb:116:in `readuntil' /usr/lib/ruby/1.8/net/protocol.rb:126:in `readline’  
/usr/lib/ruby/1.8/net/http.rb:2020:in `read_status_line' /usr/lib/ruby/1.8/net/http.rb:2009:in `read\_new’  
/usr/lib/ruby/1.8/net/http.rb:1050:in `request' /usr/lib/ruby/1.8/net/http.rb:845:in `post’  
/usr/lib/ruby/1.8/soap/netHttpClient.rb:93:in `post' /usr/lib/ruby/1.8/soap/netHttpClient.rb:116:in `start’  
/usr/lib/ruby/1.8/net/http.rb:543:in `start' /usr/lib/ruby/1.8/soap/netHttpClient.rb:115:in `start’  
/usr/lib/ruby/1.8/soap/netHttpClient.rb:92:in `post' /usr/lib/ruby/1.8/soap/streamHandler.rb:170:in `send\_post’  
/usr/lib/ruby/1.8/soap/streamHandler.rb:109:in `send' /usr/lib/ruby/1.8/soap/rpc/proxy.rb:170:in `route’  
/usr/lib/ruby/1.8/soap/rpc/proxy.rb:141:in `call' /usr/lib/ruby/1.8/soap/rpc/driver.rb:178:in `call’  
(eval):6:in `listid' /usr/lib/ruby/gems/1.8/gems/actionwebservice-1.2.6/lib/ action_web_service/client/soap_client.rb:63:in `send’  
/usr/lib/ruby/gems/1.8/gems/actionwebservice-1.2.6/lib/  
action\_web\_service/client/soap\_client.rb:63:in `perform_invocation' /usr/lib/ruby/gems/1.8/gems/actionwebservice-1.2.6/lib/ action_web_service/client/base.rb:15:in `method\_missing’  
/var/www/fabdev/app/controllers/client\_controller.rb:11:in `list2' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/ base.rb:1101:in `send’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action\_controller/  
base.rb:1101:in `perform_action_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/ filters.rb:696:in `call\_filters’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action\_controller/  
filters.rb:688:in `perform_action_without_benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/ benchmarking.rb:66:in `perform\_action\_without\_rescue’  
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/ benchmarking.rb:66:in `perform\_action\_without\_rescue’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action\_controller/  
rescue.rb:83:in `perform_action' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/ base.rb:435:in `send’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action\_controller/  
base.rb:435:in `process_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/ filters.rb:684:in `process\_without\_session\_management\_support’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action\_controller/  
session\_management.rb:114:in `process' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.6/lib/action_controller/ base.rb:334:in `process’  
/usr/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/dispatcher.rb:41:in  
`dispatch' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/rails.rb:76:in `process’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/rails.rb:74:in  
`synchronize' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/rails.rb:74:in `process’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:155:in  
`process_client' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:154:in `each’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:154:in  
`process_client' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:281:in `run’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:281:in  
`initialize' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:281:in `new’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:281:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:264:in `initialize’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:264:in `new' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:264:in `run’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/configurator.rb:  
282:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/configurator.rb: 281:in `each’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/configurator.rb:  
281:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/mongrel_rails:128:in `run’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/command.rb:  
212:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/mongrel_rails:281 /usr/bin/mongrel_rails:19:in `load’  
/usr/bin/mongrel\_rails:19

Request

Parameters: None

Show session dump

* * *

flash: !map:ActionController::Flash::FlashHash {}

Response

Can you help me?

I realise a client in ruby (without ruby on rails) like this :  
#!/usr/bin/env ruby

require ‘soap/wsdlDriver’  
wsdl = “[http://localhost:3000/customer/service.wsdl](http://localhost:3000/customer/service.wsdl)”  
customer\_server = SOAP::WSDLDriverFactory.new(wsdl).create\_rpc\_driver  
customer\_server.listall.map do |id|  
customer = customer\_server.listid(id)  
puts “Client: #{customer.nom}, rtc : #{customer.rtc}, commercial :  
#{customer.commercial}”  
end  
It’s give me the good info but slowly, not snapshot.

Thanks for your help.  
Fabien.

---

<div class="post-metadata">

**Author:** ![fafarun](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/2bfe46/32.png) [@fafarun](https://www.ruby-forum.com/u/fafarun)\
**Post date:** [December 14, 2007, 12:47pm UTC](https://www.ruby-forum.com/t/realise-a-web-service-with-ruby-on-rails/123038/2 "2007-12-14T12:47:26Z")

</div>

Hi,  
No body Had a idea for my problem?

best regards.  
Fabien

---

<div class="post-metadata">

**Author:** ![fafarun](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/2bfe46/32.png) [@fafarun](https://www.ruby-forum.com/u/fafarun)\
**Post date:** [December 18, 2007, 3:29pm UTC](https://www.ruby-forum.com/t/realise-a-web-service-with-ruby-on-rails/123038/3 "2007-12-18T15:29:47Z")

</div>

Hi,  
nobody has realized a webservice and it’s client with ruby on rails?

thanks?

Fabien.

---

<div class="post-metadata">

**Author:** ![fafarun](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/2bfe46/32.png) [@fafarun](https://www.ruby-forum.com/u/fafarun)\
**Post date:** [December 18, 2007, 3:11pm UTC](https://www.ruby-forum.com/t/realise-a-web-service-with-ruby-on-rails/123038/4 "2007-12-18T15:11:35Z")

</div>

Hi,  
nobody has realized a webservice and it’s client with ruby on rails?

thanks?

Fabien.
