【发布时间】:2018-10-08 02:41:51
【问题描述】:
我在使用 wsHttpBinding 和 Https 基地址设置 WCF 服务时遇到问题。
真正的问题是在客户端测试 WCF 中定义 mex 时:
错误:无法从
https://localhost:8722/Design_Time_Addresses/_20180420_WcfServiceLibraryTest/Service1/mex
如果这是您有权访问的 Windows (R) Communication Foundation 服务,请检查您是否已在指定地址启用元数据发布。
有关启用元数据发布的帮助,请参阅位于 http://go.microsoft.com/fwlink/?LinkId=65455 的 MSDN 文档。
App.config:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="NewBehavior0"> <!-- Error: Cannot optain metadata -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="NewBehavior1"> <!-- Error: Cannot Find Cert -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<serviceCertificate findValue="BadThumbprint" x509FindType="FindByThumbprint" storeLocation="LocalMachine" storeName="My"/>
</serviceCredentials>
</behavior>
<behavior name="NewBehavior2"> <!-- Error: Cannot optain metadata -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<serviceCertificate findValue="GoodThumbprint" x509FindType="FindByThumbprint" storeLocation="LocalMachine" storeName="My"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="wsHTTPBindingConf">
<security mode="Transport">
<!--<message clientCredentialType="None" />-->
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="NewBehavior0" name="_20180420_WcfServiceLibraryTest.Service1">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHTTPBindingConf"
name="WCFEndpoint" contract="_20180420_WcfServiceLibraryTest.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" bindingConfiguration=""
name="mexEndPoint" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="https://localhost:8722/Design_Time_Addresses/_20180420_WcfServiceLibraryTest/Service1/" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
阅读 SO 并尝试我发现的所有东西,我尝试了很多配置。但没有一个显示出值得一提的进展。而且看起来更像,我不知道。 使用 wsHttpBinding 使最基本的 Ws 工作(在 SoapUi 中编译 + 可测试)的正确配置是什么?
【问题讨论】:
-
无 Https 绑定因基于 https 的地址而失败。每个 Https 绑定都会被拒绝。
-
您尝试
WCF Service Configuration Editor(来自Tools菜单)还是右键单击App.config文件并选择Edit WCF Configuration? -
你的本地机器上有证书吗?
-
@Tim,是的,尝试使用真实证书和来自内部 PKI 的证书。
-
@HemidAbbasov,起初我使用工具界面阅读文档并尝试自己制作。老实说,这是第 6 个尝试从头开始创建的项目。
标签: c# web-services wcf wcf-security