views:

21

answers:

2

I want to create a spring-ws web service that eventually marshals a POJO into xml. I'd also like the clients of the web service to unmarshal the xml back into the POJO. How should I structure the projects?

Currently my thinking is:

  1. Domain and business layer project - has the ability to query mainframe and create POJOs. This project has no dependencies to any of the below projects but does depend on the mainframe lib.
  2. Web service project - implements a web service that receives a request, calls the business logic in project 1, and returns a marshalled domain object from project 1.
  3. Client project - calls the web service, receives some xml, unmarshals the xml into a domain object from project 1.

The problem I have with this design is that project 3 depends on project 1 for the domain model, but as a result of this, depends on the mainframe libraries. This contradicts my main reason for creating a web service in the first place which was to loosely couple the code.. the flip side is to split out the domain model from the business logic into separate projects but this seems a little extreme..

A: 

No, I would say you still have just project 1 for server and 2 for client. No need for 3.

Project 1 should have the usual Spring suspects: persistence, service, and model objects. Your choice to expose the POJO service interface as a web service is just one of many choices; make the ws tier part of project 1.

Project 2 is the client. It only needs to get WSDL information. Perhaps marshaling and unmarshaling classes can be shared as a 3rd party JAR.

Or they could be one project that's packaged differently for server and client. That might make the most sense, because you need the client for testing. Consider it part of your test package.

No need for all these projects. Just packaging and deployment that are different.

duffymo
A: 

I prefer to separate my projects as well. Can you separate your domain model POJOs from the business layer into another project so that they can be shared by the client?

Blaise Doughan
Hi Blaise, that's what I've gone with in the end, it just seems a little odd to me that I have to have a project with 4 domain objects in it just to handle dependencies.
James
True, but dependency management is important. If this is the direction you take, please consider accepting this answer. The project I work on (EclipseLink) is structured in OSGi bundles. OSGi provides a lot of dependency management options.
Blaise Doughan