Re: casting issue

Chandra Shekar
Thu, 15 Mar 2007 09:34:57 -0000

# API class
class SampApi < ActionWebService::API::Base
    api_method :GetInfo, :expects => [:string,:string], :returns
=>[CompleteInfo]

end

# struct class TP
class TP < ActionWebService::Struct
    member :Name, :string
    member :Address, :string
end

# struct class DR
class DR < ActionWebService::Struct
    member :Price, :string
    member :Tax, :string
end


# Composite class
class CompleteInfo

  def initialize
  @an_array = []
  end

        class TP < ActionWebService::Struct

        end

        class DR < ActionWebService::Struct

        end

  def assign_to_array (item)
  @an_array << item
  end
end


# Controller class
class ContentController < ApplicationController
def GetInfo(param0,param1)
    p1 =  @params[''param0'']
    p2 = @params[''param1'']


    completeInfo = CompleteInfo.new


    tP = CompleteInfo::TP.new()

    dR1 = CompleteInfo::DR.new()

    dR2 = CompleteInfo::DR.new()

    dR3 = CompleteInfo::DR.new()

    #TP
    tP.Name  = "user"
    tP.Address  = "IN"

    #DR
    dR1.Price = "10"
    dR1.Tax = "1"

    dR1.Price = "20"
    dR1.Tax = "2"

    dR3.Price = "30"
    dR3.Tax = "3"

    completeInfo.assign_to_array(dR1)
    completeInfo.assign_to_array(dR2)
    completeInfo.assign_to_array(dR3)

    completeInfo

 end

end

after execution of the above class the error message displayed is

"Don''t know how to cast CompleteInfo to CompleteInfo"

--
Posted via http://www.ruby-forum.com/.