首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >所提供的URI方案'https‘无效;即使在指定<httpsTransport/>之后,也期望'http’

所提供的URI方案'https‘无效;即使在指定<httpsTransport/>之后,也期望'http’
EN

Stack Overflow用户
提问于 2022-09-20 09:00:05
回答 1查看 23关注 0票数 0

我做了很多搜索,但似乎没有任何效果。我已经为我的Https服务做了自定义绑定。看上去像这样。

代码语言:javascript
复制
<?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>

在客户端(在代码上),我也做了一个自定义绑定。但出于某种原因,它给了我一个错误“提供的URI方案'https‘是无效的;预期的’http‘

相同的自定义绑定对于customBasicHttpBinding非常有效,但对EBICustom却不起作用。

如果有人能帮我指出哪里出了问题,那将是很有帮助的。

EN

回答 1

Stack Overflow用户

发布于 2022-09-21 07:21:52

首先,客户端绑定配置必须与服务器相同,因此在客户端使用安全传输通道。

您可以通过app.config文件中的配置完成此操作,也可以参考以下代码:

代码语言:javascript
复制
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();
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73784101

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档