无法连接到远程WCF服务 - SecurityNegotiationException [英] Unable to Connect to Remote WCF Service - SecurityNegotiationException

查看:202
本文介绍了无法连接到远程WCF服务 - SecurityNegotiationException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始了与 WCF 和我下面的从MSDN 样本。我设法运行由部署在客户端和功放一台机器上,以及入门样本;服务在不同的机器和远程访问服务。

I am starting off with WCF, and I am following the samples from MSDN. I managed to run the Getting Started sample on one machine as well as by deploying the client & service on separate machines and remotely accessing the service.

我的目标是实现的发布/订阅设计模式。我已成功地没有任何重大问题一台机器上运行它。但是,当我部署客户端和放大器;不同的机器上的服务,我的客户端无法连接到该服务。我得到以下异常:

My goal is to implement the Publish/Subscribe design pattern. I have managed to run it on one machine without any big issues. But when I am deploying client & service on different machine, my client is unable to connect to the service. I get the following exception:

System.ServiceModel.Security.SecurityNegotiationException was unhandled
  Message=The caller was not authenticated by the service.
  Source=mscorlib



(我可以分享堆栈跟踪,如果必要的。)

(I can share the stack trace if necessary.)

下面是我的配置:

服务 - web.config中

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <protocolMapping>
      <add scheme="http" binding="wsDualHttpBinding"/>
    </protocolMapping>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>



客户端 - 的app.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>
    <bindings>
      <wsDualHttpBinding>
        <binding name="WSDualHttpBinding_ISampleContract" clientBaseAddress="http://<SERVICE MACHINE PUBLIC IP>:8000/myClient/"
                 closeTimeout="00:01:00"
                  openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                  bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                  maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                  messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00" />
          <security mode="Message">
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
                algorithmSuite="Default"/>
          </security>
        </binding>
      </wsDualHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://<SERVICE MACHINE PUBLIC IP>/ServiceModelSamples/service.svc"
          binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_ISampleContract"
          contract="ISampleContract" name="WSDualHttpBinding_ISampleContract">
        <identity>
          <servicePrincipalName value="host/<SERVICE MACHINE PUBLIC IP>" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
</configuration>



我已经寻找一个解决方案,但一切都没有为我工作。我试图找到一种方法来禁用在服务端的安全/认证(只是为了得到它的工作),但在没有成功也是如此。

I have searched for a solution, but nothing has worked for me. I have tried to find a way to disable the security/authentication on the service side (just to get it work), but haven't been successful in that as well.

我怎样才能解决这个问题?

How can I fix this?

推荐答案

wsDualHttpBinding 默认使用Windows身份验证。如果你不需要这个认证,现在,你可以改变你的配置将其关闭:

wsDualHttpBinding by default uses Windows authentication. If you don't need this authentication for now, you can change your configuration to switch it off:

<configuration>
  <system.serviceModel>
<bindings>
  <wsDualHttpBinding>
    <binding name="wsHttpDual">
      <security mode="None">
        <transport clientCredentialType="None" protectionLevel="EncryptAndSign" />
        <message clientCredentialType="None" algorithmSuite="Default" />
      </security>
    </binding>
  </wsDualHttpBinding>
</bindings>
    <protocolMapping>
      <add scheme="http" binding="wsDualHttpBinding" bindingConfiguration="wsHttpDual"/>
    </protocolMapping>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

在客户端配置以同样的方式改变安全部分:

The same way change security section in client configuration:

      <security mode="None">
        <transport clientCredentialType="None" protectionLevel="EncryptAndSign" />
        <message clientCredentialType="None" algorithmSuite="Default" />
      </security>

这篇关于无法连接到远程WCF服务 - SecurityNegotiationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