Difference Between Service Agent and Service Gateway

I'm working on my upcoming session for the Columbus Day of .NET and as I'm listing some of my talking points, a question occurred to me: what's the difference between a Service Agent and a Service Gateway? I've kind of always used them interchangeably, but since I'm giving a talk about one of them (the Service Gateway) I figured I best do a little research into the matter. Afterall, someone at the session is bound to ask me what the difference is, and I better have at least some sort of semi-intelligent answer.

So I pulled out two of the Patterns and Practices books: “Enterprise Solution Patterns in .NET” and “Application Architecture for .NET: Designing Applications and Services”. These two books have been tremendously helpful to me over the course of time, and if you haven't read them, I strongly suggest you do (the sooner the better, trust me).

In the Application Architecture book, the term Service Agent is used, with the following definition:
”When a business component needs to use functionality provided in an external service, you may need to provide some code to manage the semantics of communicating with the particular service. Service agents isolate the idiosynchrasies of calling diverse services from your application, and can provide additional services, such as basic mapping between the format of the data exposed by the service and the format your application requires.”

In the Enterprise Solution Patterns book, the term Service Gateway is used, with the following definition:
”The Service Gateway design pattern provides guidance for implementing the service consumer portion of the contract. It discusses using a component that encapsulates all the low-level details of communicating with the service and exposes an interface that is optimized for the use of the other components within the service consumer application. Service Gateway also maps between the internal organization of information in your application and the format mandated by the service's communication contract.”

Essentially, both of those definitions say the same thing, which means there isn't really any difference between the two. And although there are hints that a Service Agent is a physical representation of the Service Gateway pattern itself, it's fairly obvious the two terms are synonomous and interchangeable.

Print | posted on Monday, January 10, 2005 9:41 PM

Feedback

# re: Difference Between Service Agent and Service Gateway

left by Peter B at 1/17/2005 11:23 AM
Hey Dave,

Consider that a Web service proxy class that VS automatically creates for you when you add a Web reference is a Service Agent.

- Peter

# re: Difference Between Service Agent and Service Gateway

left by Michael Wittenburg at 2/17/2005 8:22 AM
Interesting. Technically and conceptually I interpret an agent as being a provider, and a gateway a consumer of a service. So the agent encapsulates the complexity of the underlying process/service, and the gateway in turn encapsulates the complexities of dealing with a service...

...which leads to another distiction - that of gateway vs. interface vs. agent. I typically use a gateway to talk to a service interface - this being between the UI process and business services. Business components in turn make use of agents, with or without a gateway. That choice is driven by the type of service being consumed.

So where 3 agents are created that abstract, e.g., three different equity trading systems, I create a gateway that calls a broker which in turn calls the relevant agent.

# re: Difference Between Service Agent and Service Gateway

left by Gregor Hohpe at 3/22/2005 10:10 PM
You are right, they serve essentially the same purpose. The slight difference is that Service Gateway has been elevated to pattern status (and is consistent with Gatweay in Martin Fowler's PofEAA and Messaging Gateway in my own Enterprise Integration Patterns). I prefer Gateway because most people see an Agent as something autonomous, which this component most of the time is not. It simply shields the app from all the plumbing work to make a service call. Also, Gateway has the nice colloquial connotation of something outbound.

# re: Difference Between Service Agent and Service Gateway

left by Benjy at 10/2/2005 8:57 AM
Very interesting points. Re: Gregors point on Gateways referring to outbound stuff, funnily enough, I was briefly involved in a project a while ago where they had a web service gateway that did exactly the opposite in that it provided an Incoming endpoint for suppliers to send some business data that was consolidated in a central repository.

Its true that the service agent sounds far 'richer' than gateway.Considering that within a gateway we usually have dedicated handlers for specific external services we could consider those handlers to be agents. In this perspective a gateway is just a system boundary consisting of one or more agents to communicate with the external services.

Cheers
benjy
Comments have been closed on this topic.