sobota, 17 grudnia 2016

70-487 Create a WCF Service part 3

Visual studio simplifies creating of WCF service by providing project templates.

First way to create WCF service is to use the New Web Site option and then choose WCF Service.
It will create a new web site with a sample WCF service implementation linked to a .svc file, with related configuration in the web.config file. In this approach Visual Studio does not just create the core WCF project and add the needed assembly references, but it also builds the host application.



Figure 1. WCF Service template from Web Site

This creates the same files as the WCF Service Application template but organizes it as if it were a ASP.NET web site. App_Code and App_Data folders are created.

Second way is use one of the WCF-specific templates, including the WCF Service Library, WCF Application, WCF Workflow Service Application, and the Syndication Service Library template.

WCF Service Library 


Generates a new class library with a sample WCF service implementation and related configuration in the app.config file. This project is suitable if you want to create a host independent service or set of services, After creation it contains 3 files: IService1.cs, Service1.cs and app.config.

Figure 2. WCF Service Library template

Service contract file (IService1.cs or IService1.vb) is an interface that has WCF service attributes applied. This file provides a definition of a simple service to show you how to define your services, and includes parameter-based operations and a simple data contract sample.

Service implementation file (Service1.cs or Service1.vb). The service implementation file implements the contract defined in the service contract file.

Application configuration file (App.config). The configuration file provides the basic elements of a WCF service model with a secure HTTP binding. It also includes an endpoint for the service and enables metadata exchange.

WCF Service Application


This template automatically creates a Web site (to be deployed to a virtual directory) and hosts a service in it. the project includes the following four files:
  • Service host file (Service1.svc)
  • Service contract file (IService1.cs or IService1.vb)
  • Service implementation file (Service1.svc.cs or Service1.svc.vb)
  • Web configuration file (Web.config)

WCF Workflow Service Application


Generates a new class library with a sample sequential Workflow Service implementation and related configuration in the app.config file. Workflow Service is built with Workflow Foundation framework. WWF is out of the scope of the exam but you can read more about WWF in [1].


Syndication Service Application


This type of project template provides the syndication functionality in an application in which you can easily work with feeds in ATOM, RSS and other custom formats as a WCF service. Syndication is a mechanism of application integration in which a server exposes some application data in an interoperable format known as a feed.

[1] Windows Workflow Foundation https://msdn.microsoft.com/en-us/library/dd489441(v=vs.110).aspx 

1 komentarz: