利用 Script 來快速啟動及執行 WS-Notification

請利用 jython Script 來配置必要的資源,以便在 WebSphere® Application Server 中備妥及快速執行 WS-Notification。

開始之前

這個主題所提供的範例 Script 只適用於單一伺服器上的開發用途,不適合在正式作業或網路部署環境中使用。

關於這項作業

您可以利用範例 Script 來配置一組預設資源,以便連接 WS-Notification 應用程式來進行開發。 執行時,Script 會採取下列動作:

  1. 它會在配置中搜尋現有的服務整合匯流排,必要的話,會建立一個。
  2. 它會搜尋現有的匯流排成員,如果找不到,它會新增(獨立式)伺服器至匯流排中,然後使用預設資料來源。
  3. 它會搜尋現有的服務整合匯流排主題空間目的地,必要的話,會建立一個。
  4. 它會建立 6.1 版或 7.0 版 WS-Notification 服務。
  5. 它會針對 SOAP over HTTP 連結,在本端伺服器上建立 6.1 版或 7.0 版 WS-Notification 服務點。
  6. 它會建立一個 WS-Notification 永久主題名稱空間,來參照步驟 3 所找到或建立的服務整合匯流排主題空間。
  7. 它會儲存配置,並說明在哪裡尋找已顯現的新的通知分配管理系統 Web 服務的 WSDL。

如果要使用範例 Script,請完成下列步驟:

程序

  1. 利用您選擇的名稱(如 wsnQuickStart.py),將 Script 儲存在檔案系統中。
  2. 修改 Script 中所定義的 hostRoot 變數來指向本端伺服器的 HTTP 埠(通常是 9080)。
  3. (只有 6.1 版 WS-Notification 服務需要這個步驟)安裝及配置 SDO 儲存庫
  4. 啟動伺服器,然後執行下列指令。 如果您用 wsnQuickStart.py 以外的名稱來儲存 Script,請改用該名稱。
    wsadmin -f wsnQuickStart.py

範例

以下是 Script 範例:
#######################################################################################
# WS-Notification QuickStart Script                                                   #
#                                                                                     #
# 這個 Jython Script 會快速建立開始使用                                               #
# WebSphere Application Server 6.1 版或更新版本中的        #
# WS-Notification 所需要的基本資源。                                                  #
#                                                                                     #
# 執行它之前,您必須先修改以下所定義的變數,                                          #
# 以符合您的配置設定。                                                                #
#                                                                                     #
# 附註:                                                                              #
#    - 這個 Script 不適合正式作業用途,只適合在                                       #
#      獨立式伺服器(不是網路部署)上使用。                                           #
#    - 這個 Script 會搜尋配置來尋找現有的匯流排,                                     #
#      如果找不到,就會新建一個匯流排                                                 #
#    - 之後,它會在所選的匯流排上,尋找現有的匯流排成員。如果找不到,                 #
#      就會利用預設「檔案儲存庫」來建立一個                                           #
#    - 之後,它會尋找一個現有的服務整合匯流排主題空間。如果找不到,                   #
#      就會建立一個。                                                                 #
#                                                                                     #
# 請輸入如下,以執行這個 Script:                                                     #
#   wsadmin -f wsnQuickStart.py                                                       #
#                                                                                     #
#######################################################################################

###########################################################
# 配置變數                                                #
#                                                         #
# 請將下列變數設為符合您的配置                            #
###########################################################
# 本端伺服器上 HTTP 埠的 URL 根目錄
hostRoot = "http://xyz.ibm.com:9080"
# 您想要建立的 WS-Notification 服務類型(6.1 版或 7.0 版)
wsnServiceType = "V7.0"

#######################################################################################
# 現在,利用上面定義的變數來建立配置物件                                              #
#######################################################################################

# 這些變數是任意選項,若非必要,不需設定。
wsnServiceName = "myWSNService"+wsnServiceType
wsnServicePointName = "myWSNServicePoint"+wsnServiceType
eplName = "myNewEPL"
tnsNamespaceURI = "http://example.org/topicNamespace/example1"

# 一般環境變數
nodeName = AdminTask.listNodes().split("\n")[0].rstrip()
server = AdminTask.listServers().split("\n")[0].rstrip()

print "###########################################################"
print "# 開始之前,檢查必要條件                                  #"
print "###########################################################"
# 檢查匯流排是否存在
requiresRestart = "false"
myBuses = AdminTask.listSIBuses().split("\n")
myBus = myBuses[0].rstrip()

