File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts and WebServices Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts and WebServices" Watch "Struts and WebServices" New topic

Struts and WebServices

Frosty One

Joined: Nov 07, 2002
Posts: 5
Can Struts integrate with WebServices and SOAP? Can anyone give a brief synopsis of how this is accomplished?
Brian McCallister

Joined: Dec 03, 2002
Posts: 19
This is not Struts specific, but the easiest way I have found to add webservices to any java app is Axis ( ).
If you want to act as a web service client - put the call wheveer it belongs (probably in the model oart), if you want to export functionality of your Struts app to a web service, make sure you are well layerd, then add a seperate web service interface to the application (basically alongside struts, using the same model underneath).
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
Frosty One,
We don't have many rules at Javaranch, but our naming policy is one of them. Please read this policy and change your display name to comply with it if you wish to continue posting. Thanks.
You can change your display name here.

Matthew Phillips
Ted Husted
Ranch Hand

Joined: Dec 02, 2002
Posts: 37
As Brian said, you can access a web service from Struts in the same way you would access any application model -- via the Action. Instead of calling a method that returns a result from a database, you would call a method that returns a result for a web service.
Ideally, you should try and encapsulate your business tier behind a facade. The Action doesn't need to know where the data comes from. It just knows it needs to call this method with these parameters. The Action can then return the result to the view (via the request context).
The Artimus application bundled with Struts in Action makes calls to both a database and the Lucene search engine. But all calls are behind a consistent facade so that the Action doesn't know where the result comes from. This makes it easy to add another persistance device, like a web service.
HTH, Ted.

<a href="" target="_blank" rel="nofollow">Struts in Action</a>
I agree. Here's the link:
subject: Struts and WebServices
It's not a secret anymore!