找不到WCF默认端点

时间:2011-04-29 13:17:04

标签: wcf configuration-files wcf-binding wcf-endpoint

我正在创建一个WCF服务。这是我的第一个。我收到错误:

  

无法找到默认端点   引用合同的元素   'WCFClient.IWCFClient'中   ServiceModel客户端配置   部分。

我尝试切换端点名称等,并删除/重新创建服务引用。我似乎无法弄清问题是什么。

应用程序配置:

<bindings>
    <basicHttpBinding>
         <binding name="BasicHttpBinding_IWCFClient" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
    </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:4295/Services/WCFClient.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWCFClient"
            contract="WCFClient.IWCFClient" name="BasicHttpBinding_IWCFClient" />
    </client>

服务配置:

 <services>
  <service behaviorConfiguration="WCFGraphicManagementTool.Services.WCFClientBehavior"
    name="WCFGraphicManagementTool.Services.WCFClient">
      <endpoint address="" name="BasicHttpBinding_IWCFClient" binding="basicHttpBinding" contract="WCFGraphicManagementTool.Contracts.IWCFClient">
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="WCFGraphicManagementTool.Services.WCFClientBehavior">
        <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        <serviceThrottling maxConcurrentCalls="120" maxConcurrentSessions="120" maxConcurrentInstances="120" />
        <serviceMetadata httpGetEnabled="True" />
        <serviceDebug includeExceptionDetailInFaults="True" />
    </behavior>
  </serviceBehaviors>
</behaviors>    

2 个答案:

答案 0 :(得分:1)

我只是想通了。我还需要将它添加到项目的web.config中。这是服务的,但不是项目。

答案 1 :(得分:0)

这通常是由于配置文件中指定的服务名称/命名空间与源代码上的合同名称或服务文件的标记不匹配。通常在通过Visual Studio创建新服务然后重命名服务/命名空间后发生。

右键单击解决方案资源管理器中的.svc文件,然后选择“查看标记”

检查“服务”属性值是否正确。检查名称空间和名称是否与您指定的名称相匹配。

应该是这样的:

<%@ ServiceHost Language="C#" Debug="true" Service="WCFGraphicManagementTool.Services.WCFClient" CodeBehind="WCFClient.svc.cs" %>