【问题标题】:C# - Could not find endpoint element with name 'XXXXXX' and contractC# - 找不到名称为“XXXXXX”和合同的端点元素
【发布时间】:2016-04-07 07:39:55
【问题描述】:

我正在尝试在 VS2010 中运行一个在本地调用 2 个 Web 服务的项目,我的 app.config 文件设置如下,并将 2 个 Web 服务添加到服务引用中,但是当我收到以下错误尝试进入其中一个 Web 服务中的代码。

只是想知道你能帮忙吗,我知道这个错误可能以前在这里出现过,但给出的解决方案似乎无法解决我的问题。

错误信息:

在 ServiceModel 客户端配置部分找不到名为“XXXXXX”和合同“IcxnService.IIcxnService”的端点元素。这可能是因为找不到您的应用程序的配置文件,或者因为在客户端元素中找不到与此名称匹配的端点元素。

App.Config文件:

<system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IIcxnService" 
                closeTimeout="00:10:00" openTimeout="00:30:00" 
                receiveTimeout="00:30:00" sendTimeout="00:30:00"
                bypassProxyOnLocal="false" transactionFlow="false" 
                hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
                messageEncoding="Text" textEncoding="utf-8" 
                useDefaultWebProxy="true" allowCookies="false">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" 
                       maxArrayLength="16384" maxBytesPerRead="4096" 
                       maxNameTableCharCount="16384" />
                <reliableSession ordered="true" 
                       inactivityTimeout="00:10:00" enabled="false" />
                <security mode="Message">
                    <transport clientCredentialType="Windows"  
                               proxyCredentialType="None" realm="" />
                    <message clientCredentialType="Windows" 
                             negotiateServiceCredential="true"
                             algorithmSuite="Default" />
                </security>
            </binding>
            <binding name="WSHttpBinding_ICznzrzctZzzzsService" 
                 closeTimeout="00:10:00" openTimeout="00:10:00" 
                 receiveTimeout="00:10:00" sendTimeout="00:10:00"
                 bypassProxyOnLocal="false" transactionFlow="false" 
                 hostNameComparisonMode="StrongWildcard"
                 maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
                 messageEncoding="Text" textEncoding="utf-8" 
                 useDefaultWebProxy="true" allowCookies="false">
                 <readerQuotas maxDepth="32" maxStringContentLength="8192" 
                        maxArrayLength="16384" maxBytesPerRead="4096" 
                        maxNameTableCharCount="16384" />
                 <reliableSession enabled="false"
                        ordered="true" inactivityTimeout="00:10:00" />
                 <security mode="Message">
                     <transport clientCredentialType="Windows" 
                                proxyCredentialType="None" realm="" />
                     <message clientCredentialType="Windows" 
                              negotiateServiceCredential="true"
                              algorithmSuite="Default" />
                 </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint name="WSHttpBinding_ICznzrzctZzzzsService" 
            address="http://localhost:1600/ContractNotes.svc" 
            binding="wsHttpBinding"
            bindingConfiguration="WSHttpBinding_ICznzrzctZzzzsService" 
            contract="ContractNotes.ICznzrzctZzzzsService" />
        <endpoint name="WSHttpBinding_IIcxnService"
            address="http://localhost:1000/IcxnService.svc" 
            binding="wsHttpBinding"
            bindingConfiguration="WSHttpBinding_IIcxnService" 
            contract="IcxnService.IIcxnService">
            <identity>
                <userPrincipalName value="john@xxxxxxx.COM" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

【问题讨论】:

    标签: c# wcf wcf-binding


    【解决方案1】:

    在你的浏览器中插入这个字符串http://localhost:1600/ContractNotes.svc,如果你没有得到任何东西,你需要运行你的本地web服务(点击web应用,设置为启动项目,并调试它们(点击ctrl+F5)) ,然后将运行这些服务引用并运行它们的项目设置为启动项目。

    编辑 1: 是否使用关键字(ServiceContract 和 OperationContract)标记了您的服务?像这样:

    [ServiceContract]
    public interface IIcxnService
    {
        [OperationContract]
        void NameMethod(some parameters);
    }
    

    【讨论】:

    • 我已将 2 个本地 Web 服务添加到我的所有项目中,即有主项目和我从主项目引用的 2 个 Web 服务项目。我已将启动项目设置为主项目,并将 2 个 Web 服务作为依赖项,并确保它们正在运行,但我仍然遇到上述相同的端点错误问题。能否提供更多帮助。
    • @John 您是否使用关键字(ServiceContract、OperationContract)标记了您的 Web 服务?
    • 是的,也有这个设置:[ServiceContract] public interface IIcxnService { [OperationContract]
    • 嗨,这个问题还没有解决,只是想知道有人可以帮忙吗? Tks
    【解决方案2】:

    确保您要查找的配置名称是WSHttpBinding_IIcxnService。 如果您没有明确指定端点配置名称,您可以检查 Reference.cs 文件中 ServiceContractAttribute 上的 ConfigurationName 属性。

    【讨论】:

    • ConfigurationName 如下[System.ServiceModel.ServiceContractAttribute(ConfigurationName="IcxnService.IIcxnService")]....这个需要改成WSHttpBinding_IIcxnService吗?我正在使用的另一个 Web 服务的设置与此类似
    • 您可以尝试在配置文件中将
    • 嗨,这个问题还没有解决,只是想知道有人可以帮忙吗? Tks
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-11
    • 2011-03-12
    • 1970-01-01
    • 1970-01-01
    • 2017-01-04
    • 2010-11-28
    相关资源
    最近更新 更多