Web services on the client side

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?

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+Consume+.NET+WebServices

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 K. 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”

Pradeep S. 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?

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 K. wrote:

that’s what i have in apis/user_api.rb on the server application. am i
supposed to have it in both apps?