44

我正在尝试从我的客户端控制台应用程序访问服务器上的 WCF 服务以进行测试。我收到以下错误:

调用者未经服务验证

我正在使用wsHttpBinding. 我不确定该服务需要什么样的身份验证?



<behaviors>
  <serviceBehaviors>
    <behavior name="MyTrakerService.MyTrakerServiceBehavior">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

更新 如果我<endpoint "basicHttpBinding" ... />在托管的 IIS 7.0、windows 2008 服务器上将绑定更改为(从 wsHttpBinding),它就可以工作

4

10 回答 10

26

如果您使用 basicHttpBinding,请将端点安全性配置为“None”,并将 clientCredentialType 传输为“None”。

<bindings>
    <basicHttpBinding>
        <binding name="MyBasicHttpBinding">
            <security mode="None">
                <transport clientCredentialType="None" />
            </security>
        </binding>
    </basicHttpBinding>
</bindings>
<services>
    <service behaviorConfiguration="MyServiceBehavior" name="MyService">
        <endpoint 
            binding="basicHttpBinding" 
            bindingConfiguration="MyBasicHttpBinding"
            name="basicEndPoint"    
            contract="IMyService" 
        />
</service>

另外,确保 IIS 中的目录身份验证方法启用匿名访问

于 2008-11-12T19:33:10.307 回答
24

我知道了。

如果您想使用 wshttpbinding,您需要添加 Windows 凭据,如下所示。

svc.ClientCredentials.Windows.ClientCredential.UserName = "abc";
svc.ClientCredentials.Windows.ClientCredential.Password = "xxx";

谢谢

于 2009-02-25T23:42:14.823 回答
4

您是否尝试过使用 basicHttpBinding 而不是 wsHttpBinding?如果不需要任何身份验证并且不需要 Ws-* 实现,那么使用普通的旧 basicHttpBinding 可能会更好。WsHttpBinding 为消息安全和身份验证实现 WS-Security。

于 2008-11-12T18:04:27.787 回答
2

在您的虚拟目录中设置匿名访问

将以下凭据写入您的服务

ADTService.ServiceClient adtService = new ADTService.ServiceClient();
adtService.ClientCredentials.Windows.ClientCredential.UserName="windowsuseraccountname";
adtService.ClientCredentials.Windows.ClientCredential.Password="windowsuseraccountpassword";
adtService.ClientCredentials.Windows.ClientCredential.Domain="windowspcname";

之后,您调用您的网络服务方法。

于 2009-10-21T07:09:52.017 回答
1

如果您使用像我这样的自托管站点,避免此问题的方法(如上所述)是在主机和客户端都规定 wsHttpBinding 安全模式 = NONE。

在客户端和主机上创建绑定时,您可以使用以下代码:

 Dim binding as System.ServiceModel.WSHttpBinding 
 binding= New System.ServiceModel.WSHttpBinding(System.ServiceModel.SecurityMode.None)

或者

 System.ServiceModel.WSHttpBinding binding
 binding = new System.ServiceModel.WSHttpBinding(System.ServiceModel.SecurityMode.None);
于 2013-11-04T13:57:41.390 回答
1

我能够通过以下步骤解决共享问题:

  1. 转到 IIS-->站点-->您的站点-->
  2. 功能视图窗格-->身份验证
  3. 匿名身份验证设置为禁用
  4. Windows 身份验证设置为已启用

在此处输入图像描述

于 2016-04-07T22:12:01.483 回答
0

我也有同样的问题wsHtppBinding。我只需要添加security指向 的模式none,就解决了我的问题,无需切换到basicHttpBinding. 检查此处并检查如何禁用 WCF 安全性。检查以下配置更改以供参考:

<wsHttpBinding>
    <binding name="soapBinding">
        <security mode="None">
            <transport clientCredentialType="None" />
            <message establishSecurityContext="false" />
        </security>
    </binding>
</wsHttpBinding>
于 2018-07-19T06:26:49.267 回答
0

如果需要在 webconfig 中指定域(验证客户端使用的用户名和密码),您可以将其放入 system.serviceModel services 服务部分:

<identity>          
<servicePrincipalName value="example.com" />
</identity>

并在客户端指定域和用户名和密码:

 client.ClientCredentials.Windows.ClientCredential.Domain = "example.com";
 client.ClientCredentials.Windows.ClientCredential.UserName = "UserName ";
 client.ClientCredentials.Windows.ClientCredential.Password = "Password";
于 2016-02-27T09:55:13.350 回答
0

如果客户端与服务器位于不同的域中,则可能会导致此问题。

我在测试我的一个应用程序从我的 PC(客户端)到我的(云)测试服务器时遇到了这个问题,我能想到的最简单的解决方案是设置一个 vpn。

于 2016-05-17T04:22:52.073 回答
-2

为什么不能完全删除 wsHttpBinding 的安全设置(“none”而不是“message”或“transport”)?

于 2009-11-03T06:29:06.453 回答