我有一个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