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

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.
1e2dd87a31c5d3e07adc9efa375f4dc4?d=identicon&s=25 rph (Guest)
on 2007-01-18 20: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 = ActionWebService::Client::XmlRpc.new(UserApi,
"http://localhost:3000/user/api/RPC2")

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
help.
40db9e75b3f5899258e3bdc0c9210154?d=identicon&s=25 Conrad Taylor (Guest)
on 2007-01-19 16: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 = ActionWebService::Client::XmlRpc.new(UserApi,
      "http://localhost:3000/user/api/RPC2"

b)  If (a) is working as expected, then you should read and follow the
information
     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
process
     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,

     -Conrad
C4dc94c893471878a105761a9207f29b?d=identicon&s=25 Zack Chandler (Guest)
on 2007-09-25 22:37
(Received via mailing list)
On 1/18/07, Conrad Taylor <conradwt@gmail.com> 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
> >
> > >
> >
>
> >
>

Hi,

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 Chandler
http://depixelate.com
This topic is locked and can not be replied to.