C# 提供的 URI scheme 'http' 无效;预计 'https'

标签 c# uri app-config

我在调用我的网络服务的方法时遇到这个错误,我不知道该怎么做了:s

异常详情如下:

{"The provided URI scheme 'http' is invalid; expected 'https'.\r\nParameter name: via"}

这是我的 App.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

    <connectionStrings>
      <add name="PowerWeb" connectionString="Data Source=MYSERVER;Initial Catalog=MYTABLE;User ID=MYUSER;Password=MYPW" providerName="System.Data.SqlClient" />
    </connectionStrings>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <system.serviceModel>



      <bindings>
        <customBinding>
          <binding name="ZWS_HARMONIZACAO">
            <!--    WsdlImporter encountered unrecognized policy assertions in ServiceDescription 'urn:sap-com:document:sap:rfc:functions':    -->
            <!--    <wsdl:binding name='ZWS_HARMONIZACAO'>    -->
            <!--        <saptrnbnd:OptimizedXMLTransfer xmlns:saptrnbnd="http://www.sap.com/webas/710/soap/features/transportbinding/">..</saptrnbnd:OptimizedXMLTransfer>    -->
            <!--        <saptrnbnd:OptimizedXMLTransfer xmlns:saptrnbnd="http://www.sap.com/webas/710/soap/features/transportbinding/">..</saptrnbnd:OptimizedXMLTransfer>    -->
            <!--        <sapattahnd:Enabled xmlns:sapattahnd="http://www.sap.com/710/features/attachment/">..</sapattahnd:Enabled>    -->
            <textMessageEncoding messageVersion="Soap11" />

            <httpsTransport authenticationScheme="Basic"  />


          </binding>
        </customBinding>
      </bindings>
        <client>
            <endpoint address="http://mydomain:8080/sap/bc/srt/rfc/sap/zws_harmonizacao/010/zws_harmonizacao/zws_harmonizacao"
                binding="customBinding" bindingConfiguration="ZWS_HARMONIZACAO"
                contract="ServiceReference1.ZWS_HARMONIZACAO" name="ZWS_HARMONIZACAO" />
        </client>

    </system.serviceModel>
</configuration>

谁能帮帮我? 提前致谢

最佳答案

您正在指定 httpsTransport在绑定(bind)中,但在您提供的端点定义中 http作为协议(protocol)。正如评论中所建议的那样,尝试更改 <endpoint address="http://...https

关于C# 提供的 URI scheme 'http' 无效;预计 'https',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21779311/

相关文章:

c# - 如何从 C# 中的 app.config 获取一些元素?

android - 在 SharedPreferences 中存储和检索目录 Uri

asp.net-core - Blazor 项目中出现 "No connection could be made because the target machine actively refused it."错误

c# - ListView 中 MVC 5 的下拉列表(Viewmodel 的 IEnumerable)

c# - 如何以编程方式发现系统上映射的网络驱动器及其服务器名称?

android - 我怎么知道 Uri 是否为空?

c# - 你如何使用 c# 4.0 app.config 中的部分?

c# - dotnet 4.5 的混合模式装配问题

c# - 使用 Linq 从数据库中获取项目的最小值和最大值

c# - 不能在同一个类中使用声明的字典?