2010-05-30 56 views
4

我想消费位于https://TestServices/ServiceList.asmx的网络服务。当我尝试将服务引用添加到我的C#库类项目我app.config文件看起来像如下:如何通过https消费网络服务

<system.serviceModel> 
     <bindings> 
      <basicHttpBinding> 
       <binding name="TestServicesSoap" closeTimeout="00:01:00" openTimeout="00:01:00" 
        receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" 
        bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
        maxBufferSize="50000000" maxBufferPoolSize="524288" maxReceivedMessageSize="50000000" 
        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
        useDefaultWebProxy="true"> 
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
         maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
        <security mode="None"> 
         <transport clientCredentialType="None" proxyCredentialType="None" 
          realm=""> 
         </transport> 
         <message clientCredentialType="UserName" algorithmSuite="Default" /> 
        </security> 
       </binding> 
      </basicHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="http://TestServices/ServiceList.asmx" 
       binding="basicHttpBinding" bindingConfiguration="TestServicesSoap" 
       contract="TestServices.TestServicesSoap" name="TestServicesSoap" /> 
     </client> 
    </system.serviceModel> 

即使当我试图出于某种原因终点地址添加服务参考https://TestServices/ServiceList.asmx仍然指向http://TestServices/ServiceList.asmx。我尝试将http更改为https,但出现以下错误:

提供的URI方案'https'无效;预计'http'。 参数名称:via

在https上使用Web服务的正确方式是什么?

+0

[提供的URI方案的“https”的可能的复制是无效;预计'http'。参数名称:via](https://stackoverflow.com/questions/2435823/the-provided-uri-scheme-https-is-invalid-expected-http-parameter-name-via) – paulsm4 2017-07-25 22:59:31

回答

1

在绑定你<security mode="None" ...,其中,因为我相信,如果你想使用https,则需要将其设置为<security mode="Transport" ...