I’m building a users web service (direct dispatching) that will (I hope)
allow several other applications to manage the same pool of users. Plus
it will act as a single-sign-on solution for what I’m doing. But I’m
having difficulty accessing the UserAPI. Here’s what I’ve done so far:
$> rails usermanagement
- “usermanagement” is the application that will have an API to allow
other applications to manage the user base (register, edit, login,
Within usermanagement, I have:
Model: User.rb - This file just holds some business logic for
maintaining the users.
Controller: class UserController < ApplicationController and below
this line at the top of the file, I have:
then my method implementations.
- ApiDefinition: UserApi.rb - this file has all of my “api_method”
calls and details what methods expect and return.
Now, that’s how I’m setup, and I’ve tested all of this and followed the
AWDWRv2 book. My problem is trying to access these methods from a
completely new application, so continuing:
$> rails newapplication
- “newapplication” will be one of the many applications that must use
the users web service to register and login, etc. How can I access
these methods? Here’s what I’m trying (with no luck):
- In: class SomeController < ApplicationController I have,
web_client_api :user, :xmlrpc, “http://localhost:3000/user/api/RPC2”,
:handler_name => “user_api”
And I try using things like “user_api.authenticate(un,pw)” etc. Doesn’t
work, I’m currently getting:
“Missing API definition file in apis/user_api.rb” but surely you don’t
have to include the file from the other service from within each
application, right? Because then I would have to have a User.rb model
in every case as well?
- In: class SomeController < ApplicationController I’ve tried,
user_api = ActionWebService::Client::XmlRpc.new(UserApi,
And tried accessing things like “user_api.authenticate(un,pw)” etc.
That doesn’t work, either. I got the following errors:
“uninitialized constant UserApi” when trying to open the file
“user_api.rb”. I don’t know how to fix this.
Actually, I don’t know how to access my methods in the “usermanagement”
service from any of my other services. Can someone explain that to me?
See anything wrong with what I’ve tried? And sorry this is so long, but
I want to include as much information as possible. Thanks a lot for any