我已经创建并测试了 WCF 服务,一切正常。
当我部署到 TEST 环境并尝试打开 https://my.site/myapp/EnrollmentService.svc我收到错误消息:
Could not find a base address that matches scheme http for the endpoint with binding MetadataExchangeHttpBinding. Registered base address schemes are [https].
互联网向我展示了我需要添加更多配置选项:
http://www.codeproject.com/KB/WCF/7stepsWCF.aspx
我在服务 web.config 文件中添加了一些设置。现在它看起来像以下方式:
<system.serviceModel>
<services>
<service name="McActivationApp.EnrollmentService" behaviorConfiguration="McActivationApp.EnrollmentServicBehavior">
<endpoint
address="https://my.site/myapp/EnrollmentService.svc"
binding="basicHttpBinding"
bindingConfiguration="TransportSecurity"
contract="McActivationApp.IEnrollmentService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="McActivationApp.IEnrollmentService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="McActivationApp.EnrollmentServicBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
实际上,我已经添加了“绑定(bind)”部分并为我的端点指定了它。
但这并没有改变...
请指教,我需要做什么。非常感谢!
附言使用 https 和 http 资源的 WCF 服务有什么不同吗?
最佳答案
您已经获得了应该更改为 https 的 http 元数据端点,如下所示。
<serviceMetadata httpsGetEnabled="True"/>
此外,如果没有必要,您应该从生产中删除 mex 和 https 元数据端点作为最佳实践。
关于https - https环境下的WCF服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4651896/