开发者

WCF wrapping the service layer for asp.net mvc

I'd like to expose certain methods of my service la开发者_运维百科yer as a WCF service. If I make my whole service layer as wcf methods, would the calls from my web app be slowed down because I'm converting to and from xml for no reason? As shown in this image:

WCF wrapping the service layer for asp.net mvc

How would my project be layered or structured?


WCF services are just a contract.

You can easily expose service classes as a contract for a WCF service and also just new them up like normal classes for use in your MVC application. You won't be creating XML or SOAP/Http messages if you simply use your service classes as just classes.


If I make my whole service layer as wcf methods, would the calls from my web app be slowed down because I'm converting to and from xml for no reason?

Compared to calling the service methods directly, the WCF methods will be slower because of the network latency and serialization.

Depending on your requirements there are different techniques. In all cases you should encapsulate your service layer into a separate reusable library. Then start by using this library in your MVC application. If you are happy with the results we are finished. Now if you later need interoperability and exposure of your service layer to third parties you could easily expose this library to a WCF service.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