views:

116

answers:

2

I have an existing database (PostgreSQL in my case), and would like to access its data (Create, Read, Update, Delete, Query) through SOAP Web Services. What we are doing now, have JPA implementation of each Entity, and have an implementation of a generic CRUD interface. Then we expose these beans as JaxWS web services. The problem with this setup is that JaxWS behaves weirdly with generic interfaces.

Since this is such a common problem, accessing DB through WS, i would like to know if there is an open source solution, which would expose all the entity tables as web services. Such tool would require as input a set of JPA Classes (or some other data description), or even a JDBC connection (to pull the SQL Schema out) and would produce a set of CRUD web services.

Ideally, such a tool would mainly consist of a Servlet, that could be embedded in any web application.

Please, tell me your suggestions for such a tool, and if you had any experience with using it, please share.

Thank you in advice

+2  A: 

Apologies for not answering the question, and instead saying "you don't want to do that", but ...

First, you may not need to do that. Does your database already expose Web services directly? For example DB2 UDB and its tooling does the job for you. No need to write the Java at all.

Second, maybe you shouldn't do it anyway? It's pretty much an architectural anti-pattern to expose your entity layer directly as a Web service. The granularity tends make the service inefficient and hard to maintain in the long term. Web Services in the large tend to be better as quite coarse-grained business-meaningful services. For example creating an Insurance Policy might require several updates and inserts to several different tables. To expose the raw table access capability as web services means that evey client needs to know exactly what to do. Instead expose a Web service CreatePolicy() and let the implmentation own the gnarly stuff.

djna
I agree. It is a bad idea to expose the entity layer as a web service. One will lose the ability of one of the primary features of databases - ACID properties of a transaction.
Vineet Reynolds
A: 

in our case we have a multi layered architecture, and one of its parts is the storage. I don't want to lose trunsactions, but if i need to insert a new customer via webservice, and i have a customer service together with its schema definition, that can be auto generated. Also to be noted, BPEL 2.0 to my knowledge, supports transactions, so these data service could be transaction aware, ie. participate in a distributed transaction.

Create new BLOG entry is an operation that COULD be executed in dedicated transactions. There are a lot of other cases in our project (almost for every table), and we DO need to expose them to external systems. Why write this by hand 100 times. As the author of ANTLR says, if you can do something manually in 5 days, why not spend 5 years to automate it.

I dont want to spend 5 years, and looking for a ready solution. Currently we have semi-automated the task, which includes code generation, and the biggest problem was that JaxWS doesn't work well with generic interfaces.

This artichecture has its advantages, since you can do a lot of cool things, like: - Have a set of annotations on top of your entity classes, to check ROLE permissions. This checks will occure, no matter how you access your entity, webservice or direct java call. Also u can once define hooks, like generating an RSS/Atom feed for all the operations on particular table. - There are a lot of gui tools support for entity types described in XSD, for automatic form creation. I dont want to generate all the forms, but at least have a default implementation, which can be substituted.

What i am looking for, is actually a data access abstraction protocol, which could be backended by a database or something else, end export itself as web services (soap/restful/json whatever)

There is this Apache incubation project, EmpireDB, the cool thing about them is they dont use annotations and javaclasses to define the model, so that metadata could be used easier to create XSDs and Forms. I dont have the leasure to use a non industry standard project, so am looking for a ready solution based on standard technologies: JPA(hibernate for example), JaxWS

tzador
WS-AtomicTransaction does allow you to distributed transactions, you don't need BPEL to do it. Whether it will perform well is a whole different question. Totally agree that **if** you are going to do this then tooling is the way to go. Which DB are you using? Doesn't have and native support for WS? Could you use http://www.eclipse.org/articles/Article-JET/jet_tutorial1.html to do your own code generation? If there's a regualr pattern to what you're generating this can be surprisingly easy.
djna
thanx for pointing out that BPEL is too much.PostgreSQL, but i am not aware that it does automatic WS exposition. I am sure Oracle does it.Couldn't find a way to embed JET to standard maven build cicle, so I wrote a set of groovy scripts, to walk the model classes, and generate the nongeneric interfaces/classes for JaxWS. T
tzador