views:

188

answers:

3

Not having dealt much with creating web-services, either from scratch, or by breaking apart an existing application, where does one start? Should a web-service encapsulate an entity, much like a class does, or should the service have more/less to it?

I realize that much of this is based on a case by case analysis of what the needs are, but are there any general guide-lines or best practices or even small nuggets of information that web-service veterans can impart to a relative newbie?

A: 

Web Services are exactly what they sound like Services for the Web.

A web service should be built as an API for the service layer of your app.

A service usually encapsulates an entity larger than a single class.

To learn more about service layers and refactoring to add a service layer read about DDD.

Good Luck

Sruly
A: 

The number 1 question is: To what end are you refactoring your application functionality to be consumned as a bunch of web services?

Bedwyr Humphreys
+1  A: 

Our web services are built around functional areas. Sometimes this is just for a single entity, sometimes it's more than that.

For example, if you have a CRM, one of your web services might revolve around managing Contacts. Creating, updating, searching for, etc. If you do some type of batch type processing, a web service might exist to create and submit a job.

As far as best practices, bear in mind that web services add to the processing overhead. Mainly in serializing / deserializing the data as it goes across the wire. Because of this the main upside is solely in scalability. Meaning that you trade an increased per transaction processing time for the ability to run the service through multiple machines.

The main parts to pull out into a web service are those areas which are common across multiple applications, or which you intend to expose publicly, or which would benefit from greater load balancing.

Of course, you need to analyze your application to see where any bottlenecks really are. In some cases it doesn't make sense. For example, if you have a single application that isn't sharing its code and/or the bottleneck is primarily database related.

Chris Lively