Link to home
Start Free TrialLog in
Avatar of Solar_Flare
Solar_Flare

asked on

WCF Services - how to organise large numbers or methods?

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.CarMethod1(arg);
svc.TruckMethod1(arg);
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.Transport.Cars.CarMethod1(arg);
svc.Transport.Trucks.TruckMethod1(arg);
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?
Avatar of ChloesDad
ChloesDad
Flag of United Kingdom of Great Britain and Northern Ireland image

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
Avatar of Solar_Flare
Solar_Flare

ASKER

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.
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
ASKER CERTIFIED SOLUTION
Avatar of Solar_Flare
Solar_Flare

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial