我对下面的配置文件有几个问题:
<system.serviceModel>
<bindings />
<services>
<service behaviorConfiguration="WcfReporting.Service1Behavior"
name="WcfReporting.Service1">
<endpoint address=""
binding="basicHttpBinding" bindingConfiguration=""
contract="WcfReporting.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:5050/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfReporting.Service1Behavior" >
<!-- To avoid disclosing metadata information, set the value below to false
and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment to
avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
为什么当我按 F5 重新启动服务时,服务以这个 URL http://localhost:2752/ 开始...为什么不是我在 baseAddresses 中指定的 5050。
如何添加另一个端点。我尝试使用端点 address="/Address2"binding="basicHttpBinding"contract="WcfReporting.IService1"/>
我应该如何才能访问该服务,而不仅仅是使用 http://localhost/VirtualDir/还有http://localhost/VirtualDir/address2或者它是如何工作的?
最佳答案
如果您从 Visual Studio 2005 或更高版本中在 Cassini 中托管,您可以使用 Project/Properties/Web/Use Visual Studio Development Server/Specific Port 指定端口。
默认情况下,端口将自动分配 - 这对 Web 服务不是很有帮助,因为您的客户可能希望使用固定的 URL。
在 IIS 或 Cassini 中托管时,您无需在配置文件中指定
关于c# - WCF,更改端点的 baseAdress,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/909332/