2008年2月15日 星期五

Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http]

使用wcf的過程中,一直出現Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http]. 的錯誤。

奇怪的是,我是使用 http://localhost/service/service.svc 來測試的,為何一直有 https 的出現呢?

設定如下:

<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WindowsBinding">
<security mode="Transport">
<transport clientCredentialType="Windows" proxyCredentialType="Windows" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="IssueTracking.IssueServiceBehavior">
<serviceMetadata httpGetEnabled="true"
httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceCredentials>
<windowsAuthentication includeWindowsGroups="true" allowAnonymousLogons="false" />
</serviceCredentials>
<serviceAuthorization />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="IssueTracking.IssueServiceBehavior"
name="IssueTracking.IssueService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="WindowsBinding"
contract="IssueTracking.IIssueService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>

後來,google 了很久,才漸漸覺的,這是微軟的設計。因為 web service 是不安全的,因此會要求走 SSL。

因此,改走 basciHttpBinding ,並改成<security mode="TransportCredentialOnly">


<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="IssueTracking.IssueServiceBehavior">
<serviceMetadata httpGetEnabled="true"
httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceCredentials>
<windowsAuthentication includeWindowsGroups="true" allowAnonymousLogons="false" />
</serviceCredentials>
<serviceAuthorization />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="IssueTracking.IssueServiceBehavior"
name="IssueTracking.IssueService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicBinding"
contract="IssueTracking.IIssueService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>

就ok 了

沒有留言:

Share with Facebook