C# 如何在 IIS 上部署 WCF 服务应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18779181/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 13:10:38  来源:igfitidea点击:

How to deploy WCF service application on IIS

c#wcf

提问by TRS

I am new to WCF services.I have made a service application and put the application code directory under default website of IIS.It connects with my client very well.

我是WCF服务的新手。我做了一个服务应用程序并将应用程序代码目录放在IIS的默认网站下。它和我的客户端很好地连接。

I want to know how to deploy my service on IIS as binary,as of now my whole source code is visible on server

我想知道如何在 IIS 上以二进制形式部署我的服务,到目前为止,我的整个源代码在服务器上都是可见的

采纳答案by Damith

it is called WCF Service Publishing

它被称为 WCF 服务发布

check the MSDN Documentation

检查MSDN 文档

after publishing you have only assembly files, Web.config file, and .svcfile in the server

发布后,服务器中只有程序集文件、Web.config 文件和 .svc文件

回答by Neel

Courtesy : http://social.msdn.microsoft.com/Forums/vstudio/en-US/5c0a54e7-af4b-422f-bf5d-5f2f93d46ed0/deploying-wcf-service-to-iis-75


#i), You need create a new application on IIS for your wcf application.
#ii), To configure the service use specific port as nettcp endpoint port on IIS, you need edit "Bindings..." section on "Default Web Site", change the "net.tcp" type binding to use your desired port, (for example, to use 22550, set Binding information to "22550:*")
#iii), You can just set nettcp endpoint address with relative uri. IIS will transform the address to absolute url automaticly.
#iv-v), To enable nettcp protocol on IIS application, you could open "Advanced Settings" on specific IIS application, edit "Enabled Protocols" pair, add "net.tcp".
#vi), Yes, add a MEX endpoint, and add serviceMetadata to ServiceBehavior. See this configuration sample:

  <system.serviceModel>
    <services>
      <service name="nettcp_wcf.Service1" behaviorConfiguration="nettcp_wcf.Service1Behavior">
        <!--use relative url-->
        <endpoint address="nettcp" binding="netTcpBinding" contract="nettcp_wcf.IService1">
        </endpoint>
        <!--add mex endpoint-->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="nettcp_wcf.Service1Behavior">
          <!--enable metadata service-->
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

Here is an article about configure iis to host nettcp wcf, please have a look
http://blogs.msdn.com/swiss_dpe_team/archive/2008/02/08/iis-7-support-for-non-http-protocols.aspx

回答by Akon

1 : Publish your wcf service application from VS and give a publish path.

1:从VS发布您的wcf服务应用程序并给出发布路径。

2 : Create a virtual directory in IIS which will point to the publish directory

2:在IIS中创建一个指向发布目录的虚拟目录

3 : Set the virtual directory default page to .SVC file of your application.

3:将虚拟目录默认页面设置为应用程序的.SVC文件。

Then try to browse it ..I hope you will be able to make it now..

然后尝试浏览它..我希望你现在能够做到..