【发布时间】:2015-10-28 16:44:27
【问题描述】:
我将实现一个在NetHttpBinding 下工作的网络服务,以支持双工连接。但问题是我不知道如何保护它。我试过用CostumUserNamePasswordValidationMode,这是我的web.config:
<behaviors>
<serviceBehaviors>
<behavior name="Behavior1">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceCredentials>
<serviceCertificate findValue="MyWebSite"
storeLocation="LocalMachine"
storeName="My"
x509FindType="FindBySubjectName" />
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="WcfWSChat.UserNamePassValidator, WcfWSChat" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netHttpBinding>
<binding name="Binding1">
<security mode="Message">
<message clientCredentialType="UserName"/>
</security>
</binding>
</netHttpBinding>
</bindings>
<protocolMapping>
<add scheme="http" binding="netHttpBinding"/>
</protocolMapping>
<services>
<service name="WcfWSChat.WSChatService"
behaviorConfiguration="Behavior1" >
<endpoint address=""
binding="netHttpBinding"
bindingConfiguration="Binding1"
contract="WcfWSChat.IWSChatService" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
我认为问题是<security mode="Message">,每当我运行项目时,无论是在 IIS Express 还是 IIS 8.0 上,我都会收到此错误:
找不到与具有绑定 NetHttpBinding 的端点的方案 https 匹配的基地址。注册的基地址方案是 [http]。
如果我将mode 属性更改为None,我将不会再看到错误但验证不起作用!
我该如何解决这个问题?
【问题讨论】:
-
这个问题有什么进展吗?