# Small problem in RoR Webservices

**URL:** <https://www.ruby-forum.com/t/small-problem-in-ror-webservices/172144>\
**Category:** Rails\
**Created:** [July 15, 2009, 4:53pm UTC](https://www.ruby-forum.com/t/small-problem-in-ror-webservices/172144 "2009-07-15T16:53:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sand\_acc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@sand\_acc](https://www.ruby-forum.com/u/sand_acc)\
**Post date:** [July 15, 2009, 4:53pm UTC](https://www.ruby-forum.com/t/small-problem-in-ror-webservices/172144/1 "2009-07-15T16:53:17Z")

</div>

Hi All,

Being a beginner in RoR WebServices, just trying to learn about the  
different dispathing mechanisms. Direct dispatching is working fine, but  
unable to get a perfect example for layered and delegated diapatching  
techniques.

What I had tried is

* * *

Server Application

(hello\_api.rb)  
class HelloApi \< ActionWebService::API::Base  
api\_method :getMsg,  
:expects =\> [{:firstname =\> :string},{:lastname =\>  
:string}],  
:returns =\> [:string]  
end

* * *

## (second\_ws\_api.rb) class SecondWsApi \< ActionWebService::API::Base api\_method :get\_message\_from\_second\_ws, :expects =\> [{:name =\> :string}], :returns =\> [:date] end

(hello\_controller.rb)  
class HelloService \< ActionWebService::Base  
web\_service\_api HelloApi

def getMsg(first\_name,last\_name)  
“Hiiiiiiiiiiii …”+first\_name+last\_name  
end  
end

class SecondWsService \< ActionWebService::Base  
web\_service\_api SecondWsApi

def get\_message\_from\_second\_ws(name)  
Date.today  
end  
end

class HelloController \< ApplicationController  
web\_service\_dispatching\_mode :layered  
web\_service\_scaffold :invoke

web\_service :first\_web\_service, HelloService.new  
web\_service :second\_web\_service, SecondWsService.new  
end

This is the application running on 3001 port. With the scaffold, the  
wsdl and the invoke are working properly as guided in all the tutorials.

===========================================================

Client Application :

(web\_service\_client\_controller.rb)  
class WebServiceClientController \< ApplicationController  
require ‘soap/wsdlDriver’  
def get\_name  
first\_ws\_url = “[http://localhost:3001/hello/wsdl](http://localhost:3001/hello/wsdl)”  
first\_soap\_service = SOAP::WSDLDriverFactory.new  
(first\_ws\_url).create\_rpc\_driver  
puts “All the methods are : #{first\_soap\_service.singleton\_methods}”

```
message = first_soap_service.getMsg("First Name","Last Name")
puts "SOAP : #{message}"

puts "SOAP : second method

```

:",first\_soap\_service.get\_message\_from\_second\_ws(“My Name”)

======\> Result is

All the methods are : GetMsggetMsg  
SOAP : Hiiiiiiiiiiii …First NameLast Name, sedone method : #

and

undefined method `get\_message\_from\_second\_ws’ for  
#SOAP::RPC::Driver:0x4bab2c0

* * *

Unable to get what exactly was the problem. Please help me in this.

Thanks and Regards  
Sand.

---

<div class="post-metadata">

**Author:** ![sand\_acc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@sand\_acc](https://www.ruby-forum.com/u/sand_acc)\
**Post date:** [July 16, 2009, 8:31am UTC](https://www.ruby-forum.com/t/small-problem-in-ror-webservices/172144/2 "2009-07-16T08:31:35Z")

</div>

Try calling the 2nd WS alone ( similar to the first WS) to see if it  
works. I am sure it will work.

---

<div class="post-metadata">

**Author:** ![sand\_acc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@sand\_acc](https://www.ruby-forum.com/u/sand_acc)\
**Post date:** [July 16, 2009, 10:31am UTC](https://www.ruby-forum.com/t/small-problem-in-ror-webservices/172144/3 "2009-07-16T10:31:37Z")

</div>

Instead of calling the 2nd WS like this ( you are passing it as an  
argument to PUTS)

puts “SOAP : second method  
:”,first\_soap\_service.get\_message\_from\_second\_ws(“My Name”)

Can we not call it similar to the first one?.

---

<div class="post-metadata">

**Author:** ![sand\_acc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@sand\_acc](https://www.ruby-forum.com/u/sand_acc)\
**Post date:** [July 16, 2009, 10:18am UTC](https://www.ruby-forum.com/t/small-problem-in-ror-webservices/172144/4 "2009-07-16T10:18:47Z")

</div>

> Try calling the 2nd WS alone ( similar to the first WS) to see if it  
> works. I am sure it will work.

Thanks for a quick reply.

It was working with single invocation. Only when both the APIs are  
called, it is throwing that error. Please guide me in this and if  
possible, some examples of invoking seperate APIs in the client (other  
than the ones given in the prescribed articles)

Thanks and Regards,  
Sand .

---

<div class="post-metadata">

**Author:** ![sand\_acc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@sand\_acc](https://www.ruby-forum.com/u/sand_acc)\
**Post date:** [July 16, 2009, 12:14pm UTC](https://www.ruby-forum.com/t/small-problem-in-ror-webservices/172144/5 "2009-07-16T12:14:44Z")

</div>

First the code was written in the manner u are telling (seperate). Then,  
I trying on so many things, I finally got to this. Anyways, the second  
webservice was not getting invoked if more than one ws are called. Hope  
this information helps. Any other possible area of problem? Please  
suggest me.

```
message2 = first_soap_service.getMessageFromSecondWs("My Name")
puts "SOAP : second methof : #{message2}"

```

> Can we not call it similar to the first one?.
