【发布时间】:2018-06-03 05:38:11
【问题描述】:
我是 .NET 中 Web 服务开发的新手。现在我正在分析几十个项目的大解决方案。我有一个使用 Web 服务的项目,我想知道它是 WCF 服务 还是其他类似 Web API...
过去我在 .NET 中使用过 ASMX Web 服务,您可以通过其文件扩展名识别 ASMX Web 服务。但是在这里我没有看到项目中有任何特殊的扩展。我读过 WCF 服务有 .svc 文件,如果它们托管在 IIS 中。但是这个项目没有 .svc 文件。那么,将 WCF 服务与 .NET 中的其他 Web 服务区分开来的主要特征是什么。
解决方案的结构如下:
-Solution
+-CreateDocWebServiceInterface
+-CreateDocWebService
+-...
CreateDocWebServiceInterface 看起来像这样:
namespace CreateDocWebServiceInterface
{
/// <summary>
/// </summary>
[ServiceContract(Name = "ICreateDocWebService", Namespace = "http://www.standardlife.de/CreateDocWebService")]
[RequiredParametersBehavior]
[ServiceKnownType(typeof(Bookmark))]
[ServiceKnownType(typeof(List<Bookmark>))]
public interface ICreateDocWebService
{
[OperationContract]
byte[] CreateDoc(OutputFormat OutputFormat, bool DuplexPrinting, List<Document> Documents);
}
}
CreateDocWebService 看起来像这样:
namespace CreateDocWebService
{
// single threaded, but each request is handled concurrent !
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single, Namespace = "http://www.blablabla.de/CreateDocWebService")]
public class CreateDocWebService : ICreateDocWebService
{
public byte[] CreateDoc(OutputFormat outputFormat, bool duplexPrinting, List<Document> documents)
{
bla bla bla
}
}
}
它可能是一个带有 Web API 的 Web 服务,但据我所知,Web API 网络服务由派生自 ApiController 的 控制器 组成?!(这是Web Api Web Services 的正确性和独特性?)
那么这是 WCF 服务吗? WCF 服务和 Web API Web 服务的独特之处是什么
【问题讨论】:
-
嗯,它看起来像一个 WCF ......不是一个 WebAPI ......因为它有一个接口可以与其他想要使用这个 WS 的人签订合同 .. 它使用一个命名空间(通常是命名空间对于 XML ..so 对于 SOAP .so 对于 WCF)
-
是WCF服务,查看[识别WCF解决方案][1][1]的详细建议:social.msdn.microsoft.com/Forums/vstudio/en-US/…
标签: c# web-services wcf asp.net-web-api asmx