Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.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
C# Web服务终结点标识错误_C#_Wcf_Wcf Configuration - Fatal编程技术网

C# Web服务终结点标识错误

C# Web服务终结点标识错误,c#,wcf,wcf-configuration,C#,Wcf,Wcf Configuration,我对我们的web服务有问题。我们没有制作web服务,所以我们不知道到底发生了什么。起初,它在我们的服务器上工作,但有时不工作,这导致我们重新启动它。现在,它显示错误消息: 无法打开安全通道,因为与远程终结点的安全协商失败。这可能是由于用于创建通道的EndpointAddress中缺少EndpointIdentity或未正确指定EndpointIdentity造成的。请验证EndpointAddress指定或暗示的EndpointIdentity是否正确标识远程端点 但是我们的web服务甚至都不安

我对我们的web服务有问题。我们没有制作web服务,所以我们不知道到底发生了什么。起初,它在我们的服务器上工作,但有时不工作,这导致我们重新启动它。现在,它显示错误消息:

无法打开安全通道,因为与远程终结点的安全协商失败。这可能是由于用于创建通道的EndpointAddress中缺少EndpointIdentity或未正确指定EndpointIdentity造成的。请验证EndpointAddress指定或暗示的EndpointIdentity是否正确标识远程端点

但是我们的web服务甚至都不安全!我们的网络配置是:

<configuration>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Server=;Database=;User ID=;Password=;Trusted_Connection=False;" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime executionTimeout="3600000" maxRequestLength="102400" />
  </system.web>
  <appSettings>
    <add key="baseAddress" value="http://localhost:20088" />
    <add key="timeout" value="120"/>
    <add key="provider" value="System.Data.SqlClient" />
  </appSettings>
  <system.serviceModel>
    <services>
      <service name="H2WcfService.DataAccess" behaviorConfiguration="H2WcfServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:20088"/>
          </baseAddresses>
        </host>
        <endpoint address="" binding="wsHttpBinding" contract="H2WcfService.IDataAccess" bindingConfiguration="DataAccess">
          <identity>
            <dns value="localhost:20088"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
      <service name="H2WcfService.LoginService" behaviorConfiguration="H2WcfServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:20088"/>
          </baseAddresses>
        </host>
        <endpoint address="" binding="wsHttpBinding" contract="H2WcfService.ILoginService" bindingConfiguration="Authentic">
          <identity>
            <dns value="localhost:20088"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
      <service name="H2WcfService.LMSService" behaviorConfiguration="H2WcfServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:20088"/>
          </baseAddresses>
        </host>
        <endpoint address="" binding="wsHttpBinding" contract="H2WcfService.ILMSService" bindingConfiguration="LMSService">
          <identity>
            <dns value="localhost:20088"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="H2WcfServiceBehavior" >
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
        <behavior name="">
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <bindings>
      <wsHttpBinding>
        <binding name="DataAccess" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
          <security mode="None">
            <transport clientCredentialType="None" />
            <message establishSecurityContext="false" />
          </security>
        </binding>
        <binding name="Authentic">
          <security mode="None">
            <transport clientCredentialType="None" />
            <message establishSecurityContext="false" />
         </security>
      </binding>
      <binding name="LMSService">
        <security mode="None">
          <transport clientCredentialType="None" />
          <message establishSecurityContext="false" />
        </security>
      </binding>
    </wsHttpBinding>
  </bindings>
</system.serviceModel>
<system.webServer>
  <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>

在安全标签下,尝试以下操作

<security mode="None">  

<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />  

<message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="true" />  

</security>

终于找到了答案!基本上,在asp.net应用程序web.config的System.Servicemodel绑定下,我应该添加:

<security mode="None"/>

它被删除了,因为我正在玩web服务身份验证的代码。感谢上帝,我有多个备份!谢谢大家!我将在两天后更新此答复。

我们已修复

旧代码

<security mode="TransportWithMessageCredential">
    <transport clientCredentialType="None" />
    <message establishSecurityContext="false" />
</security>
   
<security mode="TransportWithMessageCredential">
    <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
    <message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="false" />
</security>  

新代码

<security mode="TransportWithMessageCredential">
    <transport clientCredentialType="None" />
    <message establishSecurityContext="false" />
</security>
   
<security mode="TransportWithMessageCredential">
    <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
    <message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="false" />
</security>  


我尝试了您的解决方案,但它仍然会抛出该错误。有一件事总是好的,那就是检查不同配置属性的默认值,因为它们适用于您正在使用的绑定<例如,code>wsHttpBinding的默认安全模式为
Message
,而
basicHttpBinding
的默认安全模式为
None
(IIRC),而
netTcpBinding
的默认安全模式为
Transport
。如果未在配置(或代码)中指定值,则使用默认值。