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

时间:2014-02-14 12:22:19

标签: c# uri app-config

我在调用我的网络服务方法时收到此错误,我不知道该怎么办: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>

任何人都可以帮助我吗? 非常感谢提前

5 个答案:

答案 0 :(得分:6)

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

答案 1 :(得分:3)

我已经改变了绑定的配置:

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

端点地址如下:

http://server101.local/MobileService.svc

它有效。

答案 2 :(得分:1)

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

<httpsTransport authenticationScheme="Basic"  />

<httpTransport authenticationScheme="Basic"  />

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

答案 3 :(得分:1)

从运输更改为无

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

BasicHttpSecurityMode.Transport BasicHttpSecurityMode.None

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

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

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

答案 4 :(得分:-1)

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

  

BasicHttpSecurityMode.Transport 至    BasicHttpSecurityMode.None