Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net WCF中的EndpointNotFoundException_.net_Asp.net Mvc_Wcf_Exception_Wcf Binding - Fatal编程技术网

.net WCF中的EndpointNotFoundException

.net WCF中的EndpointNotFoundException,.net,asp.net-mvc,wcf,exception,wcf-binding,.net,Asp.net Mvc,Wcf,Exception,Wcf Binding,我盯着web.config看了很久了,你们能看一下吗 运行service.Endpoint.Address.ToString()会得到预期的结果:http://localhost:2867/Service1.svc和http://localhost:2867/Service1.svc?wsdl提供了我需要的所有方法 如果您需要更多信息/代码,我很乐意添加 谢谢你看 错误 在http://localhost:2867/Service1.svc可以接受该消息。这通常是由不正确的地址或SOAP操作引

我盯着web.config看了很久了,你们能看一下吗

运行
service.Endpoint.Address.ToString()
会得到预期的结果:
http://localhost:2867/Service1.svc
http://localhost:2867/Service1.svc?wsdl
提供了我需要的所有方法

如果您需要更多信息/代码,我很乐意添加

谢谢你看


错误

http://localhost:2867/Service1.svc
可以接受该消息。这通常是由不正确的地址或SOAP操作引起的

客户端配置

<?xml version="1.0" encoding="utf-8"?>    
<configuration>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>    
  <system.web>        
    <httpRuntime targetFramework="4.5" />        
    <compilation debug="true" targetFramework="4.5" />    
    <pages>
      <namespaces>
       ...
      </namespaces>
    </pages>
  </system.web>    
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />         
  <handlers>
  ...    
  </handlers>
  </system.webServer>    
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IService1" />
        <binding name="Identity Management WebserviceSoap">
          <security mode="Transport" />
        </binding>
        <binding name="Identity Management WebserviceSoap1" />
      </basicHttpBinding>
    </bindings>    
    <client>
      <endpoint address="http://localhost:2867/Service1.svc" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReferenceCDP.IService1"
        name="BasicHttpBinding_IService1" />
    </client>
  </system.serviceModel>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>

  <system.web>

    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>

    <httpRuntime targetFramework="4.0" />
    <authorization>
      <allow users="?" />
    </authorization>

  </system.web>

  <system.serviceModel>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

    <client>
      <!--<endpoint address="https://services.howest.be/Howest.Identity.Web.Service/v1.1/facade.asmx" binding="basicHttpBinding" bindingConfiguration="Identity Management WebserviceSoap" contract="BamaFlex.IdentityManagementWebserviceSoap" name="Identity Management WebserviceSoap" />-->
    </client>

    <services>
      <service name="CollectiveDistributedPolling.Service1" behaviorConfiguration="ServiceBehavior">
        <endpoint address="" binding="webHttpBinding" behaviorConfiguration="json" contract="CollectiveDistributedPolling.IService1"></endpoint>        
      </service>
    </services>

    <behaviors>
      <endpointBehaviors>
        <behavior name="json">
          <enableWebScript />
        </behavior>
      </endpointBehaviors>


      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <bindings>
      <basicHttpBinding>
        <binding name="Identity Management WebserviceSoap">
          <security mode="Transport" />
        </binding>
      </basicHttpBinding>

      <webHttpBinding>
        <binding>
          <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="64" maxNameTableCharCount="2147483647" />
          <security mode="None" />
        </binding>
      </webHttpBinding>
    </bindings>

  </system.serviceModel>

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />

    <!--Toegevoegd omdat de browser anders nx ontvangt (GET)-->
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
      </customHeaders>
    </httpProtocol>

    <directoryBrowse enabled="true" />

  </system.webServer>

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>

</configuration>

...
...    
服务器配置

