首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >提供的URI方案“http”无效;应为“https”

提供的URI方案“http”无效;应为“https”
EN

Stack Overflow用户
提问于 2009-11-07 06:02:24
回答 1查看 91.7K关注 0票数 37

我有一个托管在IIS6.0中的RESTful网络服务,我能够在浏览器中浏览该服务。当我试图通过客户端控制台App访问相同的服务时,它给出了以下错误:

"provided URI scheme'http' is invalid; expected 'https', Parameter name: Via"

我的WebService web.config有以下设置:

<system.serviceModel>  
<services>  
  <service behaviorConfiguration="ServiceBehavior" name="TestAPI">
    <endpoint address="" behaviorConfiguration="RESTFriendly" binding="webHttpBinding" contract="ITestAPI" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>     
</services>
<behaviors>
  <endpointBehaviors>
    <behavior name="RESTFriendly">
      <webHttp />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

我的客户端应用程序有App.config,我从那里获取地址:

<appSettings>
<add key="WEBSERVICE" value="URL"/>

在Main方法中:

WebChannelFactory<ITestAPI> cf = new WebChannelFactory<IAPI>(baseAddress);
            WebHttpBinding wb =cf.Endpoint.Binding as WebHttpBinding;
            wb.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
            wb.Security.Mode = WebHttpSecurityMode.Transport;
            cf.Credentials.UserName.UserName = "usermane";
            cf.Credentials.UserName.Password = "password";

            ITestAPI channel = cf.CreateChannel();
            string msg = channel.TestMethod(); 

当它试图调用TestMethod时,它会给我这个错误。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2009-11-07 06:33:23

您使用下面的代码将安全性设置为传输模式,即HTTPS:

wb.Security.Mode = WebHttpSecurityMode.Transport;

baseAddress的值是HTTPS还是HTTPS地址?

票数 71
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1690784

复制
相关文章

相似问题

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