How do I generate the .svc file?

后端 未结 2 1165
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-03 22:20

I created my first WCF service and tested it on my computer, and it works.

The files present are an interface, an implementation of that interface, and an app.config

2条回答
  •  半阙折子戏
    2021-01-03 22:41

    IIS Hosted .svc file consists of the @ServiceHost directive and attribute, Service.

    <% @ServiceHost Service="MyNamespace.MyServiceImplementationTypeName" %>
    

    The value of the Service attribute is the CLR type name of your service implementation. Using this directive is basically equivalent to creating a service host using the following code in your self hosting console program.

    new ServiceHost(typeof(MyNamespace.MyServiceImplementationTypeName ));
    

    And If your self hosted application are using WCF configuration like 'endpoint', 'binding',etc in the app.config, you can also put that in web.config. IIS-hosted service use the same configuration elements and syntax as WCF services hosted outside of IIS. (Except something like you can't control base/endpoint address in IIS-hosted service.) And put your precompiled .dll file to application’s \bin directory of your IIS Site.

    And the address of IIS-hosted service will be the address of .svc file. (http://localhost/Application1/MyService.svc).

    Please check the below msdn - Deploying an IIS-Hosted WCF Service.

    http://msdn.microsoft.com/en-us/library/aa751792.aspx

提交回复
热议问题