简体   繁体   中英

Recognize WCF solution

I am new in Web Service Developement in .NET. Now I am analyzing a big solution of dozens of projects. There I have project that uses a web service and I want to know if it is a WCF Service or some other kind like Web API ...
In the past I used ASMX Web Services in .NET and you were able to recognize a ASMX web service via its file extension. But here I don't see any special extensions in the project. I have read that WCF Services have .svc files if they are hosted in IIS. But this project doesn't have a .svc file. So, what are the main characteristics which distinguish a WCF Service from other web services in .NET. The structure of the solution is as following:

-Solution  
  +-CreateDocWebServiceInterface  
  +-CreateDocWebService
  +-...

The CreateDocWebServiceInterface looks like that:

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);        
    }
}

And the CreateDocWebService looks like that:

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
        }
    }
}

It could be a Web Service with Web API , but as I know Web API web services consist of controllers which derive from the ApiController ?!(Is this correct and the unique characteristic of Web Api Web Services?) So is this a WCF Service? And what is the unique characteristic of a WCF service and of an Web API Web Service

It is a WCF Project because your Interface is surrounded by [ServiceContract] .

Another way if you want to know if it's a WCF Project or ASP.NET Web Service simply open your project's folders in File Explorer. You can hover over the icon with your mouse and a tooltip will display the project type as shown in the picture. Also, you can look under the Type column in File Explorer and it shows it there as well.

WCF Web Service Project: WCF 网络服务

ASP.NET Web Service Project: 在此处输入图片说明

Also to note, if your project has a Resources.Designer.cs or Settings.Designer.cs in its Properties folder it's likely a WinForms application.

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