我有一个托管在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时,它会给我这个错误。
发布于 2009-11-07 06:33:23
您使用下面的代码将安全性设置为传输模式,即HTTPS:
wb.Security.Mode = WebHttpSecurityMode.Transport;
baseAddress
的值是HTTPS还是HTTPS地址?
https://stackoverflow.com/questions/1690784
复制相似问题