我在客户端处理来自外部供应商wcf服务(如"The HTTP request is unauthorized with client authentication scheme 'Basic'. The authentication header received from the server was 'Basic realm="CASM"'".
)的异常我请求Web服务提供大量数据,但在某个时间点我遇到了异常。中间的事情是,我从wcf服务中获得了一些数据,然后得到了异常。所以我认为我是否需要对请求进行微调??所以我不应该一次询问大量数据,或者这是一个不同的问题。我确实很喜欢"在VS2012中添加web服务引用时出错"的帖子,但运气不好。有人能告诉我,这一例外背后可能的原因是什么吗。下面是我的webconfig部分,我正在起诉我的代码中的用户名和密码
<binding name="Test" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="6553600" maxBufferPoolSize="524288" maxReceivedMessageSize="6553600"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" proxyCredentialType="Basic"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<endpoint address="http://testurl/as" binding="basicHttpBinding"
bindingConfiguration="Test" contract="Testservice.Test" name="Test">
</endpoint>
更新
还有一件事,这个realm="CASM"
是什么异常,我无法在客户端配置中设置,intellisense没有给出
尝试更改此
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" proxyCredentialType="Basic"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
使用这条线路
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Anonymous"/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>