Windows Communication Foundation

Assignment: 2

Year: 3

Date In: 20th May 2008

To:  Stephen Hole

From: Julian Moruzzi

Table of Contents

Table of Figures

Introduction

This small report has been produced to support an application that has been developed in the area of Distributed Web Applications. It is contained on a CD supplied with the document.

The application that has been developed creates a self-hosting Windows communication foundation (WCF) project that is capable of calculating two types of mathematical functions:

  • Solving problems using Pythagoras
  • Using trigonometrical functions to work out the values of angles and Triangle Sides.

The software developed also writes to a database over the hosted WCF. This database interactivity writes a username of the person working out the calculation, the date it has been used as well as what function they used on the application.

On top of these processes a second WCF has been self hosted to a separate client form which sends back from the database a search function so that a user can see how many times a specific function in the application has been used, such as ‘Pythagoras’. This is contained in a gird view.

This report helps in explaining the underlying code contained within the software as well as explaining ways in which the application could be hosted using the Microsoft IIS server.

For the purpose of this report the application developed has been named ‘Maths’.

1.‘Maths’ Application Development

The concept of creating such a WCF was to show how the application could be self-hosted. A WCF ‘enables developers to build secure, reliable, transacted solutions that integrate across platforms and interoperate with existing investments or applications.’[1]

The WCF that has been developed in this example provides the user with the functionality of being able to work out mathematical calculations. It has been designed using the programming language VB.net.

The main proportion of the application is created in two parts:

  • The Host (found in the file MathsHost)
  • The Client (Found in the File MathsClient)

There is also the search engine for the database which has also been created using the WCF framework and these are found in the files:

  • The Host (found in the file SearchHost)
  • The Client (Found in the File SearchClient)

The main advantage of the Maths Host (WCF) and Client is that all the code that deals with trigonometrical and Pythagoras calculations are inserted in the document class of the ‘Host’ or WCF. When this program is running any clients which are referenced to this WCF can use this code. This cuts down on huge amounts of programming enabling one WCF to be used across platform by many clients. The ‘WCF’ is self hosting and doesn’t need the use of server using port 8001 of the computer used in the example.

1.1 Details of creating the WCF ….. Shown Below

The code below imports certain Namespace’ such as ‘Imports System’ to the class ‘service.vb’ in the host which are a collection of elements from the .net framework extensions to use. A public interface has then been written to incorporate each of the individual functions on the following page, many of these have been taken out below but in the actual code there are 10 different operation contracts and functions for each of the math functions as well as the database function.

There are two functions shown on the following page, one that works out the angle of a triangle given two sides, the opposite and the adjacent. The other inserts into a table called ‘JulianWCF’ certain fields that the user enters on the form of the client.

Figure 1: Service.vb code from the MathsHost project

Join now!

1.2 Maths Host

In the ‘MathHost’ project there is also a form which enables the host to start and stop, this form was created to enable the WCF to self host, for it to be self hosting, its own code has to be provided to initialise the hosting environment, which has been achieved in these examples. The code for this is shown below:

Again a number of namespace catalogues are imported (not all shown here). Code is written to allow the program to use a specific computer port (8001).  The service that is created is ...

This is a preview of the whole essay