NConstruct - Intelligent Software Factory

NConstruct Builder and Database Model Changes

NConstruct & WCF Web Services Hosting in IIS

Category: Using NConstruct
Target NConstruct Versions: 2.5 and newer
Document Release Date: December, 2009

Table of Contents

1. Problem Description
    WCF web services and NConstruct implications
    DOA and NetDataContractSerializer

2. Solution
    Selecting WCF web services hosting in IIS in NConstruct Builder
    Start-up project selection
    Selecting Windows integrated authentication on IIS
    Assign write permissions for ASP.NET user for log4n logger

3. Conclusion

 

1. Problem Description

Before opening Visual Studio solution file and running the NConstruct application, we need to describe some of the building WCF-DOA applications issues, show how to apply it in NConstruct Builder, how to assign authentication on IIS and write permissions for log4n logger.

WCF web services and NConstruct implications

Windows Communication Foundation (WCF) is Microsoft’s unified messaging framework for building distributed applications. It is targeted at two types of applications:

  • Distributed Objects Applications (DOA)
  • Service Oriented Applications (SOA)

Let’s define what we mean by each. “Distributed Objects Applications” are applications where client and service share common custom business object types and pass these objects back and forth over the wire. Conversely, SOAs typically hide business object types and pass lighter data transfer objects between client and service.

Since the cross-platform interoperability is not a required feature for our needs for the moment, we developed a simple WCF "Distributed Objects Application”.

DOA and NetDataContractSerializer

There are two main characteristics regarding our DOA application:

  • No ServiceModel Metadata Utility tool (SvcUtil.exe) is used to generate WCF client proxy objects. We simply use the same business entity objects (library) as on our WCF web server application.
  • Since we do not need the cross-platform interoperability and to keep things simple, use NetDataContractSerializer instead of DataContractSerializer. NetDataContractSerializer successfully serializes and deserializes an instance of a type into XML stream or document using the supplied .NET Framework types. The NetDataContractSerializer, unlike its brother the DataContractSerializer, serializes .NET type information.

Let's have a closer look about using NConstruct WCF web services in our NConstruct application.

2. Solution

Selecting WCF web services hosting in IIS in NConstruct Builder

The generation of WCF web service hosting in IIS is enabled by selecting the following properties as shown in the Figure below.

Northwind Server in Solution Explorer 

For the purposes of WCF web service, NConstruct Builder generates the project named [your application name]WCFWebHost.csproj (for example NorthwindWCFWebHost.csproj).

After generating the application and opening Visual Studio 2008 IDE (for example NorthwindNConstruct.sln), the following question will be asked by Visual Studio 2008 as shown in the Figure below:

Original Database Model

Click Yes to let Visual Studio to create the virtual IIS directory.

If IIS successfully creates the virtual directory, our Visual Studio solution will load successfully and the WCF web services project hosting in IIS will look like the following Figure:

Original Database Model

Before you run your application you have to execute certain steps:

  • select start-up project
  • select Windows integrated authentication on IIS
  • assign Write permission for logger

Start-up project selection

Select Northwind.Client.StartApplication and mark it as a start-up project in your solution.

Selecting Windows integrated authentication on IIS

Go to Control Panel > Administrative Tools > Internet Information Services.

Find NorthwindWCFWebHost node and click on it with the right mouse and select Properties. The following window appears:

Original Database Model

Go to the Directory Security tab, click on the Edit button and tick the check-box Integrated Windows authentication as in the following Figure:

Original Database Model

Assign write permissions for ASP.NET user for log4n logger

To enable log4net for logging, you have to assign write permissions on the application directory. Find [Your project dir]\Northwind\Src\Northwind\NorthwindWCFWebHost directory and click with the right mouse and select Sharing and Security option.

Original Database Model

 

Select the Security tab and allow the Write permissions for the ASP.NET user like in the Figure:

Original Database Model

You may now safely run your client application.

If you want to stop your web service, run Task Manager (shortcut hint: CTRL+SHIFT+ESC) and select the aspnet_wp.exe process and select End Process.

Original Database Model

You can also Run and Debug your server application with opening the separate Visual Studio solution file found in [your application dir] Src\[your application name]\ [your application name]WCFWebHost\[your application name]WCFWebHost.sln (for example NorthwindWCFWebHost.sln).

4. Conclusion

As we have shown throughout this short review, it is quite simple to integrate NConstruct application with WCF web services within IIS. More about WCF web services and NConstruct will be described in separate technical articles.

Comments and questions...