如何调用基于Basic authentication/Digest authentication/windows authencation验证模式并且需提供客户端certificate的web ser...

本文介绍了在使用IIS承载的Web服务时,如何通过基本认证或摘要认证等方式进行客户端认证的过程。主要内容包括如何生成代理类及如何提交客户端证书和凭据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前言:

当客户端掉用承载在IIS中基于basic authentication/digest authentication等等非anonymous验证模式时,客户端必须提供相应的credential.

主要注意点:

1. 如何generate 代理类

在利用wsdl command时,必须提供连接到web service上的用户名和密码才能generate proxy,其语法如下:

wsdl  http://webservice-uri/webservice.asmx /username:yourusername /password:yourpassword

2.如何在client application递交client credential和certificate.

为了提交client 的credential, 我们必须创建一个客户端的credential,然后随proxy instance一起递交到server端以便验证,如下所时:

Service1 proxy = new Service1();

System.Net.NetworkCredential credential = new System.Net.NetworkCredential("yourusername", "yourpassword", "yourdomain");

 proxy.Credentials = credential;

然后我们需要指定客户端的certificate(public-key 部分),如下: 

 System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate("yourcertificate-publickey.cer");

proxy.ClientCertificates.Add(cert);

这样的话,客户端就提供了credential和certificate并一起提交之server了 :)当然以上所作的一切,前提条件是web service 所在的server是配置成了基于basic/digest authencation+certificate模式。

转载于:https://www.cnblogs.com/Winston/archive/2008/11/11/1331125.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值