Web服务端点标识错误

时间:2014-12-12 04:10:48

标签: c# wcf wcf-configuration

我的网络服务存在问题。我们没有制作网络服务,所以我们不知道发生了什么。首先,它在我们的服务器中工作,但有时它不会导致我们重新启动它。然后,它显示错误消息:

  

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

但我们的网络服务甚至没有安全保障!我们的网络配置是:

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

3 个答案:

答案 0 :(得分:1)

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

<security mode="None"/>

它已删除,因为我正在使用Web服务身份验证的代码。感谢上帝,我有多个备份!多谢你们!我会在两天后将其更新为已回答。

答案 1 :(得分:0)

在安全标记下,试试这个

<security mode="None">  

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

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

</security>

答案 2 :(得分:0)

我们已修复

旧代码

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