Results 1 to 5 of 5

Thread: [RESOLVED] Designing WCF Services

  1. #1

    Thread Starter
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Resolved [RESOLVED] Designing WCF Services

    OK so I've got my WCF book now and I've read the first couple of chapters So I now know how to create a WCF service, and how to create a client that can use the service contract provided by that service... but what I am not quite sure on (maybe it will be covered later in the book) is how you should design the service contracts that your WCF service provides.

    I mean, is it common to just create one endpoint in your WCF service that exposes one class (service contract) and this one class contains every single method/property/function etc that can be called from your service? Or do people normally create several different classes that implement different service contracts?

    To help me learn WCF I am going to be making the good old fashioned instant messaging application just for people in my office to be able to use. I want a WCF service to be running on our server that keeps track of who is signed in to the IM app currently and I want it to be responsible for delivering the messages from each client to each recipient. So would I just create one endpoint that exposed a service contract named something like MessengerService and then that one class/contract would contain methods such as "SendMessageToRecipient", "SignIn", "SignOut" etc etc.

    Thanks in advance for your wisdom
    Chris
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  2. #2
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Zeist, The Netherlands
    Posts
    266

    Re: Designing WCF Services

    I've been wondering the same thing, and I came to the conclusion that I will at most ever build 3 services. One for every possible InstanceContextMode; so one that is a singleton and is shared by all users, one that is per session and thus user-specific and one that is stateless. Although from my thoughts so far, the stateless service is not needed if you have another service as well.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Designing WCF Services

    The methods should sit in classes which represent what they're about, so it's just common sense. If the methods are all related then it would make sense to have them in a single class and expose that contract, but if they're various aspects of managing the chat, then it won't make sense to have all the methods in a single class. For example,

    ChatService.svc.cs
    SendMessage()
    RetrieveMessage()
    GetSmilies()

    ChatReporting.svc.cs
    GetChatReport()

    ChatContacts.svc.cs
    GetFriendList()
    GetBlockedList()

  4. #4

    Thread Starter
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Designing WCF Services

    Ah so it is common to have more than one service contract exposed then, thanks for the clarification
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [RESOLVED] Designing WCF Services

    Yeah, think of them as URLs to web pages... you do want the URLs to make sense. Don't worry about performance hits, as they're stateless calls.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width