簡體   English   中英

C#-找不到名稱為“ XXXXXX”和合同的終結點元素

[英]C# - Could not find endpoint element with name 'XXXXXX' and contract

我正在嘗試在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>

將此字符串插入瀏覽器http:// localhost:1600 / ContractNotes.svc中 ,如果您什么都沒有得到,則需要運行本地Web服務(單擊Web應用程序,設置為StartUp Project,然后調試它們(單擊ctrl + F5)),然后將其設置為啟動項目,在其中運行這些服務引用並運行它們的項目。

編輯1:是否用關鍵字(ServiceContract和OperationContract)標記了您的服務? 像這樣:

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

確保要查找的配置名稱是WSHttpBinding_IIcxnService 如果未明確指定端點配置名稱,則可以檢查Reference.cs文件上ServiceContractAttributeConfigurationName屬性。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM