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 Benevento -------------------------- /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' <snip> This error occured while loading the following files: webpress_controller.rb webpress_api.rb my_service/soap_response.rb
on 2006-05-31 10:35
on 2006-05-31 11:02
Or maybe there is something deeper going on: http://dev.rubyonrails.org/ticket/5126 This is a unrelated bug, but with similar symptoms.
on 2006-05-31 15:07
ActionWebService::Struct classes are reloadable in the development mode (just like model classes). That means that you shouldn't place them into the vendor folder. There is a special folder app/apis created just for that. Another thing is that you must not use standard 'require' method to loaded reloadable classes, it won't work in the development mode. On 5/31/06, Michel Benevento <firstname.lastname@example.org> wrote: > When defined like this (all definitions in one file) it all works fine: > [:string], :returns => [[SoapResponse]] > ends here. If I define the SoapResponse class in the application > /vendor/my_service.rb > ---------- > ------------- > webpress_controller.rb > webpress_api.rb > my_service/soap_response.rb > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > -- Kent --- http://www.datanoise.com