首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >WCFTestClient该HTTP请求未经授权,客户端身份验证方案为“”匿名“”

WCFTestClient该HTTP请求未经授权,客户端身份验证方案为“”匿名“”
EN

Stack Overflow用户
提问于 2009-06-25 13:46:14
回答 10查看 288.8K关注 0票数 73

我已经创建了一个WCF服务,并将其部署在服务器上。当我浏览这个服务时,它给我一个肯定的响应:?wsdl URL。现在,我正在尝试通过WCF test client测试服务。它显示了适当的元数据。但是当我试图从服务中调用任何方法时,它会显示一个异常...下面是堆栈跟踪的erro详细信息。

使用客户端身份验证方案“匿名”对HTTP请求进行了授权。从服务器收到的身份验证头是'Negotiate,NTLM‘。

服务器堆栈跟踪:

地址为

System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest请求、HttpWebResponse响应、WebException responseException、HttpChannelFactory工厂)

HTTP请求未经授权,客户端身份验证方案为“匿名”。从服务器收到的身份验证头是'Negotiate,NTLM‘。

服务器堆栈跟踪:

地址为

System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest请求、HttpWebResponse响应、WebException responseException、HttpChannelFactory工厂)

客户端绑定:

代码语言:javascript
复制
<bindings>
    <wsHttpBinding>
        <binding name="WSHttpBinding_IServiceMagicService" 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"
            allowCookies="false">
            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            <reliableSession ordered="true" inactivityTimeout="00:10:00"
                enabled="false" />
            <security mode="None">
                <transport clientCredentialType="Windows" proxyCredentialType="None"
                    realm="" />
                <message clientCredentialType="Windows" negotiateServiceCredential="true"
                    establishSecurityContext="true" />
            </security>
        </binding>
    </wsHttpBinding>
</bindings>

服务器绑定:

代码语言:javascript
复制
<bindings>
  <wsHttpBinding>
    <binding name="WSHttpBinding_SEOService" closeTimeout="00:10:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="true" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="999524288" maxReceivedMessageSize="655360000" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
      <readerQuotas maxDepth="32" maxStringContentLength="900000" maxArrayLength="900000" maxBytesPerRead="900000" maxNameTableCharCount="900000" />
      <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
      <security mode="None">
        <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
        <message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="true" />
      </security>
    </binding>
    <binding name="WSHttpServiceMagicBinding" closeTimeout="00:10:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="true" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="999524288" maxReceivedMessageSize="655360000" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
      <readerQuotas maxDepth="32" maxStringContentLength="900000" maxArrayLength="900000" maxBytesPerRead="900000" maxNameTableCharCount="900000"/>
      <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
      <security mode="None">
        <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
        <message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="true"/>
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

Client's Client部分:

代码语言:javascript
复制
<client>
    <endpoint address="http://hydwebd02.solutions.com/GeoService.Saveology.com/ServiceMagicService.svc"
        binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IServiceMagicService"
        contract="IServiceMagicService" name="WSHttpBinding_IServiceMagicService" />
</client>

服务器的服务部分:

代码语言:javascript
复制
<services>
    <service behaviorConfiguration="GeoService.Saveology.com.CityStateServiceProviderBehavior"
    name="GeoService.Saveology.com.CityStateServiceProvider">
    <endpoint binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_SEOService"
        contract="SEO.Common.ServiceContract.ICityStateService" />
    <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
        contract="IMetadataExchange" />
    </service>
    <service behaviorConfiguration="GeoService.Saveology.com.ServiceMagicServiceProviderBehavior"
    name="GeoService.Saveology.com.ServiceMagicServiceProvider">
    <endpoint binding="wsHttpBinding" bindingConfiguration="WSHttpServiceMagicBinding" 
        contract="SEO.Common.ServiceContract.IServiceMagicService">
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange" />
    </service>
</services>
EN

回答 10

Stack Overflow用户

发布于 2010-03-09 22:28:37

我无法控制我要调用的服务的安全配置,但得到了相同的错误。我能够像下面这样修复我的客户。

  1. 在配置中,设置安全模式:

  • 在代码中,将代理类设置为允许模拟(我添加了对名为customer的服务的引用):

新代理=新的代理();proxy.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

票数 84
EN

Stack Overflow用户

发布于 2009-09-11 19:34:24

我也有类似的问题,你试过了吗:

代码语言:javascript
复制
proxy.ClientCredentials.Windows.AllowedImpersonationLevel =   
          System.Security.Principal.TokenImpersonationLevel.Impersonation;
票数 13
EN

Stack Overflow用户

发布于 2013-03-14 05:38:18

我发现的这个错误的另一个可能的解决方案。可能没有回答OP的确切问题,但可能会帮助其他偶然发现此错误消息的人。

为了复制下面这行代码,我使用WebHttpBinding用代码创建了我的客户端:

代码语言:javascript
复制
<security mode="TransportCredentialOnly">
  <transport clientCredentialType="Windows" proxyCredentialType="Windows" />
</security>

我不得不这样做:

代码语言:javascript
复制
var binding = new WebHttpBinding(WebHttpSecurityMode.TransportCredentialOnly);
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
                binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Windows;

以及设置proxy.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1044034

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档