18
我有一個REST風格的Web服務託管在IIS 6.0中,我可以在瀏覽器中瀏覽服務。當我試圖通過客戶端控制檯應用程序來訪問相同的服務,這是給我下面的錯誤:提供URI scheme'http'無效;預計'https'
"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的,它給了我這個錯誤。
help plz。提前致謝。
該值是Http地址。 –
這就是問題所在。你指定你想要一個安全的傳輸,但HTTP不是一個安全的傳輸。 –
謝謝你的回答。 –