Realise a web service with ruby on rails

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
def list
customer.listall.map do |id|
@customers = customer.listid(id)
end
end
end

But when I do
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
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.

Hi,
No body Had a idea for my problem?

best regards.
Fabien

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

thanks?

Fabien.

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

thanks?

Fabien.