Forum: Ruby on Rails web services on the client side

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.
66d1d0df01e4bbb82674a353ea68d6ee?d=identicon&s=25 Josh Kieschnick (jjkiesch)
on 2006-05-02 15:50
i am reading through chapter 20 of the agile web development book and
trying to figure out how to use web services. i set up two different
rails apps. one as the server and one as the client. setting up the
server seems to work fine. but when i use the example at the end of the
chapter to set up a client, i get the following error when i open the
page:

Missing API definition file in apis/user_api.rb

Which is the filename for my user api on the server application. I have
this in my controller:

class RemoteInfoController < ApplicationController
  web_client_api :user,
    :soap,
    "http://my_ip_address/server/backend/api"

  def list
    @users = user.find_all_users.map do |id|
      user.find_user_by_id(id)
    end
  end

  def index
  end
end

Am I supposed to have a user_api.rb file on the client application too,
or have I just made a mistake?
612a5333e356c4f765230d9ac06e5c8c?d=identicon&s=25 Pradeep Sethi (Guest)
on 2006-05-02 17:37
yes, you need apis/user_api.rb and you'd provide the method signature
for the api call there with api_method

such as

  api_method find_user_by_id,
    :expects => {:id => :int},
    :returns => {:user }

please note that I am not expert in this area. For complete info, see
this HowTo article on rails site.

http://wiki.rubyonrails.com/rails/pages/How+To+Con...

also, if you are trying to do anymore than basic web service stuff,
ActionWebService might not meet your needs, you would need to check
'soap4r'.

Hope that helps

PS



Josh Kieschnick wrote:
> i am reading through chapter 20 of the agile web development book and
> trying to figure out how to use web services. i set up two different
> rails apps. one as the server and one as the client. setting up the
> server seems to work fine. but when i use the example at the end of the
> chapter to set up a client, i get the following error when i open the
> page:
>
> Missing API definition file in apis/user_api.rb
>
> Which is the filename for my user api on the server application. I have
> this in my controller:
>
> class RemoteInfoController < ApplicationController
>   web_client_api :user,
>     :soap,
>     "http://my_ip_address/server/backend/api"
>
66d1d0df01e4bbb82674a353ea68d6ee?d=identicon&s=25 Josh Kieschnick (jjkiesch)
on 2006-05-02 17:41
Pradeep Sethi wrote:
> yes, you need apis/user_api.rb and you'd provide the method signature
> for the api call there with api_method
>
> such as
>
>   api_method find_user_by_id,
>     :expects => {:id => :int},
>     :returns => {:user }
>

that's what i have in apis/user_api.rb on the server application. am i
supposed to have it in both apps?
612a5333e356c4f765230d9ac06e5c8c?d=identicon&s=25 Pradeep Sethi (Guest)
on 2006-05-02 18:23
I have not done server side WS in rails. I created just a client for
consuming a .NET service and had to put the signature in apis/api.rb.

PS

Josh Kieschnick wrote:
> that's what i have in apis/user_api.rb on the server application. am i
> supposed to have it in both apps?
This topic is locked and can not be replied to.