# Restful action reuse in SOAP webservice

**URL:** <https://www.ruby-forum.com/t/restful-action-reuse-in-soap-webservice/123324>\
**Category:** Rails\
**Created:** [December 16, 2007, 3:00pm UTC](https://www.ruby-forum.com/t/restful-action-reuse-in-soap-webservice/123324 "2007-12-16T15:00:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![basvanwesting](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/53a042/32.png) [@basvanwesting](https://www.ruby-forum.com/u/basvanwesting)\
**Post date:** [December 16, 2007, 3:00pm UTC](https://www.ruby-forum.com/t/restful-action-reuse-in-soap-webservice/123324/1 "2007-12-16T15:00:46Z")

</div>

Hi,

I have a problem with the following situation. I need to add SOAP  
support (using AWS) in a fully RESTful Rails app.

I really want to reuse the existing restful action logic from the other  
controllers (just the actions, not the rendering). Stay DRY right… But  
I can’t find a way to do this.

I used render\_component(\_as\_string) for forwarding the request, but this  
doesn’t work completely as the instance variables are not available in  
the AWS controller afterwards (and the response cannot be generated as  
another mime type either, since AWS simply sees that as a single string  
while it expects an ActionWebService::Struct for rendering).  
I now have a working prototype where I use YAML to transport the  
instance variables from the RESTful controllers to the AWS controller  
and re-instantiate them there again. But this is not a very serious  
option.

Normally you would use filters and partials to reuse code in  
controllers, but in this situation I want the whole action logic  
(including the already existing filters etc).

Does anybody have an idea how to approach this problem?

Thanks in advance,  
Bas
