Views: 3.5K
Replies: 0
Archived
|
Patterns for communicating to legacy services.Overview:
We are in the process of designing an MVC web application that will need to communicate with legacy web services (non .Net). The services accept and return xml structures. The returned xml structures are then used to hydrate our domain model. The services are the applications only source of data. Question: What are your opinions on patterns used to communicate with the legacy services? The goal would be to create a clean, easy to use interface that is exposed to our controllers. Option 1: Create a DataContext that is backed by DataMappers. A controller would then communicate with the datacontext to do CRUD activities for our domain objects. The datacontext would then use the mappers to form xml requests which are then queued up and issued to the legacy services. On return the datacontext would then use the mappers to hydrate domain objects based on the returned xml. sample code: DataContext.InsertOnSubmit(objectOne) DataContext.DeleteOnSubmit(objectTwo) DataContext.SubmitChanges(); Option2: Use the request/reply pattern and a request dispatcher. Where the controller would create the request object and the dispatcher would issue that request to the legacy service. The dispatcher would be responsible for formatting serializing the requests/responses to the proper format. sample code: ObjectOneRequest request = new ObjectOneRequest(); request.entitty = objectOne; request.actionType = create; request.requestId = guid.newGuid().ToString(); Dispatcher.requests.add(request); Dispatcher.ExecuteRequests(); ObjectOneResponse response = Dispatcher.Responses(request.requestId); Thoughts? Suggestions? C Lock, Jun 25, 2010
|