# Web services on the client side

**URL:** <https://www.ruby-forum.com/t/web-services-on-the-client-side/59245>\
**Category:** Rails\
**Created:** [May 2, 2006, 3:50pm UTC](https://www.ruby-forum.com/t/web-services-on-the-client-side/59245 "2006-05-02T15:50:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [May 2, 2006, 3:50pm UTC](https://www.ruby-forum.com/t/web-services-on-the-client-side/59245/1 "2006-05-02T15:50:02Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [May 2, 2006, 5:37pm UTC](https://www.ruby-forum.com/t/web-services-on-the-client-side/59245/2 "2006-05-02T17:37:55Z")

</div>

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](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”

---

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [May 2, 2006, 5:41pm UTC](https://www.ruby-forum.com/t/web-services-on-the-client-side/59245/3 "2006-05-02T17:41:01Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [May 2, 2006, 6:23pm UTC](https://www.ruby-forum.com/t/web-services-on-the-client-side/59245/4 "2006-05-02T18:23:40Z")

</div>

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?
