F# WSDL Type Provider and HTTPS

I recently ran into a problem with accessing a WCF web service over https. I used the WSDL Type Provider to generate the service client for me. I referenced System and System.ServiceModel like a good boy, yet I couldn’t find any way to set the credentials for the service. I began by trying to use the generated client: MyService.GetWSHttpBinding_IDataService. Unfortunately, that didn’t have a the ClientCredentials property I expected. So I then tried creating a new client:

1
2
3
4
5
let endpoint = "WSHttpBinding_Test"
let username = ""
let password = ""
let client = new MyService.DataServiceClient(endpoint)
client.ClientCredentials.Windows.ClientCredential <- new NetworkCredential(username, password)

Unfortunately, the issue persisted. I then noticed a little message noting that I was missing an assembly reference. Turns out you must also open System.IdentityModel. Problem solved.

NOTE: If anyone knows of an https hosted WCF service in the wild, I’d be happy to share the full code.

Advertisements