我在IIS上运行.Net 4.0 WCF服务。我没有指定端口,所以假设它在端口80上运行。我需要在已经使用端口80的服务器上安装我的服务,并且网络人员要求我将服务更改为在端口443上运行。如何操作我这样做?我猜它可以在app.config中配置,但我找不到一篇文章告诉我如何。
这是我当前的app.config:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
答案 0 :(得分:6)
我假设你在net.tcp协议上运行你的服务。
1)修改您的绑定(右键点击Default Web Site
选择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" />
答案 1 :(得分:5)
我们可以使用WCF项目的.csproj文件(如果使用VS)。在相应的文件中更改此xml标记的值:
在端口号60000处运行服务,
<DevelopmentServerPort>60000</DevelopmentServerPort>
答案 2 :(得分:1)
通常,您应该拥有一个至少包含一个服务节点的服务节点,每个节点都有端点,您可以在其中指定端口。有关详情,请参阅:http://msdn.microsoft.com/en-us/library/ms733932.aspx
例如:
<services>
<service name="MyNamespace.myServiceType">
<endpoint
address="net.tcp://0.0.0.0:8000" binding="basicHttpBinding"
bindingConfiguration="myBindingConfiguration1"
contract="MyContract" />
</service>
</services>
答案 3 :(得分:0)
在端点的地址中指定端口。有关详细信息,请参阅this文章中的“在代码中定义端点地址”部分。