ActionWebService table -> xml mapping questions

Hi,

I’m using ActionWebService to make an XML document representing a
business object available over XML-RPC. The XML representation does not
map directly to our model in a couple of ways:

  1. XML element titles do not necessarily match the model column names.
    e.g. “programTitle” => “program_title”
  2. The XML needs to reflect the model relationships. One program object
    can have many episode objects

I have a service up and running, but returning the model directly
results in XML with only the column names and values for that object.
I’d like to be able to modify the column names, and also have related
objects represented in the XML.

I started looking at the ActionWebService::Struct object as a solution,
but I realized that the ActionWebService::Struct object can only have
base types as members. If I have an ActionWebService::Struct object for
the Program model called XMLProgram and another called XMLEpisode for
the Episode models, I can’t have XMLEpisode be an attribute of
XMLProgram. Details on that are below, but I have some general
questions:

  1. Is there a mapping framework that handles model to xml mapping with
    the requirements I mentioned above?
  2. Is there another way I should go about doing this? ActiveResource and
    REST are not on the table for the moment, and doesn’t resolve the
    scenario where there’s a difference between the db and xml
    representation. I’ve also looked at rbatis, which makes raw SQL queries
    in order to return results to methods (not what I’m looking for at the
    moment).

Feedback, questions welcome. Thanks very much.

class XMLProgram < ActionWebService::Struct
member :episodes, [:XMLEpisode]
member :broadcasts, [:Broadcasts]
end

trying to create one in the console results in the error below.

we = WebEvent.new
TypeError: XMLEpisode is not a valid base type
from
/usr/local/lib/ruby/gems/1.8/gems/actionwebservice-1.2.3/lib/action_web_service/support/signature_types.rb:71:in
canonical_type_name' from /usr/local/lib/ruby/gems/1.8/gems/actionwebservice-1.2.3/lib/action_web_service/support/signature_types.rb:47:incanonical_type’
from
/usr/local/lib/ruby/gems/1.8/gems/actionwebservice-1.2.3/lib/action_web_service/support/signature_types.rb:35:in
canonical_signature_entry' from /usr/local/lib/ruby/gems/1.8/gems/actionwebservice-1.2.3/lib/action_web_service/support/signature_types.rb:33:incanonical_signature_entry’
from
/usr/local/lib/ruby/gems/1.8/gems/actionwebservice-1.2.3/lib/action_web_service/struct.rb:51:in
member' from ./script/../config/../config/../app/models/xml_program.rb:28 from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:203:inload_without_new_constant_marking’
from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:203:in
load_file' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:innew_constants_in’
from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:202:in
load_file' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:94:inrequire_or_load_without_engine_additions’
from
./script/…/config/…/config/…/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb:139:in
require_or_load' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:248:inload_missing_constant’
from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:452:in
const_missing' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:464:inconst_missing’

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs