服务抛出EndPointNotFoundException错误

时间:2014-02-22 10:05:31

标签: wcf c#-4.0 c#-3.0 wcf-data-services

我已经尝试了所有的事情,毕竟我在error.svclog文件中发现客户端能够点击服务而服务投掷EndPointNotFoundException。 我还看过服务器日志以检查状态,它显示在下面。

#Software: Microsoft Internet Information Services 7.5
#Version: 1.0
#Date: 2014-02-22 09:22:35
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken
2014-02-22 09:22:35 192.168.10.9 GET /HostWCF/Service.svc - 80 - 192.168.10.10 Mozilla/5.0+(Windows+NT+6.2;+WOW64;+rv:27.0)+Gecko/20100101+Firefox/27.0 200 0 0 60360
2014-02-22 09:22:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 52
2014-02-22 09:23:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 52
2014-02-22 09:30:24 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 1994
2014-02-22 09:30:34 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 73
2014-02-22 09:30:44 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 52
2014-02-22 09:30:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 54
2014-02-22 09:31:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 69
2014-02-22 09:31:14 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 67
2014-02-22 09:31:24 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 62
2014-02-22 09:31:34 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 67
2014-02-22 09:31:44 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 50
2014-02-22 09:31:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 59
2014-02-22 09:32:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 50
2014-02-22 09:32:14 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 54
2014-02-22 09:32:24 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 51
2014-02-22 09:32:34 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 53
2014-02-22 09:32:44 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 82
2014-02-22 09:32:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 79
2014-02-22 09:33:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 60
2014-02-22 09:33:14 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 52
2014-02-22 09:33:24 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 76
2014-02-22 09:33:34 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 49
2014-02-22 09:33:44 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 52
2014-02-22 09:33:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 57
2014-02-22 09:34:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 72
2014-02-22 09:34:14 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 51
2014-02-22 09:34:24 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 60
2014-02-22 09:34:34 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 62
2014-02-22 09:34:44 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 55
2014-02-22 09:34:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 95
2014-02-22 09:35:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 55
2014-02-22 09:35:14 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 54
2014-02-22 09:35:24 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 58
2014-02-22 09:35:34 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 57
2014-02-22 09:35:44 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 53
2014-02-22 09:35:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 67
2014-02-22 09:36:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 54
2014-02-22 09:36:14 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 60
2014-02-22 09:36:24 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 65
2014-02-22 09:36:34 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 59
2014-02-22 09:36:44 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 58
2014-02-22 09:36:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 56
2014-02-22 09:37:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 51
2014-02-22 09:37:14 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 70
2014-02-22 09:37:24 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 61
2014-02-22 09:37:34 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 61
2014-02-22 09:37:44 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 65
2014-02-22 09:37:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 56
2014-02-22 09:38:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 69
2014-02-22 09:38:14 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 55
2014-02-22 09:38:24 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 51
2014-02-22 09:38:34 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 54
2014-02-22 09:38:44 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 51
2014-02-22 09:38:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 57
2014-02-22 09:39:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 62
2014-02-22 09:39:14 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 55
2014-02-22 09:39:24 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 56
2014-02-22 09:39:34 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 55
2014-02-22 09:39:44 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 56
2014-02-22 09:39:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 56
2014-02-22 09:40:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 56
2014-02-22 09:40:14 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 67

我的服务web.config文件

<?xml version="1.0"?>
 <configuration>
<configSections>
</configSections>
<system.diagnostics>
<sources>
  <source name="System.ServiceModel"
          switchValue="Information, ActivityTracing"
          propagateActivity="true" >
    <listeners>
      <add name="xml"/>
    </listeners>
  </source>
  <source name="System.ServiceModel.MessageLogging">
    <listeners>
      <add name="xml"/>
    </listeners>
  </source>
  <source name="myUserTraceSource"
          switchValue="Information, ActivityTracing">
    <listeners>
      <add name="xml"/>
    </listeners>
  </source>
</sources>
<sharedListeners>
  <add name="xml"
       type="System.Diagnostics.XmlWriterTraceListener"
       initializeData="Error.svclog" />
  </sharedListeners>
</system.diagnostics>
<connectionStrings>
  <add name="Connection" connectionString="Server=.\SQLSERVER;  Database=databaseDB;Trusted_Connection=True;"/>

</connectionStrings>
 <system.web>
  <!--<webServices>
  <protocols>
    <add name ="HttpGet"/>
    <add name="HttpPost"/>
    <add name="HttpPostLocalhost"/>
    <add name="HttpSoap"/>

  </protocols>
  </webServices>-->
  <compilation debug="true" targetFramework="4.0" />
 </system.web>
 <system.webServer>
  <!--<defaultDocument>
  <files>
    <add value="Service.svc"/>
  </files>
  </defaultDocument>-->
  </system.webServer>
  <system.serviceModel>
  <bindings>
  <wsDualHttpBinding>
    <binding name="DualNewBinding"> 
      <!--receiveTimeout="01:10:00" sendTimeout="01:10:00"  closeTimeout="02:00:00" openTimeout ="01:40:00" useDefaultWebProxy ="True" >-->
      <security mode="None">
        <message clientCredentialType ="None"/>
      </security>
    </binding>
  </wsDualHttpBinding>
  </bindings>
  <services>
  <service 
    behaviorConfiguration="HostWCF.ServiceBehavior" name="HostWCF.Service" >
    <endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="DualNewBinding" contract="HostWCF.IService">
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost/HostWCF"/>
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="HostWCF.ServiceBehavior">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true" />
      <serviceCredentials >
        <windowsAuthentication allowAnonymousLogons ="true"/>
      </serviceCredentials>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>

</configuration>

我的客户端app.congif文件

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
 <add name="connection" connectionString="Server=.\SQLEXPRESS;Database=TISDB;Trusted_Connection=True;"/>
 </connectionStrings>
  <system.serviceModel>
    <bindings>
        <wsDualHttpBinding>
          <binding name="WSDualHttpBinding_IService"  openTimeout="00:10:00" closeTimeout ="00:20:00" bypassProxyOnLocal ="false" receiveTimeout ="00:08:00" sendTimeout ="00:10:00" useDefaultWebProxy ="true">
            <security mode="None">
              <message clientCredentialType ="None"/>
            </security>
          </binding>
        </wsDualHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://192.168.10.9/hostwcf/service.svc" binding="wsDualHttpBinding"
            bindingConfiguration="WSDualHttpBinding_IService" contract="ServiceReference.IService"
            name="WSDualHttpBinding_IService">
            <identity>
                <dns value="192.168.10.9" />
            </identity>
        </endpoint>
    </client>
   </system.serviceModel>
 </configuration>

1 个答案:

答案 0 :(得分:0)

WCF默认设计为安全的。而且这种安全性意味着不仅服务器需要知道谁在调用它,而且客户端需要确保与之通信的服务器确实是它所期望的服务器。

用于此检查的是服务标识。对于客户端信任服务器,该服务器的标识需要与客户端的标识定义匹配。

在您的配置中,服务定义身份如下:

  <identity>
    <dns value="localhost"/>
  </identity>

和客户端如下:

    <identity>
        <dns value="192.168.10.9" />
    </identity>

这些身份不匹配,因此客户端没有与正确的端点对话==&gt;终点未找到异常。

<强>解决方案: 如果不需要进行安全检查,请使身份匹配,或完全删除身份。