【发布时间】:2016-01-12 08:06:29
【问题描述】:
我通过使用 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 中定义的地址没有帮助?
【问题讨论】:
标签: c# web-services wcf