简体   繁体   中英

What are some scenarios in which you need ASP.net Web API to consume a WCF Service?

我知道 ASP.net Web 服务仅支持 HTTP 协议,而使用 WCF,您有更多选项,例如 TCP 和命名管道等。您能想到任何可能必须通过 ASP.net Web API 使用 WCF 服务的场景吗?

Following would be one of them use case where you want to call wcf service from web API.

If you already have a wcf service running and available which is doing some complex operations and you do not want it to be available directly to your consumers, you can create a web API and call the wcf service to perform the complex tasks and let the consumers to use the web API. In web API you can put extra logic of validation and authorization of the incoming requests.

Wcf being an older technology it would be better to write something new and eventually replace wcf rather than maintaining it.

Also If the current wcf is setup is not available via http protocol then not all the clients can communicate with it. Web API has that edge over wcf service.

How web API would connect to wcf service? This depends on lot of factors such as network, deployment strategy, security etc. But following would be one of the examples.

If the wcf service is available on tcp and web API and wcf are running on the same network, then web API can call wcf.

There may be a different answer to this question based on what exact problem you are trying to solve.

My answer is based on what information you have provided and the experience I gained by solving similar issue in real life.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM