E N D
1. Agent Service Pattern
3. Problem to Solve You need to consume a service, but do not want to couple the implementation and communication details of the service to your application.
4. Solution: Service Agent Pattern AKA: Service Gateway Pattern
A specialization of the Gateway pattern.
The gateway pattern is defined by Martin Fowler as “An object that encapsulates access to an external system or resource.” http://martinfowler.com/eaaCatalog/gateway.html
6. Boundary Issues HTTP Communication
SOAP or REST
Connectivity may be unreliable or inconsistent.
Contract may be under the control of another organization or department.
Differing domain models
7. More Boundary Issues May need to switch vendors or support multiple vendors.
May have differing security requirements that the rest of your application.
Service objects may not play by the same rules as your business objects.
Errors are communicated in varying ways.
8. Uses Data caching.
Process Adaption – Adapt the business process to a service. May involve several related calls to the service. (Open, DoOperation, Close)
Handling of Synchronous and Asynchronous service calls. i.e. Silverlight
9. Uses Translate between simple container objects or XML data representation and your business entities.
Exception translation.
You’ve probably already used it: Wsdl.exe SvcUtil.exe.
10. Uses Can be stubbed for testing purposes
Graceful connection-specific error handling
Encapsulate service-related state management (Session id, cookie)
13. Guidelines One-to-one relationship between service agents and services.
May be made up of more than one object.
Should contain utility/service-related logic rather than business rules.
Not just for web services.
Personal preference is to make it part of a resource access layer repository along with database access objects.
14. Disadvantages May be overkill for small projects.
More code to maintain.
May lead to duplication of code.
16. Ambiguation Thomas Erl has reused the name “Service Agent”
Published in SOA Patterns http://www.soapatterns.org/service_agent.asp
17. Contact Info John Galioto
jgalioto@cinci.rr.com