Wcf自定义用户名PasswordValidationMode不';我不能在IIS express工作
我试图用自定义用户名PasswordValidationMode服务创建一个安全的wcf,但我遇到了一些问题(持续了三天)。我的安装环境是visual studio 2012、.net 4.0、IIS Express。我在主机中的服务模式是:Wcf自定义用户名PasswordValidationMode不';我不能在IIS express工作,wcf,ssl,iis-express,Wcf,Ssl,Iis Express,我试图用自定义用户名PasswordValidationMode服务创建一个安全的wcf,但我遇到了一些问题(持续了三天)。我的安装环境是visual studio 2012、.net 4.0、IIS Express。我在主机中的服务模式是: <system.serviceModel> <bindings > <wsHttpBinding> <binding maxReceivedMessageSize="65536"
<system.serviceModel>
<bindings >
<wsHttpBinding>
<binding maxReceivedMessageSize="65536" name="WsHttpBinding_ISurveyService">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName"/>
</security>
<readerQuotas maxArrayLength="65536"
maxBytesPerRead="65536"
maxStringContentLength="65536"/>
</binding>
</wsHttpBinding>
</bindings>
<services>
<!--name= "namespace.serviceClass"-->
<service name="Rids.Services.SurveyService" behaviorConfiguration="Rids.WcfHost.ServiceBehavior" >
<!--contract= "namespace.serviceClass"-->
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="WsHttpBinding_ISurveyService"
contract= "Rids.Services.ISurveyService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="https://localhost" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Rids.WcfHost.ServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="None" />
</clientCertificate>
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="Rids.WcfHost.ServiceUserValidator,Rids.WcfHost"/>
<!--Specify the Certificate-->
<serviceCertificate findValue="rids_2014.04.15"
storeLocation="LocalMachine"
x509FindType="FindBySubjectName"
storeName="My"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
--
但是,如果我从行为(name=“Rids.WcfHost.servicebhavior”
part)中删除名称标记,并从服务(behaviorConfiguration=“Rids.WcfHost.servicebhavior”
part)中删除行为配置标记;然后我可以添加服务(https://localhost:44300/SurveyService.svc
)发送到客户端,无错误。这也不能解决我的问题
向客户端添加服务后,客户端服务模型如下所示:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ISurveyService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:11067/SurveyService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISurveyService"
contract="Survey.ISurveyService" name="BasicHttpBinding_ISurveyService" />
</client>
</system.serviceModel>
我看到的问题是:
https://localhost:44300/SurveyService.svc
李>
https://localhost:44300/
我遇到了很多问题。有什么建议或解决办法吗?提前谢谢。我学会了如何解决这个问题。我是在VisualStudio2012中使用EditWcfConfiguration工具创建的,如下所述 首先,在主机项目属性中将“启用SSL”的属性设置为true。在此属性下,将自动生成ssl url(例如“
https://localhost:44300/
”)然后,右键单击主体项目并选择属性。在“项目属性Web”选项卡中,选中“使用本地IIS Web服务器”,然后选中“使用IIS Express”
--
在host project网络配置中,右键单击,然后选择编辑WCFConfiguration:
在EditWcfConfiguration中,首先添加服务,然后为服务的端点添加绑定,然后为服务添加行为
1-添加服务
- 在主机的bin文件夹中浏览服务类型
- 选择通信模式为HTTP
- 选择高级Web服务互操作性作为单工通信
- 把地址留空
- 添加行为配置后;选择行为配置
- 添加绑定配置后;打开服务的端点,然后选择binding(customBinding)和bindingConfiguration
- 重命名绑定以在服务的BehaviorConfiguration属性(例如“custom_binding”)中使用
- 添加安全性、httpsTransport标签
- 在安全标签下选择“AuthenticationMode”作为“UserNameOverTransport”
- 重命名要在服务端点的BindingConfiguration属性中使用的行为(例如安全行为)
- 添加serviceCredentials、serviceMetadata和serviceDebug标记
- 对于serviceCredentials标记属性: a-)选择customUserNamePasswordValidatorType作为验证器类及其命名空间(例如:“Rids.WcfHost.ServiceUserValidator,Rids.WcfHost”) b-)选择userNamePasswordValidationMode作为自定义
- 对于clientCertificate标记(在serviceCredentials标记下)属性,选择certificateValidationMode作为None,选择revocationMode作为NoCheck
- 对于serviceMetadata标记属性,将HttpsGetEnabled设置为True
- 对于serviceDebug标记属性,将includeExceptionDetailInFaults设置为True
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="safe_behavior">
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="None" revocationMode="NoCheck" />
</clientCertificate>
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="Rids.WcfHost.ServiceUserValidator, Rids.WcfHost" />
</serviceCredentials>
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="custom_binding">
<security authenticationMode="UserNameOverTransport" />
<httpsTransport />
</binding>
</customBinding>
</bindings>
<services>
<service behaviorConfiguration="safe_behavior" name="Rids.Services.Services.SurveyService">
<endpoint address="" binding="customBinding"
bindingConfiguration="custom_binding" contract="Rids.Services.Services.ISurveyService" />
</service>
</services>
</system.serviceModel>
非常感谢。我遇到了一个根本没有进行验证的问题。原来我缺少services.service.endpoint
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="safe_behavior">
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="None" revocationMode="NoCheck" />
</clientCertificate>
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="Rids.WcfHost.ServiceUserValidator, Rids.WcfHost" />
</serviceCredentials>
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="custom_binding">
<security authenticationMode="UserNameOverTransport" />
<httpsTransport />
</binding>
</customBinding>
</bindings>
<services>
<service behaviorConfiguration="safe_behavior" name="Rids.Services.Services.SurveyService">
<endpoint address="" binding="customBinding"
bindingConfiguration="custom_binding" contract="Rids.Services.Services.ISurveyService" />
</service>
</services>
</system.serviceModel>