我已经创建并测试了WCF服务,一切正常.
当我部署到TEST环境并尝试打开https://my.site/myapp/EnrollmentService.svc时,我收到了错误消息:
无法通过绑定MetadataExchangeHttpBinding找到与端点的方案http匹配的基址.注册的基地址方案是[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>
Run Code Online (Sandbox Code Playgroud)
实际上,我添加了"bindings"部分并为我的端点指定了它.
但这没有改变......
请告知我需要做什么.非常感谢!
PS从https和http资源消耗WCF服务有什么不同吗?
Lad*_*nka 23
如果只想通过HTTPS公开服务(站点根本不支持HTTP),则不能使用依赖于HTTP的任何内容.您当前的配置公开HTTP上的帮助页面以及HTTP上的mex endpoing(错误的合同).试试这个:
<system.serviceModel>
<services>
<service name="McActivationApp.EnrollmentService" behaviorConfiguration="McActivationApp.EnrollmentServicBehavior">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="TransportSecurity" contract="McActivationApp.IEnrollmentService"/>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="McActivationApp.EnrollmentServicBehavior">
<serviceMetadata httpsGetEnabled="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>
Run Code Online (Sandbox Code Playgroud)
您有http元数据端点,应该更改为https,如下所示.
<serviceMetadata httpsGetEnabled="True"/>
Run Code Online (Sandbox Code Playgroud)
此外,如果没有必要,您应该从生产中删除mex和https元数据端点作为最佳实践.
| 归档时间: |
|
| 查看次数: |
19275 次 |
| 最近记录: |