Web Service 之 Exception: "The HTTP request is unauthorized with client authentication scheme......"

来源:互联网 发布:js联动下拉菜单 编辑:程序博客网 时间:2024/05/17 23:43

问题:

An exception of type'System.ServiceModel.Security.MessageSecurityException' occurred and wascaught.

Type :System.ServiceModel.Security.MessageSecurityException, System.ServiceModel,Version=4.0.0.0, Culture=neutral, ...... 

Message: TheHTTP request is unauthorized with client authentication scheme 'Negotiate'. Theauthentication header received from the server was 'NTLM,Negotiate'.

Data :System.Collections.ListDictionaryInternal

TargetSite : VoidHandleReturnMessage(System.Runtime.Remoting.Messaging.IMessage,System.Runtime.Remoting.Messaging.IMessage)

Stack Trace :

Server stack trace:

  atSystem.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequestrequest, HttpWebResponse response, WebException responseException,HttpChannelFactory`1 factory)

  atSystem.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequestrequest, HttpWebResponse response, HttpChannelFactory`1 factory, WebExceptionresponseException, ChannelBinding channelBinding)

  at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpantimeout)

  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)

  atSystem.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessagemethodCall, ProxyOperationRuntime operation)

  at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessagemessage)

  at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)

  at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&msgData, Int32 type)

  at XXX.DataAccess.MyWebService.MySoap.GetInfoList()

  at XXX.Program.LoadAll() ind:\...\Program.cs:line XX

 

         InnerException

         Type: System.Net.WebException, System, Version=4.0.0.0, Culture=neutral,......

         Message: The remote server returned an error: (401) Unauthorized.

         Status: ProtocolError

         Response: System.Net.HttpWebResponse

         Data: System.Collections.ListDictionaryInternal

         TargetSite: System.Net.WebResponse GetResponse()

         StackTrace :    atSystem.Net.HttpWebRequest.GetResponse()

          at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpantimeout)

原因:

访问web service时, 需要用户名和密码。

此时使用的用户名和密码不对。


解决方案:

修改可用的密码和用户名



0 0
原创粉丝点击