You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by de...@struts.apache.org on 2004/12/20 20:00:18 UTC

[Apache Struts Wiki] Updated: StrutsSolutions

   Date: 2004-12-20T11:00:17
   Editor: FrankZammetti <fzammetti@omnytex,.com>
   Wiki: Apache Struts Wiki
   Page: StrutsSolutions
   URL: http://wiki.apache.org/struts/StrutsSolutions

   no comment

Change Log:

------------------------------------------------------------------------------
@@ -24,12 +24,18 @@
 
 3. Running Scripts from Java Classes
 
+4. Exposing Struts-based functions as Web Services
+
 == DISCUSSION OF PROBLEMS (What Is The Problem?) ==
 
+4. In an application I was architect and lead developer for last year, I was asked to expose certain pieces of functionality of the system as Web Services.  This request was made AFTER the application was complete and deployed in production.  I did not want to spend a lot of time on this (in fact, COULDN'T) and wanted to change as little code as possible, ideally none.
+
 == DISCUSSION OF SOLUTIONS (What Is The Solution?) ==
 
 1.1.  You can distinguish between inline and attachment (with a filename) in the response content-disposition header.
 
+4. I started a mini-project that I grandiosely called the Struts Web Services Enablement Project.
+
 == SOLUTIONS ==
 
 1.A. Frank Zammetties !DownloadAction App
@@ -116,5 +122,15 @@
   }
 }
 }}}
+
+4. Please see [url]http://www.omnytex.com/strutsws for complete details, but in brief... 
+
+I decided that, in my case at least, the easiest path "into the application" that could be exposed as a service would actually be the Actions themselves.  You may ask, assuming the application was architected properly and the Actions delegated out work to business classes (that IS the case), why not just expose the business classes?  The answer is that I wanted to leverage all the form validation and security built in to the app (it was a custom security solution).  Because of this, I needed Struts to "do it's thing" leading up to the business class execution.
+
+My solution was to write a custom request processor that could recognize a Web Service request (SOAP over HTTP).  It would be able to "unroll" the SOAP request, then let Struts process the request as it usually would, and then render the response.  My solution does this.
+
+I don't claim this is THE way to do Web Services.  Far from it.  What I WILL claim though is that if you have an existing application and you want to expose parts of it as Web Services, this solution can give you a very easy way to do it, with some limitations of course...  First, it is Struts 1.1-only at the moment.  Second, the incoming request must be "flat", that is, no nested elements are allowed (aside from children of the root element).  Third, only strings are supported, so you lose the notion of true data typing that SOAP gives you.
+
+All these details, and plenty more, as well as full source, are available at the linked address above.  I welcome any suggestions anyone has.  Although I haven't done much on this in a while (because it met my needs as-is), I would love to continue this work if enough people find it useful.
 
 = THE END =

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org