Skip to Content
Programming WCF Services, 3rd Edition
book

Programming WCF Services, 3rd Edition

by Juval Lowy
August 2010
Intermediate to advanced
908 pages
26h 22m
English
O'Reilly Media, Inc.
Content preview from Programming WCF Services, 3rd Edition

Service Contracts

  1. Always apply the ServiceContract attribute on an interface, not a class:

    //Avoid:
    [ServiceContract]
    class MyService
    {
       [OperationContract]
       public void MyMethod()
       {...}
    }
    //Correct:
    [ServiceContract]
    interface IMyContract
    {
       [OperationContract]
       void MyMethod();
    }
    class MyService : IMyContract
    {
       public void MyMethod()
       {...}
    }
  2. Prefix the service contract name with an I:

    [ServiceContract]
    interface IMyContract
    {...}
  3. Avoid property-like operations:

    //Avoid:
    [ServiceContract]
    interface IMyContract
    {
       [OperationContract]
       string GetName();
    
       [OperationContract]
       void SetName(string name);
    }
  4. Avoid contracts with one member.

  5. Strive to have three to five members per service contract.

  6. Do not have more than 20 members per service contract. Twelve is probably the practical limit.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming WCF Services, 4th Edition

Programming WCF Services, 4th Edition

Juval Lowy, Michael Montgomery
Programming .NET Security

Programming .NET Security

Adam Freeman, Allen Jones

Publisher Resources

ISBN: 9781449382476Supplemental ContentErrata Page