我正在使用带有basicHttpBinding的自定义UserNamePasswordValidator
开发WCF服务。但是,此配置仅适用于HTTPS绑定。由于Visual Studio 2010的内置Web服务器不支持https,如何测试我的自定义验证器?我一直收到Could not find a base address that matches scheme https for the endpoint with binding BasicHttpBinding. Registered base address schemes are [http].
错误,如果我将clientCredentialType设置为none,则错误消失,但验证器不会被调用。
以下是我的配置。
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="ServiceErrorHandler" type="company.application.appserver.implementation.ServiceErrorHandlerBehaviorExtensionElement, AppSoftAppServer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
<bindings>
<basicHttpBinding>
<binding name="SimpleBinding">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="DefaultBehavior" name="company.application.appserver.implementation.AppSoftUpdate">
<endpoint address="udt" binding="basicHttpBinding" bindingConfiguration="SimpleBinding"
name="AppSoftUpdate" bindingNamespace="http://company.application/update/2011/04"
contract="company.application.appserver.interfaces.IAppSoftUpdate" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
name="AppSoftUpdateMex" bindingNamespace="http://company.application/update/2011/04"
contract="IMetadataExchange" />
</service>
<service behaviorConfiguration="DefaultBehavior" name="company.application.appserver.implementation.AppSoftTransaction">
<endpoint address="udt" binding="basicHttpBinding" bindingConfiguration="SimpleBinding"
name="AppSoftTransacao" bindingNamespace="http://company.application/transaction/2011/04"
contract="company.application.appserver.interfaces.IAppSoftTransacao" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
name="AppSoftTransacaoMex" bindingNamespace="http://company.application/transaction/2011/04"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DefaultBehavior">
<serviceMetadata httpGetEnabled="true" httpGetBinding="webHttpBinding"
httpGetBindingConfiguration="" />
<serviceDebug includeExceptionDetailInFaults="true" />
<ServiceErrorHandler />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType=" company.application.appserver.implementation.AppSoftValidacaoLogin, AppSoftAppServer" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
答案 0 :(得分:4)
使用IIS进行此测试。
打开项目属性,转到Web选项卡,单击Use local IIS
单选按钮。本手册也适用于VS2010:Using Visual Studio 2008 with IIS 7
如果尚未安装IIS,请先安装它:How to install IIS.
您需要Windows版本高于Windows Home。
您还需要为您的网站创建自签名证书。这在IIS 7中很容易做到:Self-Signed Certificates on IIS 7 – the Easy Way and the Most Effective Way
答案 1 :(得分:3)
您无法在Cassine(VS 2010中的内置Web服务器)中测试此类WCF服务。您必须使用本地IIS或安装VS 2010 SP1和download IIS Express,它是用于开发的轻量级Web服务器(can replace Cassini in VS,并支持使用自签名证书的HTTPS)。 IIS Express不需要任何特定的Windows版本,它适用于自Windows XP以来的所有版本,但它提供与IIS 7.5相同的功能。