class Sampleclass
attr_reader :temp_arr,:temp_hash,:temp_str
def initialize(temp_arr,temp_hash,temp_str)
@temp_arr=temp_arr
@temp_hash=temp_hash
@temp_str=temp_str
end
class TestApi < ActionWebService::API::Base
api_method :get_me, :returns => [Sampleclass]
end
class TestController < ApplicationController
wsdl_service_name ‘Test’
web_service_api TestApi
web_service_scaffold :invocation if Rails.env == ‘development’
def get_me
#[get_indices(),get_stocks(),get_summary(),DateTime.now.to_s]
indices = get_indices()
stocks = get_stocks()
summary = get_summary()
current_time = DateTime.now
tempsnapshot = Snapshot.new(indices,stocks,summary,current_time)
tempsnapshot
[Sampleclass.new([‘1’,‘2’,3’],
{‘a’ => ‘1’,
‘b’ => ‘2’ },
‘something’ ) ]
end
end
i got this error
Don’t know how to cast Sampleclass to Sampleclass
how do i define custom classes as return paramters
disregard this section
#[get_indices(),get_stocks(),get_summary(),DateTime.now.to_s]
indices = get_indices()
stocks = get_stocks()
summary = get_summary()
current_time = DateTime.now
tempsnapshot = Snapshot.new(indices,stocks,summary,current_time)
tempsnapshot
nevermind the above posts
i wasnt paying attention
i created a model Sample
changed code to
class TestApi < ActionWebService::API::Base
api_method :get_me, :returns => [Sample]
end
class MarketdataController < ApplicationController
…
def poll
Sample.find(:all,:limit =>1)
end
here i get all sorts of mapping errors
#1
returns => [Sample] #it should expect a Sample object
i return a Sample.find(:all,:limit=>1)[0]
and i get a “Cannot map Sample to SOAP/OM”
i return a Sample.find(:all,:limit=>1) #which would return an array
containing Sample objects , it errors out and says
“Don’t know how to cast Array to Sample”
thats expected
then i tried this
#2
returns => [[Sample]] #it should expect an array of sample objects ?
i return a sample.find(:all,:limit=>1)
and i get a “Cannot map Array to SOAP/OM”
Any ideas on how to get it to cast properly ?