如何在特定端口上运行 WCF 服务 [英] How to run WCF service on a specific port
问题描述
我有一个在 IIS 上运行的 .Net 4.0 WCF 服务.我没有指定端口,所以假设它在端口 80 上运行.我需要在已经使用端口 80 的服务器上安装我的服务,并且网络人员要求我更改我的服务以在端口 443 上运行.如何做我这样做?我猜它可以在 app.config 中配置,但我找不到介绍如何配置的文章.
I have a .Net 4.0 WCF service running on IIS. I have not specified a port so assume it is running on port 80. I need to install my service on a server where port 80 is already being used and the network guy had asked me to change my service to run on port 443. How do I do this? I'm guessing it can be configured in app.config but I can't find an article that shows me how.
这是我当前的 app.config:
Here is my current app.config:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
推荐答案
我假设您在 net.tcp 协议上运行您的服务.
I am assuming you are running your services on net.tcp protocols.
1) 编辑绑定(右键单击Default Web Site
选择Edit Bindings
1) Edit your bindings (right click Default Web Site
select Edit Bindings
2) 服务端
<service name="YouServiceNameSpace.YourService">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="YourBinding" contract="YourContract" />
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange" />
</service>
3) 客户端
<endpoint address="net.tcp://YourHost:443/YourServiceDirecotry/YourService.svc"
behaviorConfiguration="YourBehavior" binding="netTcpBinding"
bindingConfiguration="YourTcpBinding" contract="YourContract"
name="YourContractName" />
这篇关于如何在特定端口上运行 WCF 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!