应用WSDK - 实践Web Services的数字签名


小气的神

2002-12-05

Article Type: In-Depth

难度等级:8.2/9

版本:1.36

生成客户端部分

1.      创建一个WinForm的Windows Application

2.      创建用户界面

3.      加入Web Services的引用。

cd/tmp

wsdl /l:cs /out:SignSOAPWebServices.cs /n:SignSOAPSvc /urlkey:SecurityURL http://localhost/Myproject/WSDK/SignSOAPUsingName/SignSOAPusingName.asmx?WSDK

然后点击Add Exit Item->选择Tmp目录->加入SignSOAPWebServices.cs 文件确定。

4.      修改SignSOAPWebServices.cs 文件

加入Microsoft.WebServices.DLL 引用和下面的代码

using Microsoft.Web.Services.Security ;

using Microsoft.Web.Services;

并将 System.Web.Services.Protocols.SoapHttpClientProtocol 替换为

Microsoft.Web.Services.WebServicesClientProtocol

5.      在Form1中加入调用 Web Services的代码

private void btnCallWebservice_Click(object sender, System.EventArgs e)

{

try

{

string username = Environment.UserName ;

byte[] passwordBytes = System.Text.Encoding.UTF8.GetBytes( username ) ;

Array.Reverse( passwordBytes ) ;

string passwordEquivalent = Convert.ToBase64String( passwordBytes ) ;

UsernameToken userToken = new UsernameToken( username, passwordEquivalent, PasswordOption.SendHashed ) ;

SignSOAPSvc.SignSOAPWebServices  Svc = new SignSOAPSvc.SignSOAPWebServices() ;

Svc.RequestSoapContext.Timestamp.Ttl = 60000 ;

Svc.RequestSoapContext.Security.Tokens.Add( userToken ) ;

Svc.RequestSoapContext.Security.Elements.Add( new Signature( userToken ) ) ;

lblCallRet.Text = Svc.HelloWorld() ;

}

catch ( System.Web.Services.Protocols.SoapException soapex )

{

MessageBox.Show ( soapex.ToString() ) ;

}

catch ( Exception ex )

{

MessageBox.Show( ex.ToString() ) ;

}

}

6.      编译并运行程序

分析结果

之后我们使用 SOAP Toolkit 3.0 的Trace Utility 进行观察可以发现下面的Dump


看得出我们整个的过程是这样的:

综上所叙述,我们看到我们能够利用WSDK实现Web Services有关Security的实现,最重要的是WS-Security对于Web Services安全性方面提供了一个高层和最基本的定义。

“WS-Security is flexible and designed to be used as the basis for securing XML Web services through the combination of a wide variety of security models, including public key infrastructure (PKI), Kerberos, and Secure Sockets Layer (SSL). Correspondingly, many types of security tokens can be propagated, such as X.509 certificates and Kerberos tickets. Additionally, the specification provides support for propagating multiple security tokens across multiple trust domains using multiple signature formats and multiple encryption technologies.”

好吧,我很愿意用这段话说明WS-Security也愿意用这段话作为本文的结束,看得出Web Services 安全性的问题非常复杂和有趣,我想还有许多许多新的内容在等着我们。

相关文件下载: [WSDKSignSOAPUsing.zip 26K]


特别:

本文原创,CSDN署名首发,所有文字和图片版权所有。未经授权请勿传播、转载或改编。

如果有问题或建议,请发电子邮件给new2001@msn.com

欢迎访问我的WebSite:www.dotNETTools.org

