定義 z/OS Connect 訊息內容轉換

藉由 IBM® z/OS® Connect,您能夠選擇性地轉換要求和回應內容,以用於呼叫 z/OS 作業系統上的商業資產。您可以實作 z/OS Connect 隨附的 com.ibm.wsspi.zos.connect.DataXform 服務提供者介面 (SPI),來建立訊息內容轉換器,以滿足特定的需求。

關於這項作業

z/OS Connect 所提供的實作需要 JSON 格式的要求和回應訊息。這項特性支援將要求轉換成位元組陣列,以供原生語言 Cobol、PL/I 或 C 結構對映。利用 z/OS Connect 提供的公用程式,會使用目標程式或記錄定義檔的這種語言結構(包括 in 和 out 參數的說明),來產生連結檔及 JSON 要求和回應綱目檔。這個公用程式產生的連結檔,供 z/OS Connect 在要求送達及回應傳回時,用來完成 JSON 與原生資料格式之間的資料轉換。您可以使用 z/OS Connect 提供的 REST API 呼叫,來擷取要求和回應訊息的 JSON 綱目。

z/OS Connect 會提供 zosConnectService 配置元素,可讓管理者配置一組屬性,來套用至特定的服務。其中有一個屬性是 dataXformRef,它會指向一個要用於特定服務的資料轉換配置。這項作業說明如何要求使用 z/OS Connect 提供的資料轉換器。

程序

  1. 針對 server.xml 配置中您要啟用 z/OS Connect 提供之資料轉換的每一項服務,更新 zosConnectService 元素。
    <!-- z/OS Connect 服務定義 -->
    <zosConnectService id="zcs1" 
    	serviceName="recordOpsCreate" 
    	serviceRef="wolaOpsCreateService" 
    	dataXformRef="xformJSON2btye"/> 
  2. 建立相關聯的 zosConnectDataXform 元素。
    <!-- z/OS Connect data transformation provider --> 
    <zosConnectDataXform id="xformJSON2Byte" 
    		bindFileLoc="/u/bindfiles" bindFileSuffix=".bnd" 
    		requestSchemaLoc="/u/json" responseSchemaLoc="/u/json"
    		requestSchemaSuffix=".json" responseSchemaSuffix=".json"/>  

    如需 zosConnectDataXform 元素相關聯的可配置屬性定義的相關資訊,請參閱 z/OS Connect 特性的說明文件。

  3. 選用:配置一個要套用至所有服務的資料轉換器。 將 zosConnectManager 元素的 globaDataXformRef 設定為所配置的資料轉換器 ID,這個 ID 是要供廣域使用的。如果同時定義了廣域和服務的資料轉換器,當服務的要求與所配置的資料轉換器一起送入時,z/OS Connect 會使用專為該服務所配置的資料轉換器。
    <zosConnectManager id="zosConnectGlobals" globalDataXformRef="globalDataXform"/>   
    
    <!-- z/OS Connect data transformation provider --> 
    <zosConnectDataXform id="globalDataXform" 
    		bindFileLoc="/u/bindfiles" bindFileSuffix=".bnd"         
    		requestSchemaLoc="/u/json" responseSchemaLoc="/u/json"
    		requestSchemaSuffix=".json" responseSchemaSuffix=".json"/>      
  4. 選用:配置 pollingRate 和 updateTrigger 之類的設定,以細部調整監視動作。 依預設,會監視與資料轉換定義相關聯的目錄,看看是否有新檔案與檔案更新。如需這些配置屬性的相關資訊,請參閱 zosConnect-1.0 和 zosConnect 1.2 之下的 zosConnectDataXform 元素區段。
      <zosConnectDataXform id="ibmDataXform2"        
    bindFileLoc="/zosConnect/banking/bind/" bindFileSuffix=".bnd"    
    requestSchemaLoc="/zosConnect/banking/reqSchema" requestSchemaSuffix=".json"    
    responseSchemaLoc="/zosConnect/banking/respSchema" responseSchemaSuffix=".json" pollingRate="500ms">    
    </zosConnectDataXform>

    在範例中,每隔 500 毫秒,就會輪詢 /zosConnect/banking/bind,/zosConnect/banking/reqSchema 和 /zosConnect/banking/respSchema 目錄中是否有檔案更新。如果沒有配置 pollingRate 和updateTrigger 配置屬性,會分別使用預設值 polled 和 2 seconds。如果您不需要監視檔案,可以將 updateTrigger 屬性設為 disabled 來停用它。如果您偏好觸發手動重新整理特定的檔案,請將 updateTrigger 屬性設為 mbean,並使用檔案通知 MBean com.ibm.ws.kernel.filemonitor.FileNotificationMBean,來觸發更新;例如:

    String[] MBEAN_METHOD_SIGNATURE = new String[] {Collection.class.getName(),Collection.class.getName(),Collection.class.getName() };        
    JMXConnector jmxConnector = ...;        
    MBeanServerConnection mbsc = jmxConnector.getMBeanServerConnection();        
    ObjectName fileMonitorMBeanName = new ObjectName("WebSphere:service=com.ibm.ws.kernel.filemonitor.FileNotificationMBean");        
    
    List<String> paths = new ArrayList<String>();        
    paths.add("/zosConnect/banking/bind/customer.bnd");        
    paths.add("/zosConnect/banking/reqSchema/customer_request.json");       
    paths.add("/zosConnect/banking/respSchema/customer_response.json");        
    
    Object[] params = new Object[] { null, paths, null };        
    mbsc.invoke(fileMonitorMBeanName, "notifyFileChanges", params, MBEAN_METHOD_SIGNATURE);

    此範例使用 restConnector-1.0 特性來觸發 customer.bnd、customer_request.json 和 customer_response.json 檔的更新。如需如何建立安全 JMX 連線的相關資訊,請參閱配置指向 Liberty 的安全 JMX 連線相關說明文件。


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



「時間戳記」圖示 前次更新: 2016 年 6 月 3 日
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-dist&topic=twlp_zconnect_msg_payload_conv
檔名:twlp_zconnect_msg_payload_conv.html