隨筆-128  評論-55  文章-5  trackbacks-0
            WS-ResourceLifetime協議

          WS-ResourceLifetime協議定義了WS-Resource的資源銷毀機制,其中包括資源的立即銷毀和資源的調度銷毀。立即銷毀使得客戶可以顯示地要求對特定的WS-Resource進行銷毀,從而釋放該WS-Resource占用的系統資源。調度銷毀則允許客戶通過設定某個WS-Resource的預定銷毀時間(Termination Time),由引擎負責在其生命周期結束時對其進行銷毀。在每一種情況都要明白,只有 WS-Resource 有狀態資源和 Web 服務的關聯—被銷毀。資源本身和 Web 服務都沒有受到影響

          另外值得注意的是此協議并沒有定義WS-Resource的創建方式。

          1.1.1.1    創建WS-Resource

          我們可以發送“create”消息:

          <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">

              <SOAP-ENV:Header/>

              <SOAP-ENV:Body>

                  <createSatellite  xmlns="http://example.com/satellite"/>

              </SOAP-ENV:Body>

          </SOAP-ENV:Envelope>

          結果是一個 SOAP 消息,其中包含對操作創建的 WS-Resource 的端點引用

          <SOAP-ENV:Envelope  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">

              <SOAP-ENV:Header/>

              <SOAP-ENV:Body>

                 <wsa:EndpointReference  xmlns:wsa="http://www.w3.org/2005/02/addressing"

                       xmlns:sat="http://example.org/satelliteSystem">

                     <wsa:Address> http://example.com/satellite</wsa:Address>

                     <wsa:ReferenceProperties>

                         <sat:SatelliteId>SAT9928</sat:SatelliteId>

                     </wsa:ReferenceProperties>

                 </wsa:EndpointReference>

              </SOAP-ENV:Body>

          </SOAP-ENV:Envelope>

          該端點引用惟一地識別正在談論的 WS-Resource,所以我們可以使用它來銷毀該 WS-Resource

          1.1.1.2    立即銷毀WS-Resource

          當我們準備銷毀 WS-Resource 時,可以使用它的端點引用來創建 SOAP 請求:

          <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"

                xmlns:sat="http://example.org/satelliteSystem"

                xmlns:wsa="http://www.w3.org/2005/02/addressing"

                xmlns:wsrl="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.xsd">

              <SOAP-ENV:Header>

                 <wsa:Action>

                     http://docs.oasis-open.org/wsrf/2004/06/WS-ResourceLifetime/Destroy

                 </wsa:Action>

                 <wsa:To SOAP-ENV:mustUnderstand="1">

                      http://example.com/satellite

                 </wsa:To>

                 <sat:SatelliteId>SAT9928</sat:SatelliteId>

              </SOAP-ENV:Header>

              <SOAP-ENV:Body>

                 <wsrl:Destroy />

              </SOAP-ENV:Body>

          </SOAP-ENV:Envelope>

           

          假設一切正常,我們會收到確認消息:

          <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"

                 xmlns:sat="http://example.org/satelliteSystem"

                 xmlns:wsa="http://www.w3.org/2005/02/addressing"

               xmlns:wsrl="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.xsd">

              <SOAP-ENV:Header>

                 <wsa:Action>

                      http://docs.oasis-open.org/wsrf/2004/06/WS-ResourceLifetime/DestroyResponse

                 </wsa:Action>

                 <wsa:To SOAP-ENV:mustUnderstand="1">

                      http://example.com/myClient

                 </wsa:To>

              </SOAP-ENV:Header>

              <SOAP-ENV:Body>

                 <wsrl:DestroyResponse />

              </SOAP-ENV:Body>

          </SOAP-ENV:Envelope>

          這似乎不怎么像確認消息,但是只要收到它,就可以知道一切正常。如果不是一切正常,就會得到 WSRF 故障:WS-ResourceLifetime 中所討論的一條 fault 消息。如果在 WS-Resource 銷毀后還試圖訪問它,也會得到故障消息。

          我們也可以安排 WS-Resource 在以后銷毀。

          1.1.1.3    調度銷毀WS-Resource

          我們并不總是想要當場銷毀 WS-Resource。在有些情況下,我們只是想要保持 WS-Resource 活躍一段特定的時間,然后再讓它銷毀。為了做到這一點,我們需要給 WS-Resource 附加一個 TerminationTime 屬性,這意味著將它添加到資源屬性文檔。對于我們的人造衛星,意味著類似下面的這些東西:

          <satProp:GenericSatelliteProperties

              xmlns:satProp="http://example.com/satellite"

              xmlns:counterProp="http://example.com/satellite/CounterSatelliteProperties"

              xmlns:wsrl="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.xsd">

             <satProp:latitude>30.3</satProp:latitude>

             <satProp:longitude>223.2</satProp:latitude>

             <satProp:altitude>47700</satProp:altitude>

             <satProp:pitch>49</satProp:pitch>

             <satProp:yaw>0</satProp:yaw>

             <satProp:roll>32</satProp:roll>

             <satProp:focalLength>

                 21999992

             </satProp:focalLength>

             <satProp:currentView>

                 http://example.com/satellite/2239992333.zip

             </satProp:currentView>

             <counterProp:currentCount>

                 92828

             </counterProp:currentCount>

             <wsrl:TerminationTime>

                 2005-12-31T12:00:00

             </wsrl:TerminationTime>

             <wsrl:CurrentTime>2005-2-15T03:24:57</CurrentTime>

          </satProp:GenericSatelliteProperties>

          如果像本例中一樣,沒有指定時區,就會假設是格林威治標準時間。

          注意,除了 TerminationTime,我們還添加了 CurrentTime。該屬性使我們不必同步時鐘,下面您就會看到。

           

          獲得 CurrentTime TerminationTime

          由于不同系統上的客戶機,因而潛在地存在時鐘同步的嚴重問題。例如,假設我們想要指定剛才創建的人造衛星 WS-Resource 應該在 4 小時后終止。選擇一個相對于客戶機的時間將會成為問題,因為在預定銷毀情況下,實際上是由服務器銷毀引用的。

          幸運的是,WS-Resource 帶有自己的“當前時間”。因為它是資源屬性文檔的一部分,所以我們可以像請求任何其他屬性一樣請求它:

          <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"

                xmlns:sat="http://example.org/satelliteSystem"

                xmlns:wsa="http://www.w3.org/2005/02/addressing"

                xmlns:wsrp="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.xsd"

                xmlns:wsrl="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.xsd">

              <SOAP-ENV:Header>

                 <wsa:Action>

                    http://docs.oasis-open.org/wsrf/2004/06/WS-ResourceProperties/GetMultipleResourceProperties

                 </wsa:Action>

                 <wsa:To SOAP-ENV:mustUnderstand="1">

                      http://example.com/satellite

                 </wsa:To>

                 <sat:SatelliteId>SAT9928</sat:SatelliteId>

              </SOAP-ENV:Header>

              <SOAP-ENV:Body>

                 <wsrp:GetMultipleResourceProperties>

                    <wsrp:ResourceProperty>wsrl:CurrentTime</wsrp:ResourceProperty>

                    <wsrp:ResourceProperty>wsrl:TerminationTime</wsrp:ResourceProperty>

                 </wsrp:GetMultipleResourceProperties>

              </SOAP-ENV:Body>

          </SOAP-ENV:Envelope>

           

          在本例中,我們請求了 CurrentTime TerminationTime,所以響應中包含了它們倆:

          <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"

                 xmlns:sat="http://example.org/satelliteSystem"

                 xmlns:wsa="http://www.w3.org/2005/02/addressing"

                xmlns:wsrp="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.xsd"

                xmlns:wsrl="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.xsd">

              <SOAP-ENV:Header>

                 <wsa:Action> http://docs.oasis-open.org/wsrf/2004/06/WS-Resour

          ceProperties/GetMutlipleResourcePropertiesResponse

                 </wsa:Action>

                 <wsa:To SOAP-ENV:mustUnderstand="1">

                      http://example.com/myClient

                 </wsa:To>

              </SOAP-ENV:Header>

              <SOAP-ENV:Body>

                 <wsrp:GetMultipleResourcePropertiesResponse>

                    <wsrl:CurrentTime>2005-2-15T03:24:57</wsrl:CurrentTime>

                    <wsrl:TerminationTime>2005-2-15T03:30:00</wsrl:TerminationTime>

                 </wsrp:GetMultipleResourcePropertiesResponse>

              </SOAP-ENV:Body>

          </SOAP-ENV:Envelope>

           

          在應用程序中,然后我們可以使用 CurrentTime 來確定和設置新的 TerminationTime

          注意,盡管我們可以像請求任何其他資源屬性一樣請求 CurrentTime TerminationTime,但是不能像設置任何其他資源屬性一樣設置它們。CurrentTime 是只讀的,而 TerminationTime 必須使用我們下面將會看到的消息來設置

           

          設置新的 TerminationTime

          一旦為 TerminationTime 確定了適當的值,我們就可以發送 SetTerminationTime 消息了:

          <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"

                xmlns:sat="http://example.org/satelliteSystem"

                xmlns:wsa="http://www.w3.org/2005/02/addressing"

                xmlns:wsrp="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.xsd"

                xmlns:wsrl="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.xsd">

              <SOAP-ENV:Header>

                 <wsa:Action>

                     http://docs.oasis-open.org/wsrf/2004/06/WS-ResourceLifetime/SetTerminationTime

                 </wsa:Action>

                 <wsa:To SOAP-ENV:mustUnderstand="1">

                      http://example.com/satellite

                 </wsa:To>

                 <sat:SatelliteId>SAT9928</sat:SatelliteId>

              </SOAP-ENV:Header>

              <SOAP-ENV:Body>

                 <wsrl:SetTerminationTime>

                    <wsrl:RequestedTerminationTime>

                           2005-2-15T07:24:00

                    </wsrl:RequestedTerminationTime>

                 </wsrl:SetTerminationTime>

              </SOAP-ENV:Body>

          </SOAP-ENV:Envelope>

          注意,我們不是通過直接操縱 TerminationTime 屬性來設置時間的。這是因為我們需要系統實施它自己的任何一個時間相關規則,比如,不縮短資源的生存期,或者不擴展它超過某個特定的點

          響應消息包含新的 TerminationTime CurrentTime

          <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"

                 xmlns:sat="http://example.org/satelliteSystem"

                 xmlns:wsa="http://www.w3.org/2005/02/addressing"

               xmlns:wsrp="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.xsd"

               xmlns:wsrl="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.xsd">

              <SOAP-ENV:Header>

                 <wsa:Action>

                     http://docs.oasis-open.org/wsrf/2004/06/WS-ResourceLifetime/SetTerminationTimeResponse

                 </wsa:Action>

                 <wsa:To SOAP-ENV:mustUnderstand="1">

                      http://example.com/myClient

                 </wsa:To>

              </SOAP-ENV:Header>

              <SOAP-ENV:Body>

                 <wsrl:SetTerminationTimeResponse>

                    <wsrl:NewTerminationTime>2005-2-15T07:24:00</wsrl:NewTerminationTime>

                    <wsrl:CurrentTime>2005-2-15T03:25:08</wsrl:CurrentTime>

                 </wsrl:SetTerminationTimeResponse>

              </SOAP-ENV:Body>

          </SOAP-ENV:Envelope>

          除非應用程序本身具有設置時間的特定規則,否則沒有任何特殊的約束。您甚至可以將 TerminationTime 設置為過去的值,這與發送 Destroy 消息的效果是一樣的。

           



          Author: orangelizq
          email: orangelizq@163.com

          歡迎大家訪問我的個人網站 萌萌的IT人
          posted on 2009-07-19 15:45 桔子汁 閱讀(347) 評論(0)  編輯  收藏 所屬分類: Web Service
          主站蜘蛛池模板: 阳西县| 舟曲县| 项城市| 突泉县| 无极县| 云浮市| 喀什市| 安远县| 宁乡县| 安多县| 镇沅| 分宜县| 新余市| 临澧县| 屏东县| 金坛市| 浦城县| 博湖县| 金川县| 云龙县| 东乡族自治县| 萨迦县| 北川| 宜昌市| 屯留县| 新闻| 西吉县| 弋阳县| 临安市| 临城县| 东安县| 宁远县| 离岛区| 正镶白旗| 博野县| 双峰县| 衡南县| 吉安市| 福泉市| 辽中县| 沂南县|