2017-05-30 38 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,那可能是最佳解決方案。

相關問題