tags:

views:

221

answers:

6

My project is converting a legacy fat-client desktop application into the web. The database is not changing as a result. Consequently, we are being forced to call external web services to access data in our own database. Couple this with the fact that some parts of our application are allowed to access the database directly through DAOs (a practice that is much faster and easier). The functionality we're supposed to call web services for are what has been deemed necessary for downstream, dependent systems.

Is this really how SOA is supposed to work? Admittedly, this is my first foray into the SOA world, but I have to think this is the complete wrong way to go about this.

+2  A: 

I agree that it's the wrong approach. Calling your own database via a webservice should raise red flags in a design review, and a simple DAO is the way to go (KISS principle).

Now, if it's data that truly needs to be shared across your company (accounts, billing, etc) THEN it's time to consider a more heavy-duty solution such as SOAP or REST. But your team could still access it directly, which would be faster.

My team had the same thing happen with a web service that we wanted to call in batch mode. Rather than call our own SOAP endpoint, we instead set it up to call a POJO (plain old java object) interface. There's no XML transformation or extra network hop through an SOA appliance.

It's overkill to put an XML interface between MVC layers when your team owns the whole application. It may not be traditional SOA... but IMO it's traditional common sense. ;)

Drew
Yeah, that's a big reason why I think its not a good idea. There's the marshalling/demarshalling, introduction of another point of failure, etc. Our data does, however, need shared across the company, but we are the ones who create the data. No other system should be modifying data in our database. They simply need to do reads. What I suggested to them was that we developer own own POJOs as services using Spring and DAOs to call the database directly, writing custom queries and whatever else we need. Then, the services we write can be deployed to downstream apps.
smaye81
A: 

Good SOA design is all about separation of behavior and data. I repeat behavior and data need to be separate or else you will have lots or problems whether its CORBA/SOAP/REST/XMLRPC or even plain old in-the-same-JVM-method calls.

Lots of people will talk about service end points, message handling, and contracts making SOA one of the more soporific areas of computing when its surprisingly not complicated.

If you are doing Java its really easy. Make POJOs for your domain objects with no weird state behavior and no weird collaborators and then make Service classes with the behavior. More often then not you can just use your DAO as the service (I mean you should have a thin layer over the DAO but if you don't need one....).

OOP lovers will disagree of this separation of data and behavior but this design pattern scales extremely well and is infact what most functional programming languages like Erlang do.

That being said if you are making a video game or something very state based then this design philosophy is a bad idea. BTW SOA is about as vacuous as the term enterprise.

Adam Gent
See my first comment above. My recommendation to the higher powers were to allow us to develop our own POJOs and DAOs and then to deploy these to the downstreams as needed. It makes it worse that these downstream systems are not even ready to consume the services, yet my application needs them now.
smaye81
A: 

SOA... SOA... is the bane of my existence, for just this reason. What, or what not, constitutes SOA? I support SOA products in my day job, and some people get it, some don't. SOA.. SOA is about wrapping discrete business services in XML. ZIP+4 validation services. Payment gateways. B2B messaging.

SOA CAN be used to decouple desktop apps from backend databases. Sometimes it doesn't make sense, sometimes it does. What almost NEVER makes sense is low-latency high-query-count logic. If you ever have to use an application in France directly connected to a database in California, you'll get what I mean. SOA pretty much forces you to then smartly about how you model and return your data (look into SDO - Service Data Objects). The devil's in the details though. Marshalling data to/from XML can be costly.

Chris Kaminski
+2  A: 
Bert F
Yes, you are correct. The need for them is necessitated by the fact that downstream systems will need to read the data. They do it through Oracle views now. You hit the nail on the head that the tables are too low a level for SOA. We have an enormous database (~1000 tables) and my app has to interact with these tables constantly, all day long. As I mentioned, this is a legacy DB which is not changing and a lot of tables have close to 100 million records in them.
smaye81
Thanks @smaye81. When I reread my answer, the key point that you identified with seems to be hard to see. I'll edit the answer to highlight that point.
Bert F
A: 

Which part do you think is wrong? The part that you have to hit the web service, or the part you are hitting the database directly?

SOA is more of an API design guideline, not a development methodology. It's not an easy thing to implement, but the reward of reusability is often worth it.

See Service-Oriented Architecture expands the vision of Web services or any technical book on SOA. Simply wrapping function calls with web call does not make it a Service Oriented Architecture. The idea of the SOA is to make reusable services, and then you make higher level services (like website) by compositing or orchestrating underlying low-level services. At the very low level, you should focus on things like statelessness, loose coupling, and granularity. Modern frameworks like Microsoft's WCF supports wiring protocols like SOAP, REST, and faster binary side by side.

If your application is designed to run over the Internet, you should be mindful of the network latency issues. In a traditional client-server application that is deployed on a LAN, because the latency is sub 10 msec, you could hit the database every time you need the data without interrupting the user experience. However, on the Internet, it is not uncommon to have 200 msec latency if you go across proxies or oceans. If you hit the database 100 times, and that will add up to 20 seconds of pause. In SOA, you would try to pack the whole thing into a single document, and you exchange the document back and forth, similar to the way tax is filed using Form 1040 if you live in the US.

You may say that the latency issue is irrelevant because the web service is only consumed by your web application layer. But you could hit the web service from the browser using AJAX reload the data, which should give the user shorter response time.

eed3si9n
I am worried about a whole host of issues -- network latency, the fact that the people writing the services have no real exposure to the legacy system they are rewriting, the marshalling/demarshalling of data, the extra point of failure, the impossibly coarse granularity of the methods. The app is an internal app, it will not run over the internet, but it will be in constant contact with the database. As I mentioned, we have ~1000 tables with hundreds of millions of rows in them.
smaye81
A: 

Consequently, we are being forced to call external web services to access data in our own database.

Man, that gotta hurt. As far as services in SOA go, a service is a repeatable logical manifestation of a business task - that means you are not implementing SOA if you are not 'service enabling' business processes. If you are putting some web services to select data out of your data base, all you got is a bunch of webservices, which would slowdown your applications which could have been faster by conventional data access patterns (like DAO)

When you equate SOA with Web services there is a risk of replacing existing APIs with Web services without proper architecture. This will result in identifying many services that are not business aligned.

Also, service orientation is a way of integrating a business as a group of linked services - so ask yourself is the organization making use of these atomic services to achieve further benefits?

Do a google search for SOA anti-patterns and you will find what are the different ways to end up with a pile of web-services instead of SOA.

ring bearer