RESTインターフェースを使用して自動運用プロセスを起動できます。
RESTインターフェースの詳細については、“Systemwalker Runbook Automation リファレンスマニュアル”を参照してください。
操作
Webコンソール、またはRESTインターフェースを使用して、起動対象の自動運用プロセスグループ名やプロセス定義名など、事前にRESTインターフェースから起動するために必要な情報を確認します。
RESTインターフェースを使用して自動運用プロセスを起動します。
以下に、自動運用プロセスを起動するJavaプログラムの例を示します。
import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import javax.mail.internet.MimeUtility; /** * REST Client Sample * * <pre> * Base64エンコードのためにJavaMailのユーティリティを使用しています。 * 必要に応じてJavaMailのモジュール(mail.jar)を入手してください。 * </pre> * */ public class ClientApl { // 接続先のURL private final static String baseURL="http://example.com"; /** * プロセスを起動します。 * @param args */ public static void main(String[] args) { String username="swrbaadmin"; // ユーザーID String password="systemwalker#1"; // パスワード String appId = "TEST"; // 自動運用プロセスグループ名 String pdname = "TEST"; // プロセス定義名 String id_pass= null; HttpURLConnection conn = null; try { URL url = new URL(baseURL + "/rbaserver/ProcessInstances" + "?" + "appid=" + appId + "&pdname=" + pdname); // Basic認証のためのエンコード ByteArrayOutputStream bos = null; OutputStream os = null; try { bos = new ByteArrayOutputStream(); os = MimeUtility.encode(bos , "base64"); os.write((username + ":" + password).getBytes()); os.flush(); id_pass = bos.toString(); } catch (Exception e) { e.printStackTrace(); throw e; } finally { os.close(); bos.close(); } // HTTP接続 conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("Authorization", "Basic " + id_pass); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type","text/plain"); conn.setRequestProperty("Accept","application/xml"); conn.connect(); // 結果を取得 if (conn.getResponseCode() != HttpURLConnection.HTTP_OK){ // Request Error. System.out.println("StatusCode : " + conn.getResponseCode()); System.exit(1); } BufferedReader bf = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line = bf.readLine(); while(line != null){ System.out.println(line); line = bf.readLine(); } } catch (Exception e) { e.printStackTrace(); } finally { if ( conn != null){ conn.disconnect(); } } System.exit(0); } }