调用者未通过服务进行身份验证(wsDualHttpBinding)

时间:2014-02-26 10:39:18

标签: .net wcf authentication

我不需要任何形式的身份验证,客户端和服务不会在同一台计算机上和不同的域中。当我尝试连接到服务时,我收到以下错误。

  

'System.ServiceModel.Security.SecurityNegotiationException'附加   信息:呼叫者未通过该服务进行身份验证。

因此我试图关闭服务的安全性:

  <system.serviceModel>
    <bindings>
      <wsDualHttpBinding>
        <binding name="CustomDualBinding">
          <security>
            <message clientCredentialType="None" negotiateServiceCredential="false" />
          </security>
        </binding>
      </wsDualHttpBinding>
    </bindings>
    <services>
      <service name="WCFServiceWebRoleStockTrading.Service">
        <endpoint address="Service.svc" binding="wsDualHttpBinding" bindingConfiguration="CustomDualBinding"
          contract="WCFServiceWebRoleStockTrading.IService" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

现在,当我尝试自行运行服务时,我收到以下错误消息:

  

未提供服务证书。指定服务证书   在ServiceCredentials中。

但我不需要任何安全保障。安装服务证书意味着我希望我的客户安装相同的证书以进行身份​​验证,对吗?这不是我想要的。

我对此非常感兴趣,建议真的很感激。

1 个答案:

答案 0 :(得分:1)

我似乎找到了它。我发现很难,在Visual Studio中使用WCF配置编辑器。最好是复制并粘贴它。

 <system.serviceModel>
    <bindings>
      <wsDualHttpBinding>
        <binding name="CustomDualBinding">
          <security mode="None" />
        </binding>
      </wsDualHttpBinding>
    </bindings>
    <services>
      <service name="WCFServiceWebRoleStockTrading.Service">
        <endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="CustomDualBinding"
          contract="WCFServiceWebRoleStockTrading.IService" />
      </service>
    </services>
...
 </system.serviceModel>

在客户端中,请确保在您的配置中具有此功能:

Uri baseAddress = new Uri("http://xxx.cloudapp.net/Service.svc");
WSDualHttpBinding wsd = new WSDualHttpBinding();
wsd.Security = new WSDualHttpSecurity() { Mode = WSDualHttpSecurityMode.None, Message = new MessageSecurityOverHttp() { ClientCredentialType = MessageCredentialType.None, NegotiateServiceCredential = false } };
EndpointAddress ea = new EndpointAddress(baseAddress);            

InstanceContext site = new InstanceContext(this);
_client = new ServiceClient(site, wsd, ea);