1

In C#, I am trying to access a web service located on an HTTPS address. My code is defined in a class library, which is referred to in the main application(s) using DLLs — so the standard way of configuring the web services with an App.config file is not possible here. My code is essentially equal to the following:

var remoteAddress = new System.ServiceModel.EndpointAddress(
    "https://myUrl.com/Service.svc");
MyServiceClient myClient = new MyServiceClient(
    new System.ServiceModel.WSHttpBinding(),
    remoteAddress);
myClient.ClientCredentials.ClientCertificate.SetCertificate(
    StoreLocation.CurrentUser,
    StoreName.My,
    X509FindType.FindByThumbprint,
    "91 47 0b e8 80 bf ee 68 32 93 f0 d4 ee e6 14 8c e5 0c fa 3e"
    );
myClient.Endpoint.Binding.SendTimeout = new TimeSpan(0, 0, 0, 10);
var myResult = myClient.MyMethod("foo bar");

But even though I use WSHttpBinding I get an ArgumentException with the message:

The provided URI scheme 'https' is invalid; expected 'http'.
Parameter name: via

Can anyone spot what the problem is?

Owen Blacker
  • 4,117
  • 2
  • 33
  • 70
someName
  • 1,275
  • 2
  • 14
  • 33
  • possible duplicate of [The provided URI scheme 'https' is invalid; expected 'http'. Parameter name: via](http://stackoverflow.com/questions/2435823/the-provided-uri-scheme-https-is-invalid-expected-http-parameter-name-via) – vcsjones Sep 13 '11 at 14:31

1 Answers1

0

Since you are using SSL/TLS, i.e. https, it would make sense to create the WSHttpBinding instance with this information. E.g. change

new System.ServiceModel.WSHttpBinding()

to new System.ServiceModel.WSHttpBinding(SecurityMode.xxx)

where xxx is defined in http://msdn.microsoft.com/en-us/library/ms575161.aspx

poupou
  • 43,413
  • 6
  • 77
  • 174