C#提供的URI方案'http'无效;预期'https'

问题描述 投票:9回答:5

我在调用我的Web服务的方法时遇到此错误,我不知道该怎么做:s

这是例外细节:

{“提供的URI方案'http'无效;预期'https'。\ r \ n参数名称: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>

谁能帮我?非常感谢提前

c# uri app-config
5个回答
6
投票

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


3
投票

我已经改变了绑定的配置,如下所示:

 var binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
 var address = new EndpointAddress(url);
 var client = new MobileServiceClient.MobileServiceClient(binding, address);

端点地址如下:

http://server101.local/MobileService.svc

它有效。


1
投票

我和一个项目有同样的问题。只需在您的配置文件中更改该行:

<httpsTransport authenticationScheme="Basic"  />

<httpTransport authenticationScheme="Basic"  />

一切都好,因为你的端点是http。


1
投票

从运输变为无

  1. 如果配置是代码的一部分

BasicHttpSecurityMode.Transport到BasicHttpSecurityMode.None

2.如果配置是web.config的一部分

<security mode="Transport"> </security>

<security mode="None">  
</security>

-1
投票

[已解决]从传输更改为无如果配置是代码的一部分

BasicHttpSecurityMode.Transport到BasicHttpSecurityMode.None

© www.soinside.com 2019 - 2024. All rights reserved.