提供URI scheme'http'是无效的;预期的“https” [英] provided URI scheme'http' is invalid; expected 'https'

查看:3637
本文介绍了提供URI scheme'http'是无效的;预期的“https”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IIS 6.0上承载一个RESTful Web服务,我能够浏览服务的浏览器。当我尝试通过客户端控制台应用程序来访问相同的服务,这是给我下面的错误:

I have a RESTful Web Service hosted in IIS 6.0, I am able to Browse the Service in browser. When i am trying to access the same service via Client console App, it is giving me the following error:

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

我的web.config文件的WebService有这样的设置:

My WebService web.config has this settings:

<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>



我的客户端应用程序管理。从那里我得到的地址配置:

My Client App has App.config from where i am getting the address :

<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的,它给了我这个错误。

When it tries to call TestMethod, it gives me this error.

帮助PLZ。 。在此先感谢

help plz. Thanks in Advance.

推荐答案

您所设置的安全运输模式,这是HTTPS,这一行:

You're setting the security to transport mode, which is HTTPS, with this line:

wb.Security.Mode = WebHttpSecurityMode.Transport;

baseAddress HTTP或HTTPS地址?

Is the value of baseAddress an HTTP or HTTPS address?

这篇关于提供URI scheme'http'是无效的;预期的“https”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