Click here to Skip to main content
15,902,939 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i'm using a WCF client to connect to a .NET Web Service (ASMX). The web service is protected using basic authentication, i set the username and password of the wcf client but it never works i always get a "The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Basic realm="localhost"'." exception. Can anyone tell me how i can solve my problem?

Thanks.
Posted
Comments
dan!sh 17-Apr-11 1:21am    
Can you share the configuration entries for the web service? I am interested in looking at the Security.Transport part.

Make sure that you have created an old fashioned reference using the add reference => advanced option in the add reference screen using visual studio.

Use fiddler to check if the wcf client is actually sending the WWW-authenticate information in the header.
 
Share this answer
 
here is my wcf client configuration:

XML
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="EchoSoap" 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="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="TransportCredentialOnly">
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost/Web%20Security/Echo.asmx"
            binding="basicHttpBinding" bindingConfiguration="EchoSoap"
            contract="Echo.EchoSoap" name="EchoSoap" />
    </client>
</system.serviceModel>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900