1

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

在 ServiceModel 客户端配置部分中找不到引用合同“WCFClient.IWCFClient”的默认终结点元素。

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

应用配置:

<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>    
4

2 回答 2

1

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

于 2011-05-01T04:03:57.627 回答
0

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

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

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

应该是这样的:

<%@ ServiceHost Language="C#" Debug="true" Service="WCFGraphicManagementTool.Services.WCFClient" CodeBehind="WCFClient.svc.cs" %>
于 2011-04-29T14:22:26.203 回答