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

StackOverflow https://stackoverflow.com/questions/11563389

Question

I have looked all over stackoverflow and internet, still can't find a solution for this I have set up a custom basichttpbinding with a 'https' endpoint. when I call the method, it kept return me exception:

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

var endPoint = new EndpointAddress("https://xxxxx/v2_soap/index/");

var binding = new BasicHttpBinding
{
    Name = "HandlerBinding",
        CloseTimeout = TimeSpan.FromMinutes(1.0),
        HostNameComparisonMode = HostNameComparisonMode.StrongWildcard,
        MessageEncoding = WSMessageEncoding.Text,
        MaxReceivedMessageSize = 65536000,
        MaxBufferPoolSize = 65536000,
        UseDefaultWebProxy = true,
        AllowCookies = false,
        BypassProxyOnLocal = false,
        Security =
    {
        Mode =BasicHttpSecurityMode.Transport,
        Transport =
        {
            ClientCredentialType = HttpClientCredentialType.None,
            ProxyCredentialType = HttpProxyCredentialType.None
        },
        Message =
            {
                ClientCredentialType = BasicHttpMessageCredentialType.UserName
            }
    } 
};

the above settings are exact the same as the app.config the VS generated when adding a service reference:

 <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="HandlerBinding" 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="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://xxxxx/v2_soap/index/?SID=qttkobaa5jrmaj22il8mn9n342"
        binding="basicHttpBinding" bindingConfiguration="HandlerBinding"
        contract="HandlerPortType"
        name="HandlerPort" />
    </client>
  </system.serviceModel>

I even tried to change from basichttpbinding to WSHttpBinding, and still no luck.

Was it helpful?

Solution

There is a good article on CodeProject for this: SSL for self hosted WCF service

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top