Forum: Ruby on Rails How to use API from AWS -- help!

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
rph (Guest)
on 2007-01-18 21:20
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,
authenticate, etc).

Within usermanagement, I have:
1) models/user.rb
2) controllers/user_controller.rb
3) apis/user_api.rb

1) Model: User.rb - This file just holds some business logic for
maintaining the users.

2) Controller: class UserController < ApplicationController and below
this line at the top of the file, I have:

wsdl_service_name 'User'
web_service_api UserApi

then my method implementations.

3) 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):

1) 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?

2) In: class SomeController < ApplicationController I've tried,
user_api =,

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
Conrad T. (Guest)
on 2007-01-19 17:31
(Received via mailing list)
Hi, my recommendation is to the following:

a) invoke and verify that your external webservice using script/console

    user_api =,

b)  If (a) is working as expected, then you should read and follow the
     in 25.7 of AWDwRv2.

     If not, then you should follow an incremental development
approach to correct
     the code:

     code A
     test  A
     debug A
     code A
     test  A
     debug A
     and so on.

     You may not need to debug in every case and you'll continue this
     until you have completed the implementation.  Why do it this way?
It seems
     that you have implemented alot of code without testing it until
the very end.
     Also, I have don't have time to do it for you and this is
something that you need
     to learn.

     Good luck,

Zack C. (Guest)
on 2007-09-26 00:37
(Received via mailing list)
On 1/18/07, Conrad T. <removed_email_address@domain.invalid> wrote:
>      in 25.7 of AWDwRv2.
>      debug A
>      Good luck,
> >
> >
> >
> > the users web service to register and login, etc.  How can I access
> > have to include the file from the other service from within each
> > "uninitialized constant UserApi" when trying to open the file
> >
> > >
> >
> >


You might also try hitting it with curl:

curl -H "Content-Type: text/xml" -H "SoapAction: authenticate" -d @msg
-X POST http://localhost:3000/user/api

where @msg is a file with the SOAP or xml message.

I have experience more on the server side of exposing web services
from a rails controller, not so much in consuming services using
ActionWebService::Client.  If all the applications will be rails
consider activeresource instead of AWS.

Good luck.

Zack C.
This topic is locked and can not be replied to.