未找到 WCF 默认端点

发布于 2024-11-04 06:15:47 字数 2658 浏览 5 评论 0原文

我正在创建一个 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>    

I am creating a WCF Service. It is my first one. I am receiving the error:

Could not find default endpoint
element that references contract
'WCFClient.IWCFClient' in the
ServiceModel client configuration
section.

I have tried switching around endpoint names and such, and deleting/recreating the service reference. I can't seem to figure out what the problem is.

Application Config:

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

Service Config:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

左岸枫 2024-11-11 06:15:47

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

I just figured it out. I needed to add it to the project's web.config also. It was in the service's, but not the project.

无语# 2024-11-11 06:15:47

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

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

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

应该是这样的:

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

This is normally due to a mismatch between the service name/namespace that is specified in the config file and either the contract name on the source code or markup of the service file. Normally happens after you create a new service via Visual Studio and then rename the service/namespace.

Right-click on the .svc file in the solution explorer and select 'View Markup'

Check if the 'Service' attribute value is correct. Check if both namespace and name match the ones you have assigned.

Should be something like this:

<%@ ServiceHost Language="C#" Debug="true" Service="WCFGraphicManagementTool.Services.WCFClient" CodeBehind="WCFClient.svc.cs" %>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文