views:

80

answers:

3

Hello,

Can anyone point me in the direction of documentation for exposing a DAO as an external web service? Currently, in my application we follow a DAO -> Service -> UI layered architecture. Everything is internal to the app, our DAOs access the DB through Spring JDBC and the services are visible only to the web application.

We now have a need for downstream systems within my company to access the DAOs we've created. I need to know what the effort would be to expose our DAOs and what, if any, other technologies I would need to perform this task.

Also, would I expose the DAOs themselves or the services?

A: 

I guess I don't fully understand the problem. You'll have to create service operations that do CRUD operations for you DAOs, along with operations for any special data processing your DAOs perform. You already expose the DAOs via service to your current UI. Can you not simply use that service as a template for your externally facing service?

Randolpho
Yeah, that was actually how I thought the approach would work originally, but I was told by an architect here it would be the DAO exposed. So, I would expose my already-written service to external applications.
@smayers81: well, odds are your already written service is tightly coupled to your UI, so there might be some operations on that service that you won't want exposed, and there might be some operations that aren't exposed that you *do* want exposed. I don't know of any automatic tool that will build a service framework around your DAOs. At least, not for Java. You're going to have to create custom data structures for your service that resemble your DAOs and operations for your service that reflect operations available on your DAOs.
Randolpho
That said, you might find [this article](http://www.lulu.com/content/content_download_redirect.php?metaId=1090073) very interesting. [Warning, PDF]
Randolpho
So is it not possible to only expose certain methods of my service, for example, through annotations?
@smayers81: if you set up each DOA as a separate service, I suppose so. I would personally not do such a thing, as that would tightly couple your DAO to your service layer. I would build a translation layer whose sole responsibility would be translating service calls into calls to a DAO.
Randolpho
A: 

Well, I would suggest not to expose DAO through WebServices,Instead expose Service method in WS.

But if you need to do this

Create a Layer of WebServices right above of DAO and lower the Core Service Layer.

And you can expose DAO to any other modules if you want.

Let me know why DAO is needed to be exposed.

org.life.java
here is the tutorial for Spring Web Services. It would be easy and yes it can be done with eclipse
org.life.java
http://www.springbyexample.org/examples/simple-spring-web-services.html
org.life.java
A: 

If I were you, I'll just wrap the DAOs in a webservice. So, first define the wsdl, then generate the java code that goes with that wsdl. Then, in the webservice implementation, just hand-copy the entity beans into this webservice beans. Guess you could use bean copy utils if that is too tedious.

Not sure if you can use the entity beans directly in java2wsdl style webservice development, but that seems like a bad idea because you don't have an abstraction layer between entity beans and webservice interface in that case.

Enno Shioji
I am really new to all of this. Is that all stuff that can be done within Eclipse?
@smayers81: Never used eclipse for this, but I'm sure you can. There are a lot of options. I personally liked CXF integrated with Spring. If I were in your position, I'd go with that.
Enno Shioji