Forum: Ruby on Rails web serveces problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A6d777dcac0572d2b5288b1c41cbcd45?d=identicon&s=25 Amir Lidor (shiko)
on 2006-03-02 11:12
Hi,
I'm trying to added layered web services to my application and from some
reason it's not working for me. i'm working with ruby 1.84, rails 1.0.

here are my files:
1. app/apis/kate_api.rb:

class KateAPI < ActionWebService::API::Base
	inflect_names false
	api_method :check_version, :expects => [:string], :returns => [:string]
end

2. app/models/kate_api_service.rb : (tried to put it also in apis
directory - where should it be??)

class KateAPIService < ActionWebService::Base
	web_service_api KateAPI

	def check_version (version)
		if version != '0.25'
			'you are trying to talk with Tyra version 0.25 with a different
version !'
		else
			'server and client versions match - 0.25'
		end
	end
end

3. app/controller/kate_controller.rb:

class KateController < ApplicationController
	web_service_scaffold :invoke
	web_service_dispatching_mode :layered
	web_service :kate, KateAPIService.check_version
end

when I go to the browser to /myapp/kate/api i get:
NoMethodError in <controller not set>#<action not set>
undefined method `check_version' for KateAPIService:Class

and in the log:
oMethodError (undefined method `check_version' for
KateAPIService:Class):
    .//app/controllers/kate_controller.rb:6
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:207:in
`load'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:39:in
`require_or_load'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:22:in
`depend_on'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:178:in
`require_dependency'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:134:in
`load_file!'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:97:in
`const_load!'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:80:in
`const_load!'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:72:in
`const_missing'
    routing.rb:234:in `traverse_to_controller'
    generated/routing/recognition.rb:7:in `eval'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/routing.rb:234:in
`traverse_to_controller'
    generated/routing/recognition.rb:7:in `recognize_path'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/routing.rb:458:in
`recognize!'
    /usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:in
`dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:117:in
`handle_dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:in
`service'
    /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
    /usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
    /usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
    /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
    /usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'
    /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'
    /usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'
    /usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'
    /usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:69:in
`dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webrick.rb:59
    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
`require'
    /usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28
    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
`require'
    ./script/server:3


any help would be appriciated. I've wasted lots of time on this...
Thanks,
Amir.
3ccecc71b9fb0a3d7f00a0bef6f0a63a?d=identicon&s=25 Kent Sibilev (Guest)
on 2006-03-02 15:29
(Received via mailing list)
Your controller should look like:

class KateController < ApplicationController
       web_service_scaffold :invoke
       web_service_dispatching_mode :layered
       web_service :kate, KateAPIService.new
end

On 3/2/06, amir lidor <amirl@kashya.com> wrote:
> end
> version !'
>         web_service_dispatching_mode :layered
>     .//app/controllers/kate_controller.rb:6
> 
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:97:in
> 
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/routing.rb:458:in
>     /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
> `require'
> Amir.
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


--
Kent
---
http://www.datanoise.com
This topic is locked and can not be replied to.