简体   繁体   中英

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

I am trying to run a project in VS2010 that calls 2 web services locally, I have my app.config file set up as below and have added the 2 web services to the Services References but I am getting the following error when I try and step into code in one of the web services.

Just wondering could you help, I know that this error may have appeared here before but the solutions given don't seem to resolve my issue.

Error message:

Could not find endpoint element with name 'XXXXXX' and contract 'IcxnService.IIcxnService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.

App.Config file:

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

Insert this string in your browser http://localhost:1600/ContractNotes.svc , if you don not get anything, you need to run your local web services(click on the web application, Set as StartUp Project, and debug them(click ctrl+F5)), after that Set as StartUp Project your project where you run these service refenerces and run them.

EDIT 1: Did mark up your services with key words(ServiceContract and OperationContract) ? like this:

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

Make sure that the configuration name you are looking for is WSHttpBinding_IIcxnService . If you are not explicitly specifying an endpoint configuration name, you can check the ConfigurationName property on ServiceContractAttribute on Reference.cs file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM