WCF Services - how to organise large numbers or methods?

Posted on 2009-02-10
Last Modified: 2013-12-17
I am putting together a WCF service application, and my concern is that as it grows all the methods will be appear as methods of the xxxServiceClient proxy on the client. The methods could easily be grouped logically like nested classes, but I can't see a way to do this with wcf.

As an example, a service with methods for cars, truck and distance would look something like this on the client

WCFService.IMyService svc = new MyProject.WCFService.MyServiceClient();
svc.CalculateDistance(point1, point2);

But if it grows to hundreds of methods it would be messy, ideally I would end up with code on the client looking like

WCFService.IMyService svc = new MyProject.WCFService.MyServiceClient();
svc.Utility.CalculateDistance(point1, point2);

Does anyone know if it is possible to do something like this, or what is the best practice for separating/grouping methods in services with large numbers of methods?
Question by:Solar_Flare
    LVL 15

    Expert Comment

    As with any .Net structure you would need to setup a class that is called something like

    Public Class CarMethods

    ' all Methods go here

    public sub Car1

    end sub

    ' etc

    end class

    The same for trucks etc

    then in your myserviceClient class

    have public property Cars as mycars
    public property Trucks as mytrucks
    LVL 15

    Author Comment

    This is WCF, the MyServiceClient class on the client is autogenerated from the WSDL/MEX, and all service methods must be implemented in an interface.
    LVL 15

    Expert Comment

    If its auto generated then no you can't. The only way that you can do it is using classes, and as you cant then they will all be in a single class
    LVL 15

    Accepted Solution

    Please don't comment on a WCF question if you don't know anything about WCF.

    For anyone that is interested in the future, I found an post that comes about as close as you can get (I think) to achieving this with WCF.

    You can break the interface up and offer each interface via a separate WCF endpoint on one service, but all the methods need to be implemented in a single class which implements all your interfaces

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    This video discusses moving either the default database or any database to a new volume.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now