如何在VS2010内置Web服务器中使用TransportWithMessageCredential测试WCF服务

Pas*_*cal 5 c# wcf visual-studio-2010

我正在UserNamePasswordValidator使用带有basicHttpBinding 的自定义开发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>
Run Code Online (Sandbox Code Playgroud)

Ale*_*Aza 4

使用 IIS 进行此测试。

\n\n

打开项目属性,转到 Web 选项卡,点击Use local IIS单选按钮。本手册也适用于 VS2010:Using Visual Studio 2008 with IIS 7

\n\n

如果尚未安装 IIS,请先安装:如何安装 IIS。

\n\n

您需要拥有高于 Windows Home 的 Windows 版本。

\n\n

您还需要为您的网站创建自签名证书。这在 IIS 7 中很容易做到:IIS 7 \xe2\x80\x93 上的自签名证书,简单方法和最有效方法

\n