if (myBus == ""):
        print "  *** Creating new bus "
        myBus = AdminTask.createSIBus("-bus MySampleBus -busSecurity false
                                       -scriptCompatibility 6.1")
        requiresRestart = "true"
#endIf
siBusName = AdminConfig.showAttribute(myBus, "name" )
print "  service integration bus name: "+siBusName+" "

# 檢查匯流排成員是否存在
busMembers = AdminTask.listSIBusMembers(" -bus "+siBusName).split("\n")
myBusMember = busMembers[0].rstrip()

if (myBusMember == ""):
        print ""
        print "  *** Creating new Bus Member "
        busMemberName = AdminConfig.showAttribute(server, "name")
        myBusMember = AdminTask.addSIBusMember(" -bus "+siBusName+"
                        -node "+nodeName+" -server "+busMemberName)
        print ""
        requiresRestart = "true"
else:
        nodeName = AdminConfig.showAttribute(myBusMember, "node")
        busMemberName = AdminConfig.showAttribute(myBusMember, "server")
#endElse
print "  service integration bus Member on node: "+nodeName+" "
print "                               on server: "+busMemberName+" "

# Find a topic space to use
topicSpaces = AdminTask.listSIBDestinations(" -bus "+siBusName+"
                                  -type TopicSpace ").split("\n")
tSpace = topicSpaces[0].rstrip()

if (tSpace == ""):
        print "  *** Creating a Topic Space "
        tSpace = AdminTask.createSIBDestination(" -bus "+siBusName+"
                        -node "+nodeName+" -server "+myBusMember+"
                        -name MyTopicSpace -type TopicSpace")
        print ""

#endIf
siBusTopicSpaceName = AdminConfig.showAttribute(tSpace, "identifier" )
print "     service integration bus topic space: "+siBusTopicSpaceName+" "

print ""
print "###########################################################"
print "# 建立 WS-Notification 服務                               #"
print "###########################################################"
newService = AdminTask.listWSNServices(" -name "+wsnServiceName+"
                            -bus "+siBusName).split("\n")[0].rstrip()

if (newService == ""):
        newService = AdminTask.createWSNService(" -name "+wsnServiceName+"
                            -bus "+siBusName+" "+" -type "+wsnServiceType)
        print "WS-Notification service created: "+wsnServiceName+" "
        print "                         on bus: "+siBusName+" "
else:
        print "WS-Notification service '"+wsnServiceName+"' "
        print "  already exists on bus '"+siBusName+"' "
#endElse

print ""
print "###########################################################"
print "# 建立 WS-Notification 服務點                             #"
print "###########################################################"
eplURLRoot = hostRoot+"/wsn"
wsdlURLRoot = hostRoot+"/SIBWS/wsdl"

newServicePoint = AdminTask.listWSNServicePoints(newService, "
                -name "+wsnServicePointName+" " ).split("\n")[0].rstrip()

if (newServicePoint == ""):
        if (wsnServiceType == "V7.0"):
            newServicePoint = AdminTask.createWSNServicePoint(newService, "
            -name "+wsnServicePointName+" -node "+nodeName+" -server "+busMemberName)
        else:
            newServicePoint = AdminTask.createWSNServicePoint(newService, "
            -name "+wsnServicePointName+"
            -node "+nodeName+" -server "+busMemberName+" -eplName "+eplName+"
            -eplURLRoot "+eplURLRoot+" -eplWSDLServingURLRoot "+wsdlURLRoot+" " )
        print "WS-Notification service point created: "+wsnServicePointName+" "
        print "                        on bus member: "+busMemberName+" "
        print "                              on node: "+nodeName+" "
else:
        print "WS-Notification service point '"+wsnServicePointName+"' "
        print "already exists on WS-Notification service '"+wsnServiceName+"' "
#endElse

print ""
print "###########################################################"
print "# 建立 WS-Notification 永久主題名稱空間                   #"
print "###########################################################"
newTopicNamespace = AdminTask.listWSNTopicNamespaces(newService, "
                    -namespace "+tnsNamespaceURI+" ").split("\n")[0].rstrip()

if (newTopicNamespace == ""):
    newTopicNamespace = AdminTask.createWSNTopicNamespace(newService, "
      -namespace "+tnsNamespaceURI+" -busTopicSpace "+siBusTopicSpaceName+"
      -reliability RELIABLE_PERSISTENT")
  print "WS-Notification topic namespace created: "+tnsNamespaceURI+" "
  print "                        bus topic space: "+siBusTopicSpaceName+" "
else:
  print "WS-Notification permanent topic namespace already exists: "
        +tnsNamespaceURI+" "
#endElse

#######################################################################################
# 所有物件都已建立好 - 通知使用者在哪裡繼續下一步                                     #
#######################################################################################

print ""
print "###########################################################"
print "# 摘要                                                    #"
print "###########################################################"

# 計算您會在哪裡找到新服務的 WSDL。
if (wsnServiceType == "V7.0"):
  print "IMPORTANT: Because you've created a Version 7.0 service"
  print "you need to start the newly installed application;"
  print "           WSN_"+wsnServiceName+"_"+wsnServicePointName
  print ""

  wsdlLocation = hostRoot+"/"+wsnServiceName+wsnServicePointName
                         +"NB/Service?wsdl"
else:
  print "IMPORTANT: Because you've created a Version 6.1 service"
  print "you need to start 2 newly installed applications;"
  serverName = AdminConfig.showAttribute(server, "name")
  print "           "+eplName+"."+nodeName+"."+serverName
  print "           sibws."+nodeName+"."+serverName
  print ""
  wsdlLocation = hostRoot+"/wsn/soaphttpengine/"+siBusName+"/"
                 +wsnServiceName+"NotificationBroker/"
                 +wsnServicePointName+"NotificationBrokerPort?wsdl"
print " The WSDL for the new service can be viewed at the following location; "
print "   "+wsdlLocation+" "
print ""
print " Your web service applications can publish and subscribe to any topics in the namespace; "
print "   "+tnsNamespaceURI+" "
print ""
if (requiresRestart == "true"):
  print " You must now restart the server for the changes to take effect. "
  print ""
#endIf

print ""
print "###########################################################"
print "# 儲存配置並結束                                          #"
print "###########################################################"
AdminConfig.save()
sys.exit()

指出主題類型的圖示 作業主題



時間戳記圖示 前次更新: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=tjwsn_task_sysa0
檔名:tjwsn_task_sysa0.html