应用WSDK - 实践Web Services的数字签名(下)相关推荐

  1. 应用WSDK-实现和使用DIME的Web Services(下)

    应用WSDK-实现和使用DIME的Web Services 小气的神 2002-10-20 Article Type: In-Depth 难度等级:7/9 版本:1.26 二.产生Client 消费W ...

  2. 应用WSDK-实现和使用DIME的Web Services(上)

    应用WSDK-实现和使用DIME的Web Services 小气的神 2002-10-20 Article Type: In-Depth 难度等级:7/9 版本:1.26 现在还很清晰的记得几乎是一年 ...

  3. Web services 安全实践: 基于 HTTP Basic Authentication 为 Web services 配置传输层安全机制...

    转载:http://www.ibm.com/developerworks/cn/webservices/1106_webservicessecurity/ 简介 正如"HTTP Basic ...

  4. delphi7下调用微软的Web Services的心得

    我在delphi7下调用微软的Web Services的心得.(其中服务是指返回数据集) 我在delphi7下调用微软的Web Services的心得.(其中服务是指返回数据集)        作者: ...

  5. RESTful Web Services in Spring 3(下)转载

    上一篇我主要发了RESTful Web Services in Spring 3的服务端代码,这里我准备写客户端的代码. 上篇得连接地址为:http://yangjizhong.iteye.com/b ...

  6. 轻松简单地开发Web Services 2

    XFire和其它类库 现在是最后一步了,需要得到所有必需的类库.我们怎样得到它们呢?去XFire网站,下载xfire-distribution-1.0.zip,然后解压到一个本地文件夹.复制下面的ja ...

  7. 详解Axis2实现Web Services之AXIOM篇

    AXIOM--AXis 对象模型(AXis Object Model,AXIOM)是 Apache Axis 2 的 XML 对象模型,Axiom采用pull解析方式,基于StAX(JSR173),其 ...

  8. 用 Amazon Web Services 进行云计算,第 2 部分: 用 Amazon Simple Storage Service (S3) 在云中存储数据

    用 Amazon Web Services 进行云计算,第 2 部分: 用 Amazon Simple Storage Service (S3) 在云中存储数据 简介: 学习基本的 Amazon Si ...

  9. 使用 Web Services 整合 IBM FileNet P8 BPM 与 IBM WebSphere ILOG JRules

    Ranjeeth Pasupathi, 软件工程师, IBM Ranjeeth 是 IBM India Software Labs 的一位软件开发人员.他专注于新技术.敏捷 BPM 和关系数据管理等方 ...

最新文章

  1. 在JavaScript函数中定义全局变量
  2. Java集合的概念及其相关类的简单使用
  3. centos6.9配置安装python2.7及pip
  4. Cacti 每日导出图形及流量报表 [未完成]
  5. JAVA基础:JDK、JRE、JVM的概念
  6. rabbitmq(四)、消息丢失问题
  7. 数据库技术基础:查询优化相关知识笔记
  8. C++之指向const对象的指针和const指针
  9. 应朋友死皮白咧地邀请贴一个招聘广告
  10. 交换机TFTP配置备份
  11. xp系统怎样安装传真服务器,Windowsxp系统下设置传真接收的详细步骤
  12. mysql跨库oracle查询,Oracle跨数据库查询(databaselink方式)
  13. Drilldown饼状图
  14. Google的愚人节
  15. mysql drop column_MySQL DROP COLUMN
  16. vue中全局定义mintUI中toast
  17. Es7.x使用RestHighLevelClient进行聚合操作
  18. 华为S5700-SI 系统打补丁
  19. 测试主管面试必问合集:get 与 post 的区别
  20. poi对word读取(文本和图片)、修改、保存操作及word转换为PDF

热门文章

  1. 恶意软件、恶意软件反杀技术以及反病毒技术的详细介绍
  2. 图形学 - 纹理的应用
  3. Android 实现JNI动态注册
  4. Vue2.0跨域的两种情况
  5. Centos | 官网下载Centos7详细教程
  6. Android不同手机屏幕分辨率自适应【转】
  7. 局域网网盘 构建局域网网盘(校园云盘,育网云盘,私有云盘)
  8. 图神经网络系列-知识图谱Neo4j-图神经网络案例实战
  9. 给生活一点浪漫——python实现烟花绽放
  10. TensorFlow 2——导数和微分