Hello,
I have seen some odd behaviour of my Web Services code plus some
‘similar’ postings to this list, so I believe this may be a bug in
Rails. But I’m failry new to RoR, so maybe I’m doing something wrong.
I’ll explain:
I have a WS API defined, communicating with a remote system that
expects a stucture:
When defined like this (all definitions in one file) it all works fine:
/app/apis/myws_api.rb
class SoapResponse < ActionWebService::Struct
member :id, :int
member :title, :string
end
class MyApi < ActionWebService::API::Base
api_method :find_products_by_category, :expects =>
[:string], :returns => [[SoapResponse]]
end
Now when I try to isolate my API code and my structures into a module
(listing below) things go wrong, but in a weird way. When I restart
my Webrick server the initial “/myws/invoke” hit gives no complaints,
but when I reload the exact same page an ‘uninitialized constant’
error occurs (error msgs below). This happens with external clients
as well, the first request is fine but all others throw an error. It
seems to be related to loading the required file, but my expertise
ends here. If I define the SoapResponse class in the application
controller it all works fine, BTW (but I don’t want that).
Does anybody have any suggestions how to further investigate/remedy
this? Am I doing this right anyway?
TIA,
Michel B.
/vendor/my_service.rb
module MyService
class SoapResponse < ActionWebService::Struct
member :id, :int
member :title, :string
end
end
/app/apis/myws_api.rb
require “my_service”
class MywsApi < ActionWebService::API::Base
include MyService
api_method :find_products_by_category, :expects =>
[:string], :returns => [[MyService::SoapResponse]]
end
error msg (occurs only on second and subsequent requests):
NameError
uninitialized constant SoapResponse
/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/
active_support/dependencies.rb:123:in `const_missing’
This error occured while loading the following files:
webpress_controller.rb
webpress_api.rb
my_service/soap_response.rb