2017-05-30 101 views
0

我正在使用调用另一个Web服务的Web服务。我的应用程序可以在短时间内进行大量呼叫时运行场景。在某个时间点,Web Service开始抛出错误401 Unauthorized。这里有详细的错误:许多Web服务调用导致401未经授权的响应随机

<Exception> 
    <Source>mscorlib</Source> 
    <Message>The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM'.</Message> 
    <Stack> 
Server stack trace: 
    at System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse response, WebException responseException, HttpChannelFactory`1 factory) 
    at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding) 
    at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 
    at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) 
    at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) 
    at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 
    at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) 

Exception rethrown at [0]: 
    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 
    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData, Int32 type) 
    at KwikTagWebInterface.DMSWebSrv.IWOVServicesSoap.CreateDocuments(CreateDocumentsRequest request) 
    at KwikTagWebInterface.DMSWebSrv.WOVServicesSoapClient.CreateDocuments(CreateDocumentsInput CreateDocuments1) 
    at KwikTagWebInterface.Controllers.DMSConnector.CreateDocumentProforma(String profIndex, String matter, String userName) 
    at KwikTagWebInterface.KTWebServices.TagProformaECover(String profIndex, String matter, String userName, String userDomain)</Stack> 
    <InnerException> 
     <Source>System</Source> 
     <Message>The remote server returned an error: (401) Unauthorized.</Message> 
     <Stack> at System.Net.HttpWebRequest.GetResponse() 
    at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)</Stack> 
    </InnerException> 
    </Exception> 

它引发了这样的几个错误,然后继续工作就好了。这些电话之间绝对没有区别,所以我不明白为什么有些电话可以正常工作,其中一些电话不工作。

这里是我的配置:

<system.serviceModel> 
    <bindings> 
    <basicHttpBinding> 
     <binding name="IWOVServicesSoap" maxReceivedMessageSize="2097152" maxBufferSize="2097152" maxBufferPoolSize="2097152"> 
     <security mode="TransportCredentialOnly"> 
      <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" /> 
      <message clientCredentialType="UserName" algorithmSuite="Default" /> 
     </security> 
     </binding> 
    </basicHttpBinding> 
    </bindings> 
    <client> 
    <endpoint address="http://Server/Application/Services/IWOVServices.asmx" 
     binding="basicHttpBinding" bindingConfiguration="IWOVServicesSoap" 
     contract="WebSrv.IWOVServicesSoap" name="IWOVServicesSoap" /> 
    </client> 
</system.serviceModel> 

任何建议吗?

回答

0

您可能会受到限制,尽管这是对这种情况的错误响应代码。不过,这是分布式服务的本质。我建议采用某种重试策略来缓解问题。或者引入一些自己的速率限制来减少你提出请求的频率。或者,如果有办法批量处理您的请求并发送1而不是1000,那可能是最佳解决方案。

相关问题