Could not find default endpoint element that refer

2020-08-23 08:36发布

I tried creating a simple WCF application, I haven't changed any of the existing default configurations. I have tried consuming the service using the TestClient generated by using svcutil.exe. It is showing an error message "Could not find default endpoint element that references contract 'IAuthenticationService' 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 contract could be found in the client element." I tried putting endpoint to localhost:port number/test.svc but its showing the same error.

this code is being shown after i execute the web test client. I couldnt trace out the error after searching for long hours over internet

Here is my testClients clientdll.config

<configuration>
    <system.serviceModel>
        <bindings>
            <wsHttpBinding>
                <binding name="wsHttpBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01: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 ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="Message">
                        <transport clientCredentialType="Windows" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="Windows" negotiateServiceCredential="true"
                            algorithmSuite="Default" establishSecurityContext="true" />
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:2490/AuthenticationService.svc"
                binding="wsHttpBinding" bindingConfiguration="wsHttpBinding"
                contract="IAuthenicationService" name="wsHttpBinding">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>

2条回答
做自己的国王
2楼-- · 2020-08-23 09:22

try removing the end points there and use

 compilation debug=true 

in web.config. then after trying

svcutil.exe http://your_wsdl

you will generate an output.config. Try putting in servicemodel nodes replacing your client website or application with the output.config service model. It will work

查看更多
等我变得足够好
3楼-- · 2020-08-23 09:36

This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

The name of the binding or contract will be wrong. You confing needs to look something like

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="Binding1" />
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://foo" binding="basicHttpBinding" bindingConfiguration="Binding1" contract="Service.MyService" name="MyService" />
    </client>
  </system.serviceModel>

Make sure the bindingConfiguration matches the binding name. In the above example Binding1

查看更多
登录 后发表回答