简体   繁体   English

调用者未通过服务验证(wsDualHttpBinding)

[英]The caller was not authenticated by the service (wsDualHttpBinding)

I don't require any sort of authentication, client and service won't be on the same machine and in different domains. 我不需要任何身份验证,客户端和服务不会在同一台计算机上和不同的域中。 When I try to connect to the service I get the following error. 当我尝试连接到服务时,出现以下错误。

'System.ServiceModel.Security.SecurityNegotiationException' Additional information: The caller was not authenticated by the service. 'System.ServiceModel.Security.SecurityNegotiationException'附加信息:服务未对调用方进行身份验证。

Hence I tried to turn off the security on service: 因此,我试图关闭服务的安全性:

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

Now when I try to run the service on its own I get this error message: 现在,当我尝试自行运行服务时,出现以下错误消息:

The service certificate is not provided. 未提供服务证书。 Specify a service certificate in ServiceCredentials. 在ServiceCredentials中指定服务证书。

But I don't need any security. 但是我不需要任何安全性。 Installing a service certificate means that I expect my clients to have installed the same certificate in order to authenticate, correct? 安装服务证书意味着我希望我的客户端安装相同的证书以进行身份​​验证,对吗? This is not what I want though. 这不是我想要的。

I am quite stuck on this, an advice would be really appreciated. 我对此非常执着,非常感谢您的建议。

I seem to have found it. 我似乎已经找到了。 I found it difficult, getting it right with the WCF Config editor in Visual Studio. 我发现很难,要在Visual Studio中使用WCF Config编辑器正确解决。 Best is to copy and paste this. 最好是将其复制并粘贴。

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

In the client make sure to have this in your configuration: 在客户端中,请确保在您的配置中包含以下内容:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM