0

I did a lot of searching and nothing seems to work. I have done a custom binding for my Https service . which looks like this.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <section name="Time.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
    </sectionGroup>
  </configSections>

  <applicationSettings>
    <Time.Properties.Settings>
      <setting name="Time_SupervisorSinkTime_TimeService" serializeAs="String">
       <value>http://localhost:8080/Time/</value>
      </setting>
    </Time.Properties.Settings>
  </applicationSettings>

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IDataSink" closeTimeout="00:00:10" openTimeout="00:00:10" receiveTimeout="00:00:10" sendTimeout="00:00:10" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
        </binding>
  <binding name="SslBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="Certificate" algorithmSuite="Default" />
          </security>
        </binding>

        <binding name="EBinding" allowCookies="true"
                 maxReceivedMessageSize="20000000" 
                 maxBufferSize="20000000"
                 maxBufferPoolSize="20000000">
            <readerQuotas maxDepth="32" 
                 maxArrayLength="200000000"
                 maxStringContentLength="200000000"/>
        </binding>  

      </basicHttpBinding>
<customBinding>
  <binding name="customBasicHttpBinding">
    <security authenticationMode="UserNameOverTransport"  enableUnsecuredResponse="true"/>
    <textMessageEncoding messageVersion="Soap11" />
    <httpsTransport />
  </binding>
   <binding name="EBICustom">
   <security authenticationMode="UserNameOverTransport"  enableUnsecuredResponse="true"/>
    <textMessageEncoding messageVersion="Soap12" />
    <httpsTransport maxBufferSize="2097152" maxReceivedMessageSize="1073741824" transferMode="Streamed" />
  </binding>
</customBinding>      
    </bindings>
    <client>
      <endpoint bindingConfiguration="BasicHttpBinding" address="http:///" binding="basicHttpBinding" contract="" name=""/>
     <endpoint bindingConfiguration="EBICustom" address="https://.." binding="customBinding" contract="EBIContract" name="EBIPort" /> 
    <endpoint bindingConfiguration="EBinding" address="http://.." binding="basicHttpBinding" contract="EcontractSEI" name="EService" />
    <endpoint bindingConfiguration="customBasicHttpBinding" address="https://.." binding="customBinding" contract="contractSEI" name="someservice" />

    </client>
    <behaviors>
      <endpointBehaviors>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>

  <appSettings>
    <add key="interfaces" />
    <add key="startup" />
  </appSettings>
</configuration>

and also on the client (on the code ) I have done a custom binding . but for some reason it gives me the error " provided URI scheme 'https' is invalid; expected 'http'"

the same custom binding work perfectly for customBasicHttpBinding but not for EBICustom.

if someone could help me point on what is wrong where, it would really be helpful.

1 Answers1

0

First the client binding configuration must be the same as the server, so use the secure transport channel on the client side.

You can do this through the configuration in the app.config file, or you can refer to the following code:

var ws_http_binding = new WSHttpBinding();

ws_http_binding.Security.Mode = SecurityMode.Transport;

ChannelFactory<IInternal> factory = 
    new ChannelFactory<IInternal>(
        ws_http_binding,
        new EndpointAddress("https://MyMachine:8733/IInternal"));

var channel = factory.CreateChannel();
Jiayao
  • 510
  • 3
  • 7