How to: Create a Contract


Updated: October 9, 2012

Applies To: Windows Server 2012 Essentials, Windows Home Server 2011, Windows Storage Server 2008 R2 Essentials, Windows Small Business Server 2011 Essentials

You should start to develop a provider by identifying the functionality that you want to present to the home or small business network. The contracts that you define should be consumed through the object model. It is important that you understand the functionality of your object model and how it will be called by users to make sure that you have a usable contract interface. For more information about how to create contracts, see Designing Service Contracts ( The contracts for the chat application are defined as C# interfaces.

System_CAPS_ICON_note.jpg Note

Before you start the procedures in this section, you should complete the procedures listed in How to: Create an Object Model.

To create the service contract

  1. In the ChatSample.ObjectModel project, open the IProvider.cs file.

  2. Change the interface to include the SetUserName and the SendChat operations.

    [ServiceContract(CallbackContract = typeof(IProviderCallback))]  
    public interface IProvider {  
       [OperationContract(IsOneWay = true)]  
       void SetUserName(string name);  
       [OperationContract(IsOneWay = true)]  
       void SendChat(string text);  
  3. Save the project.

To create the callback contract

  1. In the ChatSample.ObjectModel project, open the IProviderCallback.cs file.

  2. Change the ResponseReceived operation to include the user name and text parameters.

    public interface IProviderCallback {  
       [OperationContract(IsOneWay = true)]  
       void ResponseReceived(string user, string text);  
  3. Save the project.

The next step is to create the provider. To do this, see How to: Create a Provider.

Community Additions