我通过使用VS2013创建wcf应用程序项目来创建wcf服务。 我的服务合同是IWCFService,我有一个名为WCFService的IWCFService实现
[ServiceContract]
public interface IWCFService
{
[OperationContract]
void DoWork();
}
public class WCFService : IWCFService
{
public void DoWork()
{
//do something
}
}
我的服务配置如下:
<system.serviceModel>
<services>
<service name="WcfService2.WCFService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration=""
contract="WcfService2.IWCFService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:5831/WCFService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
当我启动我的应用程序时,我可以通过URL http://localhost:5831/WCFService.svc添加服务引用,但是当我尝试通过http://localhost:5831/WCFService添加服务引用时,发现了注释。为什么我在web.config中定义的地址不能帮助
答案 0 :(得分:0)
<baseAddresses>
仅在您的服务托管在自托管环境中时才有效。
表示baseAddress元素的集合,它们是base 自托管环境中的服务主机的地址。如果是基地 如果存在地址,则可以使用地址配置端点 相对于基地址。