應用 WSDK - 實踐 Web Services 的數字簽名 小氣的神 2002-12-05 Article Type: In-Depth 難度等級: 8.2/9 版本: 1.36 生成客戶端部分 1. 創建一個 WinForm 的 Windows Ap" name="description" />

應用WSDK-實踐WebServices的數字簽名(下)

發表于:2007-05-25來源:作者:點擊數: 標簽:實踐WSDK-數字簽名應用webservices
MI LY: 宋體; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">應用 WSDK - 實踐 Web Services 的數字簽名 小氣的神 2002-12-05 Article Type: In-Depth 難度等級: 8.2/9 版本: 1.36 生成客戶端部分 1. 創建一個 WinForm 的 Windows Ap

MILY: 宋體; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">應用WSDK 實踐Web Services的數字簽名

 


小氣的神

2002-12-05

 

Article Type: In-Depth 

難度等級:8.2/9       

版本:1.36

 

 

生成客戶端部分

1.      創建一個WinFormWindows 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

歡迎訪問我的WebSitewww.dotNETTools.org

 

 

原文轉自:http://www.anti-gravitydesign.com

評論列表(網友評論僅供網友表達個人看法,并不表明本站同意其觀點或證實其描述)
国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97