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

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

 

By connecting to WCF WebService with configuration shown bellow you may notice that the client could get sometimes in trouble.
That is the exception can be thrown while invoking of some service operation: The remote server returned an error: (401) Unauthorized.

<endpoint address="basiccredentialsendpoint"
                binding="basicHttpBinding"
                bindingConfiguration="BasicAuthenticationBinding"
                contract="IService"/>

 

If authentication settings of the service in IIS looks like shown at the picture below, you will get the error shown above.

image
If you for example disable the WindowsAuthentication, the client will authenticate successfully by using of
Basic-Transport-Authentication.

image

However if you enable BasicAuthetication in IIS only but you enable both in WCF
you will also get an error: InternalServer Error 500: Client found response content type of '', but expected 'text/xml'.

 

<endpoint address="windowscredentialsendpoint"
                binding="basicHttpBinding"
                bindingConfiguration="WindowsCredentialsViaTransport"
                contract="IService"/>

<endpoint address="basiccredentialsendpoint"
                binding="basicHttpBinding"
                bindingConfiguration="BasicAuthenticationBinding"
                contract="IService"/>


Posted Jul 06 2009, 06:47 PM by Damir Dobric
developers.de is a .Net Community Blog powered by daenet GmbH.