【问题标题】:Could not find default endpoint element error in Allscripts在 Allscripts 中找不到默认端点元素错误
【发布时间】:2012-06-18 18:28:57
【问题描述】:

我想连接到 WCF 服务。服务引用驻留在类库中。通过将 App.config 添加到单元测试项目中,我成功连接到 MSTEST 单元测试中的服务。我无法成功连接到应用程序中的服务。我找到了应用程序的配置文件。我可以编辑该文件,并确认我可以通过

访问我添加到配置中的密钥

<add key="testKey"

但是,当我尝试在应用程序中连接时收到错误消息

在 ServiceModel 客户端配置部分中找不到引用合同“ContractName.Service”的默认端点元素。这可能是因为在客户端元素中找不到与此合同匹配的端点元素。

我添加了部分

<system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IPinGenerator" 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://somewhere"
             binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IPinGenerator"
             contract="CompanyNamePinGenerator.IPinGenerator" name="BasicHttpBinding_IPinGenerator" />
        </client>
    </system.serviceModel>

然而,它并不能解决问题。我还尝试将命名空间添加到contract="" 和生成的代码属性

[System.ServiceModel.ServiceContractAttribute(ConfigurationName=

有什么办法可以解决这个问题吗?

【问题讨论】:

  • 右侧建议了几个相关主题,听起来它们可能会帮助您解决此问题。
  • 您确定您的端点合同属性中的 CompanyNamePinGenerator.IPinGenerator 完全正确吗?并且您提供的确切地址的服务器端端点是 basicHttpBinding?
  • 将整个 部分从您的 mstest app.config 复制到应用程序的配置文件中应该足以让事情正常运行(假设还没有 system.serviceModel 部分)。我'd 建议使用 SvcConfigEditor.exe (msdn.microsoft.com/en-us/library/ms732009(v=vs.100).aspx) 打开您的配置文件,以验证对绑定和配置的各种引用是否正确。

标签: c# .net wcf


【解决方案1】:

出现问题是因为您在客户端配置中没有任何端点与名称 ContractName.Service 匹配。

我所看到的是你只有一个端点与不同的合同CompanyNamePinGenerator.IPinGenerator

您位于代理文件中的服务类或接口引用了ContractName.Service,而配置中缺少。

您必须确保以下几点:

  1. 将生成的代理更新到最新版本
  2. 确保客户端配置包含服务所需的所有端点。

通常当我遇到此类问题时,我会打开 VS 命令提示符运行 svcutil.exe 并从生成的文件中复制代理代码和客户端配置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-09-26
    • 2013-05-13
    • 2013-01-23
    • 2012-04-25
    • 1970-01-01
    • 2013-06-27
    • 2023-03-12
    相关资源
    最近更新 更多