Export (0) Print
Expand All

How to: Create a Contract

Published: December 17, 2010

Updated: October 9, 2012

Applies To: Windows Home Server 2011, Windows Server 2012 Essentials, Windows Small Business Server 2011 Essentials, Windows Storage Server 2008 R2 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 (http://go.microsoft.com/fwlink/?LinkId=164847). The contracts for the chat application are defined as C# interfaces.

noteNote
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.

    [ProviderEndpointBehavior(CredentialType.User)]
    [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.

    [ServiceContract]
    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.

Show:
© 2014 Microsoft