<?xml version="1.0" encoding="utf-8"?>    
<configuration>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>    
  <system.web>        
    <httpRuntime targetFramework="4.5" />        
    <compilation debug="true" targetFramework="4.5" />    
    <pages>
      <namespaces>
       ...
      </namespaces>
    </pages>
  </system.web>    
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />         
  <handlers>
  ...    
  </handlers>
  </system.webServer>    
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IService1" />
        <binding name="Identity Management WebserviceSoap">
          <security mode="Transport" />
        </binding>
        <binding name="Identity Management WebserviceSoap1" />
      </basicHttpBinding>
    </bindings>    
    <client>
      <endpoint address="http://localhost:2867/Service1.svc" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReferenceCDP.IService1"
        name="BasicHttpBinding_IService1" />
    </client>
  </system.serviceModel>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>

  <system.web>

    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>

    <httpRuntime targetFramework="4.0" />
    <authorization>
      <allow users="?" />
    </authorization>

  </system.web>

  <system.serviceModel>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

    <client>
      <!--<endpoint address="https://services.howest.be/Howest.Identity.Web.Service/v1.1/facade.asmx" binding="basicHttpBinding" bindingConfiguration="Identity Management WebserviceSoap" contract="BamaFlex.IdentityManagementWebserviceSoap" name="Identity Management WebserviceSoap" />-->
    </client>

    <services>
      <service name="CollectiveDistributedPolling.Service1" behaviorConfiguration="ServiceBehavior">
        <endpoint address="" binding="webHttpBinding" behaviorConfiguration="json" contract="CollectiveDistributedPolling.IService1"></endpoint>        
      </service>
    </services>

    <behaviors>
      <endpointBehaviors>
        <behavior name="json">
          <enableWebScript />
        </behavior>
      </endpointBehaviors>


      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <bindings>
      <basicHttpBinding>
        <binding name="Identity Management WebserviceSoap">
          <security mode="Transport" />
        </binding>
      </basicHttpBinding>

      <webHttpBinding>
        <binding>
          <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="64" maxNameTableCharCount="2147483647" />
          <security mode="None" />
        </binding>
      </webHttpBinding>
    </bindings>

  </system.serviceModel>

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />

    <!--Toegevoegd omdat de browser anders nx ontvangt (GET)-->
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
      </customHeaders>
    </httpProtocol>

    <directoryBrowse enabled="true" />

  </system.webServer>

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>

</configuration>

编辑

<services>
      <service name="CollectiveDistributedPolling.Service1" behaviorConfiguration="ServiceBehavior">
        <endpoint address="http://localhost:2867/Service1.svc" binding="webHttpBinding" behaviorConfiguration="json" contract="CollectiveDistributedPolling.IService1"></endpoint>        
      </service>
    </services>

如果服务器端配置地址属性仅包含空字符串,请在其中指定地址:
http://localhost:2867/Service1.svc


(请不要为此使用development server。)

如果服务器端配置地址属性仅包含空字符串,请在其中指定地址:
http://localhost:2867/Service1.svc

(请不要为此使用development server。)

需要检查两件事:

  • 您的客户端正在使用
    basicHttpBinding
    ,而您的服务正在使用
    webHttpBinding
    ,因此您的绑定不匹配

  • 您的客户正在为合同引用
    servicereferencedp.IService1
    ,而您的服务正在使用
    CollectiveDistributedPolling.IService1
    ——即使代码相同,它们也不相同

  • 记住WCF的基本条款——地址、约束和合同。客户端必须匹配服务才能连接。

    需要检查两件事:

  • 您的客户端正在使用
    basicHttpBinding
    ,而您的服务正在使用
    webHttpBinding
    ,因此您的绑定不匹配

  • 您的客户正在为合同引用
    servicereferencedp.IService1
    ,而您的服务正在使用
    CollectiveDistributedPolling.IService1
    ——即使代码相同,它们也不相同


  • 记住WCF的基本条款——地址、约束和合同。客户端必须与服务匹配才能连接。

    我已进行了调整,但仍收到相同的异常。请更新服务引用并检查Windows错误日志中的服务错误。我已进行了调整,但仍收到相同的异常。请更新服务引用并检查Windows错误日志中的服务错误。