开发者

How do I restructure a sprawling WCF service

开发者 https://www.devze.com 2023-04-08 15:15 出处:网络
I am new to Windows Communication Foundation and I am working on a system that serves data to a front end.

I am new to Windows Communication Foundation and I am working on a system that serves data to a front end.

The WCF portion of the system consists of hundreds of queries that retrieve specific filtered datasets. These datasets are send back to the client via over a hundred different classes. It almost seems like there is a separate class for each service o开发者_Go百科peration.

A snapshot of the code would look like

 [OperationContract]
    IList<A> LoadAdata();
 [OperationContract]
    IList<B> LoadBdata();
 [OperationContract]
    IList<C> LoadCDdata();
.
.

In addition alot of time and code is spent converting from the dataset into the IList<> objects.

My Questions are:

Is this how WCF is suppose to work?

Is there a better way to structure this service?


  1. The typically structure you describe is not an absolute necessity for WCF to work. It can be a practice that your company to have a standard way of dealing with service and data contracts. For example: ServiceResponse ServiceOperation (ServiceRequest request); is a common pattern to see. This allows to flexibily maintain the input and output parameters of a service operation, without changing the outer visible signature of the operation. This might seem overhead, but can serve a purpose.

  2. Is operations are standard CRUD operation and all look the same and do not have any specific business logic behind it, please take a look at WCF Data Services which exposes your data model as a standardize OData interface. The client is able to create custom queries and prevents the service from having to expose a large set of interface operations. It is all handled for you in that case.

0

精彩评论

暂无评论...
验证码 换一张
取 消