.NET WCF客户端程序可以调用现有的(供应商提供的)使用WS-Security进行登录的.asmx web服务吗?
在我们的例子中,供应商提供了一个带有WS-Security的.asmx web服务。我们将首先尝试使用SOAPUI和WCFTestHarness或WCFTestClient来访问它。如果可能的话,我宁愿使用WCF。
谢谢,
尼尔·沃尔特斯
发布于 2009-10-28 00:17:45
是的,完全正确。WCF对WS-Security有很好的支持。服务需要什么样的令牌来进行身份验证?
假设只是用户名/密码,您只需将绑定配置为在客户端凭据类型为UserName的情况下使用TransportWithMessageCredential安全性(注意:您必须使用HTTPS来完成此操作)。首先,像这样定义一个绑定:
<basicHttpBinding>
<binding name=“MyBinding”>
<security mode=“TransportWithMessageCredential”>
<transport clientCredentialType=“None” />
<message clientCredentialType=“UserName” />
</security>
</binding>
</basicHttpBinding>然后配置您的终结点以使用此绑定:
<endpoint address="https://somewhere.com/TargetService.asmx" binding="basicHttpBinding" bindingConfiguration="MyBinding" />然后在运行时,假设您正在使用生成的代理(即ClientBase),您只需像这样设置客户端凭据:
TargetServiceClient client = new TargetServiceClient();
client.Credentials.UserName.UserName = "myusername";
client.Credentials.UserName.Password = "mypassword";https://stackoverflow.com/questions/1631721
复制相似问题