Small problem in RoR Webservices

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

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

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

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 .

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