Difference between Webservice and Enterprise Service Bus

First, some general terms:

Service is a general term for exposed functionality that can be invoked from outside consuming applications. Most often services are exposed by the integration layer of applications. Services can be Web Service - SOAP-based, REST etc, so WebService is a subtype of service using SOAP.

Connecting all applications to each other does not scale well (communication channels grow exponentially as you add more and more applications to your environment) and this leads to expensive maintenance in the long term. This is why we are using middleware software (ESB being a type of middleware) as the sole point where application services are exposed.

So what is the difference between Service and ESB?

Services "live" on the ESB. They often represent particular functional contexts - for example business context of Customers, Orders. So, if you need to fetch customer info, you don't go directly to the CRM application, you send a request to the ESB service that provides this functionality. Thus you don't need to know anything about the CRM itself.

ESB in practice is a middleware (the integration backbone if you will) that provides the technical infrastructure and tools to easily host and implement services including:

  • Routing mechanisms
  • Connectors and bridges for different protocols
  • Listeners for different events
  • Means to implement different communication models
  • Data and model transformation means
  • Asynchronous queuing
  • Monitoring, logging
  • Policy centralisation
  • etc.

Using a middleware greatly reduces the number of point to point connections between systems, and also leads to better isolation and low level of coupling, which means more agility when you need to implement changes, switch between vendors and so on.

For more information on services I will suggest see this article. The whole site is great and you may want to explore it. Also, you can see representation of ESB as compound SOA design pattern, that you may find helpful.