Patterns and Practices recently made available a drop of their Web Services Software Factory toolkit.
The Service Factory is a cohesive collection of various forms of guidance that have been build with the primary goal of helping you build high quality connected solutions in a more consistent way with less effort. In addition to the forms of guidance you may have already seen from the patterns & practices team, there is a new form of guidance in here, called a guidance package, that allows guidance to be automated from inside Visual Studio 2005 through the use of a wizard-based dialog than can be modified (by an architect perhaps) to fit the needs of a specific solution.
The frist drop includes a reference implemention as well as a set of Guidance Automation recipes for helping automate the development of services using WCF/Indigo. Below is a list of some of the recipes I came across during my experimentation:
-
Create WCF Solution – This builds a nice big solution with seperate projects for all your contracts (service, data/message, fault), as well as your service implementation, data layer, business entities, business logic, host, client, and kitchen sink. The package does a good job of seperating our everything into distinct projects which helps to make the point that things should be be clearly seperated. The structure that was created for my “CustomerService” was as follows:
-
CustomerServiceBusinessEntities
-
CustomerServiceBusinessLogic
-
CustomerServiceDataAccess
-
CustomerServiceDataContracts
-
CustomerServiceFaultContracts
-
CustomerServiceServiceContracts
-
CustomerServiceServiceImplementation
-
CustomerServiceHost
-
CustomerServiceClient
-
Create Data/Fault Contract – This has a couple different options including creating a data contract or fault contract via a wizard, or via code snippets. I hate wizards so I can’t see ever using the wizard to create my data contracts. The amount of time it takes to navigate around the data grid to define your contract would be much better spent in the VS.NET editor. Do we really need a wizard for everything?
-
Create Service Contract – This allows you to define the contract for a service again providing both a wizard and code snippet option. If you like wizards your going to love the P&P team.
-
Create Service Implementation – This allows you to create a service implementation by selecting a service contact. Those familiar with writing code will likely skip this one as well and use the wonderful SHIFT+ALT+F10 keyboard shortcut to implement the service contact after inheriting their concrete implementation for the proper interface (aka: service contact)
-
Create Service Contract Translator using Wizard– This little beauty allows you to map your business entities to your data contracts. While I couldn’t actually get this to run it seems like a nice utility that can help reduce the amount of grunt work required when you translate all your messages into your entities and vice versa. Update: It’s working, something was hosed on my home installation of WinFX). An example below shows a translator created to translate my Customer data contract into my Customer business entity. Pure Fun!
public class TranslateBetweenCustomerAndCustomer {
public CustomerServiceDataContracts.Customer TranslateCustomerToCustomer(CustomerServiceBusinessEntities.Customer from) {
CustomerServiceDataContracts.Customer to = new CustomerServiceDataContracts.Customer();
to.CustomerName = from.CustomerName;
return to;
}
public CustomerServiceBusinessEntities.Customer TranslateCustomerToCustomer(CustomerServiceDataContracts.Customer from) {
CustomerServiceBusinessEntities.Customer to = new CustomerServiceBusinessEntities.Customer();
to.CustomerName = from.CustomerName;
return to;
}
}
-
Decorate Type as Data Contact – This allows you to right click in a class and select for it to be decorated as a data contract. A [DataContract] attribute is added to the class and [DataMember] attributes are applied to all properties.
-
Validate Data Contact – This allows you to right click in a class and have the data contract validated. Amazingly the data contract produced by their wizard validates quite well!
Overall there seems to be some pretty useful nuggets of guidance within the first release. I’m very interested to see the project progress and mature. I just hope the wizard to coding ratio doesn’t get too ridiculous.