Karen - Following is a re-post from a similar thread about a week ago where I laid out one potential solution for this problem - assuming I understand your issue correctly. Following is a description and some code I used for setting up communications between Struts and Axis for SOAP communications. The suammry of this recommendation is: - Post to form bean - Modify form bean design to allow you to extract a 'value object' from it (not XML). - Create a facade class that 'hides' the communications to the remote server. Have it accept the 'value object'. - Inside the 'facade class' have it create the XML from the value object and oversee communications - The Action class simply takes a valid form bean, extracts a value object form it and send it through the facade. In essence, your facade class is a 'model' component that hides any knowledge of the back end from the Action class and form bean. There are files below that you can use to see what I'm talking about. Let me know if you have questions - Kevin Kevin -------------------------------------------------------------------------------- I've attached a few files from my upcoming book Struts Kick Start that provide a basic design pattern that sounds like it may be similar to what your describing. What I do is: - Create a Value Object that encapsulates data communicated with the Model component. - Create a facade class that accepts and returns value objects through 'business methods'. By defining the facade to work at a 'business method' level, it helps keep any code related to a particular persistence layer or back-end system out of the Action class. This also addresses the issues you described of 'designing to test' - the clean seperation between the Action class and the Model components that the Facade provides simplifies testing. - Create the form bean to provide set/get methods that also accept and return value objects - this greatly simplifies the Action class and isolates it from changes. The Action class (a bit simplified - I've taken out detailed comments and exception handling) goes something like: // cast the form bean CustomerForm cf = (CustomerForm) form; // Create a facade to interface to the back-end system CustomerWSFacade facade = new CustomerWSFacade(); // Extract the value object from the form bean CustomerValueObject cvo = cf.getValueObject(); // Pass the value object to the facade. It returns an update value object cvo = facade.addressChange( cvo ); // Use the returned value object to update the values in the form bean. cf.setValueObject(cvo); These particular classes come from the chapter on providing integration with Axis for Web Services. Another chapter uses the identical set of classes to communicate with JBoss using a Session Bean - all I did was write a different facade class. The point of this was to demonstrate a design that made it very simple to perform maintenance or changes on the back-end or persistence layer. Regarding testing - I'd recommend you take a look at the StrutsTestCase project at sourceforge - it provides some great templates for both JUnit and Cactus tests that are designed for Struts. Makes JUnit/Cactus testing pretty straightforward. A copy of this and detailed directions also come with the book. http://strutstestcase.sourceforge.net/ Best of luck - Kevin Author, Struts Kick Start (See attached file: customer.zip) Karen Choi <[EMAIL PROTECTED]> on 10/21/2002 06:41:59 PM Please respond to "Struts Users Mailing List" <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] cc: (bcc: Kevin Bedell/Systems/USHO/SunLife) Subject: Using Struts with XML-RPC (or JAXB?) I am stuck on a rather vexing Struts problem... It sounds simple enough. I need to read some values from a form bean, then parse those values into a valid xml document (must conform to schema I've been provided with) then send that document to a defined service endpoint (another servlet). I know how to do this the "normal" way, but I can't seem to figure out how to do it with Struts. Would I be able to use JAXB, and create an XML representation of my form bean, which could be sent to the servlet, or is there another approach that I am not aware of. Any help or suggestions would be greatly appreciated. --------------------------------- Do you Yahoo!? Y! Web Hosting - Let the expert host your web site --------------------------------------------------------------------------- This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender and erase this e-mail message immediately. ---------------------------------------------------------------------------
customer.zip
Description: Zip archive
-- To unsubscribe, e-mail: <mailto:struts-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>