【发布时间】:2010-10-29 15:35:53
【问题描述】:
我有一个内置于 .NET 4.0 的 WCF Web 服务,该服务配置为在每次调用时都需要用户名/密码,并在行为中使用服务器证书来加密请求。它目前使用 wsHttpBinding。我有一个 .NET 4 实用程序应用程序,它可以让我很好地调用这个 WCF Web 服务上的方法。
我需要从 .NET 2.0 类库中调用此服务。该库位于 VS 2010 中,但针对 .NET 2.0 - 我想简单地切换到 .NET 4.0,但由于政治原因和时间限制不能。因此,从我目前所读到的内容来看,现在使用的 wsHttpBinding 和服务器证书是不可能的。
通过阅读点点滴滴,我做了以下事情:
- 更改了要使用的绑定 基本HttpBinding
- 从行为中删除了对服务器证书的提及
- 已安装并 在类库上启用 WSE 项目。
- 尝试在 .NET 2.0 winforms 应用程序中使用 WCF Web 服务方法 - 史诗般的失败!!
不管我如何在服务器端配置绑定 HTTPS 是不可接受的;让它让我调用它的唯一方法是使用“无”的安全模式,grrrghhh!这当然允许我调用它,但是没有提供用户名/密码详细信息,并且永远不会在 WCF 服务上设置,因此当它最终尝试保存时失败,因为用户 ID 为 0。
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false"/>
<services>
<service name="MyService.NameHere" behaviorConfiguration="NameOfMyConfigHere">
<endpoint binding="basicHttpBinding" bindingConfiguration="basicBinding" contract="DirectoryServices.IDirectorySubmitService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyBehaviourName">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="basicBinding" maxReceivedMessageSize="5242880">
<readerQuotas maxStringContentLength="5242880"/>
<security mode="None">
<transport clientCredentialType="Basic" proxyCredentialType="Basic" />
<message clientCredentialType="UserName"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
如果有人能帮我找出正确的魔法胡言乱语,我将不胜感激。
我要做的就是调用一个提供用户名/密码的 WCF Web 方法,并让它使用 SSL 进行加密。该服务在 IIS 上运行。客户端是一个winforms应用。
【问题讨论】:
标签: .net-2.0 wcf wcf-binding wcf-security class-library