# ActionWebService table -\> xml mapping questions

**URL:** <https://www.ruby-forum.com/t/actionwebservice-table-xml-mapping-questions/104699>\
**Category:** Rails\
**Created:** [May 21, 2007, 6:47pm UTC](https://www.ruby-forum.com/t/actionwebservice-table-xml-mapping-questions/104699 "2007-05-21T18:47:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Nyon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/43a26b/32.png) [@Mark\_Nyon](https://www.ruby-forum.com/u/Mark_Nyon)\
**Post date:** [May 21, 2007, 6:47pm UTC](https://www.ruby-forum.com/t/actionwebservice-table-xml-mapping-questions/104699/1 "2007-05-21T18:47:04Z")

</div>

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:in`canonical\_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:in`canonical\_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:in`load\_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:in`new\_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:in`require\_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:in`load\_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:in`const\_missing’
