我有一個REST服務。該服務需要使用http和https。 我試着在我的web.config文件中添加兩個端點。REST服務WebHttpBinding與Http和Https
找不到匹配方案HTTPS在 端點結合的WebHttpBinding基址:但是當我嘗試瀏覽我的服務通過HTTP我得到這個錯誤。註冊的基地址方案 是[http]。
找不到與綁定的WebHttpBinding端點符合計劃http的基址:
,當我試圖瀏覽通過https我得到這個錯誤。註冊的基地址方案是[https]。
如果我從我的配置文件中刪除了一個端點,那麼http和https服務都可以正常工作。 我檢查了此鏈接:WebHttpBinding with Http and Https 但是,當我從我的配置文件中刪除端點時,http和https服務在Web瀏覽器上運行時沒有任何錯誤。但是當我嘗試在此服務它會調用我的方法之一(在其他客戶端工具):
500內部服務器錯誤。
如何通過http和https運行此服務而沒有任何錯誤?
我的配置文件是這樣的:
<system.serviceModel>
<protocolMapping>
<add scheme="http" binding="webHttpBinding" bindingConfiguration="webHttpBinding"/>
<add scheme="https" binding="webHttpBinding" bindingConfiguration="webHttpsBinding"/>
</protocolMapping>
<bindings>
<webHttpBinding>
<binding name="webHttpBinding">
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" />
</security>
</binding>
<binding name="webHttpsBinding">
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="MyProject.MyService" behaviorConfiguration="serviceBehavior">
<endpoint address="" binding="webHttpBinding" behaviorConfiguration="web" bindingConfiguration="webHttpBinding" contract="MyProject.IMyService" />
<endpoint address="" binding="webHttpBinding" behaviorConfiguration="web" bindingConfiguration="webHttpsBinding" contract="MyProject.IMyService" />
<!--<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />-->
<!--<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>-->
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceAuthorization serviceAuthorizationManagerType="MyProject.RestAuthorizationManager, MyProject"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
你是否設法解決了這個問題? – Mese