The Greenfield

Played today with some thoughts about "greenfield", "brownfield", the Service Factory and Team Architect.


I think many people who are willing to use the service factory, already have build services and who are willing to use Team Architect allready build applications :-)
So, when you start using it at your development department, you must also think about those “brownfield” applications. I don’t think you are going to build only new “greenfield” services from scratch…

So, some possible “brownfield” scenarios:

  1. A software solution already in production and there is a need to upgrade, for example from .NET 1.1 to .NET 3.5.
  2. A software development department already working on a product wants’ to use team architect and WSSF modeling edition.
  3. Probably more, for example where you only want to reuse some parts of the application.

First ideas…
I think with scenario 1 where you want to upgrade, Team Architect en the P&P Factories would help enormously. The development team is going to use new technologies and the factories already have the best practices in them, this will boost the learning of new technologies.

For scenario 1, what you can do is use the feature “Create from WSDL” [This feature is available at the application diagram and at the service factory]. Generate the service model, the code and reuse the other layers

Let's give it a try...
A walkthrough on upgrading the ASMX Reference Implementation to WSSF V3 Modeling Edition with Team Architect [should be easy]

First step: open the ASMX Reference Implementation, take a look at the services and build the solution.
For now I'm only going to focus on the "QuoteService" which has two operations, "GetQuote" and "GetQuotes", the other models I will generate but I won’t focus on the implementation, should be the same.


Second step: of course I'm going to use Team Architect for the big picture and focus. So, create a new Distributed Application, call it GlobalBank and draw the shapes. The ASMX RI has three services and two databases.
I also added a Windows Client to it. In the reference application the clients are in the Test projects, I won’t focus on that [lazy].
Connect the shapes [see image].


Next step: at the Application Diagram, right click on a Service Endpoint and select “conform Endpoint to WSDL”, you get a “Add Web Reference” dialog box. Grab the WSDL URL from the ASMX RI "QuoteService.asmx?WSDL" and put it in the textbox.


At this moment all the information is added from the WSDL to that EndPoint [see image]. The operations, the WSDL binding information, the namespace and so on.
When you generate the service with the default template it will generate also the types [with roundtripping], but still ASMX and for our upgrade “brownfield” I want to upgrade to WCF and use the Service Factory.
Anyway, use the “conform to WSDL” for each service endpoint.


Fourth step: attach the Service Factory Template to the services [should be in this location ...\..\Service Factory Guidance Package\Guidance Package\bin\Debug\Templates\Solutions]. NOTE: This is the customized template which can read values out of the AD file. [If anyone is interested send me a mail].
Right click the shapes and select “Implement Application”. This will create all the service models, with their operations, service contracts, message contracts and namespaces. Nice… I like this.


The picture above is the "Branche Service" and this is the "CustomerProducts" [the CoreAccounts service you can see in the next step]


Fived Step: so far we got the application landscape with all the connections and we can zoom in at service level, where we can see the operations and contracts.
Before we can generate code we have to define the DataContracts / XSD’s. Lucky those XSD’s are the same as in the WSDL. So, extract the XSD’s from the WSDL and add them to the “Schemas” solution folder.
I use XML Spy to extract the XSD’s, the service factory also can do this [during the WSDL import].

Attach the XSD types to the XML Message Parts and we are ready for code generation.


Next: we just created the Service Interface and we are going to reuse the other layers. Easy, just add them.
I use the Power Tools from Team Architect which also visualizes libraries. Adding them and reference the Service implementation library can be done by drawing a connection between them. Finally all the libraries and the connections between them look like this picture.


Final step: and the only step where we have to type some code. Create the adapters, create the translators, or better reuse them… the types are the same as in the ASMX RI, so that’s no problem. Only one thing you have to take in to account… the ASMX RI doesn’t use message contracts and the WCF Implementation does.
Actually the only thing I had to create from scratch is the partial class part from “double derived pattern ”.

scv impl

and expose the "Upgraded to WCF" service...


I used VS2005 and VS2008 because WSSF V3 is'nt available for 2008 yet.

Add comment

Şarkı Sozleri