首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在VS2010内置web服务器上用TransportWithMessageCredential测试WCF服务

问如何在VS2010内置web服务器上用TransportWithMessageCredential测试WCF服务
EN

Stack Overflow用户
提问于 2011-05-23 02:35:57
回答 2查看 1.7K关注 0票数 5

我正在开发一个带有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,错误就会消失,但不会调用验证器。

下面是我的配置。

代码语言:javascript
复制
<?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>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-05-23 02:39:10

使用IIS进行此测试。

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

如果尚未安装IIS,请先安装它:How to install IIS.

您需要使用比Windows Home更高的Windows版本。

您还需要为您的网站创建自签名证书。这在IIS7中很容易做到:Self-Signed Certificates on IIS 7 – the Easy Way and the Most Effective Way

票数 4
EN

Stack Overflow用户

发布于 2011-05-23 02:40:52

您不能在Cassine (VS2010中的内置web服务器)中测试此类WCF服务。您必须使用本地IIS或安装VS2010HTTPS和download IIS Express,这是用于开发的轻量级web服务器(can replace Cassini in VS,支持带有自签名证书的SP1 )。IIS Express不需要任何特定的Windows版本,它可以在Windows XP之后的所有版本上运行,但它提供了与IIS 7.5相同的功能。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6089927

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档