C# class architecture for REST services

Posted by user15370 on Programmers See other posts from Programmers or by user15370
Published on 2011-02-02T16:26:51Z Indexed on 2011/02/02 23:33 UTC
Read the original article Hit count: 242

Filed under:
|
|

Hi. I am integrating with a set of REST services exposed by our partner. The unit of integration is at the project level meaning that for each project created on our partners side of the fence they will expose a unique set of REST services.

To be more clear, assume there are two projects - project1 and project2. The REST services available to access the project data would then be:
/project1/search/getstuff?etc...
/project1/analysis/getstuff?etc...
/project1/cluster/getstuff?etc...

/project2/search/getstuff?etc...
/project2/analysis/getstuff?etc...
/project2/cluster/getstuff?etc...

My task is to wrap these services in a C# class to be used by our app developer.

I want to make it simple for the app developer and am thinking of providing something like the following class.

class ProjectClient  
{  
  SearchClient _searchclient;  
  AnalysisClient _analysisclient;  
  ClusterClient _clusterclient;  

  string Project {get; set;}  
  ProjectClient(string _project)  
  {  
    Project = _project;  
  }  
}

SearchClient, AnalysisClient and ClusterClient are my classes to support the respective services shown above.

The problem with this approach is that ProjectClient will need to provide public methods for each of the API's exposed by SearchClient, etc...

public void SearchGetStuff()
{
  _searchclient.getStuff();
}

Any suggestions how I can architect this better?

© Programmers or respective owner

Related posts about c#

Related posts about architecture