gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 23:02:54 24 4
gpt4 key购买 nike

我正在使用带有 basicHttpBinding 的自定义 UserNamePasswordValidator 开发 WCF 服务。但是,此配置仅适用于 HTTPS 绑定(bind)。由于 Visual Studio 2010 的内置 Web 服务器不支持 https,我该如何测试我的自定义验证器?我不断收到 Could not find a base address that matches scheme https for the endpoint with binding BasicHttpBinding。已注册的基址方案是 [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>

最佳答案

使用 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

关于c# - 如何在 VS2010 内置 Web 服务器中使用 TransportWithMessageCredential 测试 WCF 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6089927/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com