Rest vs Wcf pros and cons [closed]

2019-04-18 01:30发布

What are the pros and cons of using a rest service vs a wcf service?

I am wondering which type to use and I was interested to find some sort of comparision.

标签: wcf rest
3条回答
可以哭但决不认输i
2楼-- · 2019-04-18 01:58

You're asking a question about apples and oranges. REST is pattern used in creating web services. I'm not an expert on it, but you can find plenty of details on Wikipedia. WCF is a Microsoft technology for creating web services (primarily using SOAP, although it's so configurable that you can do REST on it as well - see ASP.Net WebAPI).

Pros for WCF:

  1. Very configurable - If you can imagine it, WCF can probably do it.
  2. Simple to use if you're sticking to the Microsoft stack. Visual Studio does 90% of the work for you.

Cons for WCF:

  1. Very configurable - It can be a bit of a pain to get it do exactly what you want sometimes, especially if you're new to it.
  2. There can be some problems communicating between different technology stacks. I've heard of Java services curling up and dying when pointed at a WCF service. As far as I've heard, this is a problem with the Java libraries, not WCF, but who knows for sure.

That's all that comes to mind right now, but hopefully that gives a you a decent impression on WCF.

查看更多
3楼-- · 2019-04-18 02:14

If you are absolutely sure that HTTP is the protocol you want to use and you want to embrace it as an "Application" protocol, not just a "Transport" protocol then something like ASP.NET Web API.

If you building a service for your servers in your datacenter to talk to each other then seriously consider WCF.

Whether to do REST is a completely different question. Will this service last for many years? Will it have many different clients? Will some of those clients be out of your control? If you answered yes, then it may be worth investigating what benefits the REST constraints can bring.

查看更多
兄弟一词,经得起流年.
4楼-- · 2019-04-18 02:18

Rest is a way of doing communication over the internet. It is a very basic process of picking addresses to serve as method locations and returning HTML standard data (javascript, css, html of course).

WCF is a .net library used to have two programs talk to each other using SOAP. Which consists of two very familiar programs trading class info.

Seeing as Rest is a process, and WCF is a class library, a better question might be "Rest vs Soap".

The bottom line is, if you need two apps to talk, you might want to use WCF. Even if the apps are not both written in .net. However if you need information to be accessed by web tech(usualy javascript access is done this way) you'll want to use Rest.

Just a quick side note though, WCF does Rest well too, so you realy can't go wrong there.

查看更多
登录 后发表回答