WCF service, legacy client using Basic authentication?



I am trying to develop a WCF service hosted in IIS that will be called by a
Windows Mobile client. Because the client is using the Compact Framework, it
appears I won't be able to use either WCF or WSE in the client. The web
service will require authentication. I am therefore trying to use Basic
Authentication over HTTPS.

I have a simple WCF service, and a WCF client that works great. But for the
life of me, I can't get a simple web service client that works. I am using
VS 2008, the client project is targeted for .NET 2.0, and added a standard
web reference. I am supplying credentials to the proxy as follows:

proxy.Credentials = new System.Net.NetworkCredential(@"MyUserName",
"MyPassword", "MyDomain");

The config file for my service is as follows:

<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicAuthenticationConfiguration">
<security mode="Transport">
<transport clientCredentialType="Basic"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="CalculatorService.Service"
behaviorConfiguration="CalculatorServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="https://MyServer/CalculatorService/Service.svc"; />
</baseAddresses>
</host>
<endpoint
name="BasicAuthenticationEndpoint"
address=""
binding="basicHttpBinding"
bindingConfiguration="BasicAuthenticationConfiguration"
contract="CalculatorService.ICalculator" />
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="CalculatorServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>

The response I get is:

System.Net.WebException: The request failed with HTTP status 401:
Unauthorized.

Oddly enough, if I omit the Domain parameter from the NetworkCredential
constructor, and instead use "MyDomain\MyUserName" in the UserName parameter,
I get a "401: Access Denied." response instead of "Unauthorized".

I'm sure that the credentials I'm using are valid (and indeed the same
credentials work just fine in the WCF client). It seems to make no
difference whether I use basicHttpBinding or wsHttpBinding.

What am I doing wrong? Any suggestions, thoughts, speculation or advice
would be very welcome at this point!
.



Relevant Pages

  • RE: WCF Security Issue
    ... ** Is your WCF service designed to use domain ... both wsHttpbinding and netTcpBinding support message ... Then, for your WCF client, you can use the current logon user's credential ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: System.Configuration does not support config files for libraries.
    ... Seems what you want to do is sharing some custom classes/types between the WCF service and client application. ... For WCF there is type sharing support. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: WCF Contract Design Best Practices Question
    ... don't have to worry about maintaining client apps. ... I had this thought that I could host my WFC client proxies in this library ... my WCF object I'm still going to have to ... properties that are used just for the web service. ...
    (microsoft.public.dotnet.framework.webservices)
  • RE: Comet implementation in WCF
    ... As for the WCF Comet service scenario you mentioned, ... So far based on my research, at server-side, WCF method can use ... Microsoft MSDN Online Support Lead ... I am developing a WCF Comet web service, where client requests gets queued ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • WCF and ASP.Net wsHTTPBinding Access Denied
    ... The service works fine with the WCF ... test client in Visual Studio 2008 and from an ASP.Net client hosted on my ... "Same" IIS server, ... Upon deployment, the following identity element should be ...
    (microsoft.public.dotnet.framework.webservices)