Reputation: 11915
I have a wcf application. tested on my local computer (windows 7 and IIS 7.5), it works. but after deployed to dev server (windows server 2003, IIS 6). I got following error message.
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'.
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.Dispatcher.RequestChannelBinder.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& msgData, Int32 type)
at ICFIR.ProcessXmlMessage(String xmlDocument)
at CFIRClient.ProcessXmlMessage(String xmlDocument)
Inner Exception:
The remote server returned an error: (401) Unauthorized.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
I searched on google for hours, found alot similar issues but none of them can fix it. here's my web.config
<basicHttpBinding>
<binding name="ServiceSoap" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="65536" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
Upvotes: 2
Views: 52173
Reputation: 136
This is what Bravo11 was talking about.... This was really bothering me for a while, but I finally ran into a solution after trying the above many different ways. When creating a service in vs2010 if you want to add Windows as your security you need to have the authentication mode set to Windows.
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Windows" />
</system.web>
you can do this either in your Web.config in the service or in IIS 6.0 in the properties -> ASP.NET -> Edit Configuration -> Authentication -> Authentication mode drop down
If you choose to do it in IIS you must remember to do it all the time or it will reset when you publish again.
Hope this will help someone.
Upvotes: 1
Reputation: 918
Its expecting windows authentication, are you on the same domain that your server is? if you are you will need to turn on windows authentication like this:
<security>
<transport clientCredentialType="Windows" proxyCredentialType="None" />
<message clientCredentialType="Windows" />
</security>
if you dont want to turn that on your can turn on other authentication types like Anonymous or Certificate. Refer to this:
http://msdn.microsoft.com/en-us/library/ms729700.aspx
Note: Sometimes if your proxy server is enabled from the machine you are calling, it will get this type of issue too. In that case either turn off your proxy or provide authentication to the proxy.
Upvotes: 1