Signum Framework Logo
"Open framework that encourages convention over configuration, using C# code,
not XML files, to model at the right level of abstraction and achieve deadlines.
...but also has a full Linq provider, and syncs the schema for you!"
Login
RSS

Search

»



Main
Index
Map
Videos
Download
Source code
Tutorials
Forum
FAQ



Image



PoweredBy

Tutorial: Writing the Shared Contract

RSS
Modified on 2010/01/11 00:30 by olmo Categorized as SignumServices

Introduction

Since we are using WCF, we just have to write the contract of our service as an plain old interface decorated with some attributes. Nothing new here.

Some modules, however, need client and server code to be deployed, and require the service to implement some custom methods defined in an interface.

Accomplishing both things at the same time is as easy as defining our custom service interface as the union of all the needed interfaces (using interface implementation) and your own custom methods.

Example

Let's suppose we want to add a user interface to our bug entities. We will need the server to implement the mandatory IBaseServer interfaces to enable Entity Controls, and also IQueryServer interface to enable Search. We won't need any login here, neither excel reports, so we won't implement INotesServer or IAlertsServer for instance.

We will need, however, some custom methods in the server that will be called by our client logic.

An interface like this will do the job:

    [ServiceContract(SessionMode = SessionMode.Required)]
    public interface IServerBugs : IBaseServer, IQueryServer //INotesServer, IAlertsServer
    {
        [OperationContract, NetDataContract]
        IdentifiableEntity Save(IdentifiableEntity entidad); 
    }

Remember to decorate every custom operation with OperationContract, NetDataContract attributes.

In order for the client to know the interface (we don't use WSDL here) and the server to implement it, you need to place these interfaces in a shared assembly. The common thing is to place the Services in a folder inside the Entities assembly.

In previous version of the framework we recommended to place Contracts in a different assembly. Finally we have merged it for simplicity and they are merged with the entities.


Finally, you will need to:
Creative Commons License Signum Framework Site by Signum Software is licensed under a Creative Commons Attribution 3.0 License.
Powered by ScrewTurn Wiki version 3.0.5.600.