Created
September 28, 2011 03:14
-
-
Save yehara/1246898 to your computer and use it in GitHub Desktop.
Questetra BPM Suite のメッセージ開始イベントを起動するサンプルコード(Java)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.questetra; | |
import java.io.IOException; | |
import java.io.UnsupportedEncodingException; | |
import java.util.ArrayList; | |
import java.util.List; | |
import org.apache.http.HttpEntity; | |
import org.apache.http.HttpResponse; | |
import org.apache.http.NameValuePair; | |
import org.apache.http.client.HttpClient; | |
import org.apache.http.client.entity.UrlEncodedFormEntity; | |
import org.apache.http.client.methods.HttpPost; | |
import org.apache.http.impl.client.DefaultHttpClient; | |
import org.apache.http.message.BasicNameValuePair; | |
import org.apache.http.protocol.HTTP; | |
import org.apache.http.util.EntityUtils; | |
public class MessageStartClient { | |
public static void main(String[] args) { | |
HttpClient client = new DefaultHttpClient(); | |
HttpPost post = new HttpPost("https://s.questetra.net/00000000/System/Event/MessageStart/start"); | |
List<NameValuePair> params = new ArrayList<NameValuePair>(); | |
params.add(new BasicNameValuePair("processModelInfoId", "1")); | |
params.add(new BasicNameValuePair("nodeNumber", "0")); | |
params.add(new BasicNameValuePair("key", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")); | |
// 件名 | |
params.add(new BasicNameValuePair("title", "件名です")); | |
// 文字型 | |
params.add(new BasicNameValuePair("data[0].input", "文字型です")); | |
// 数値型 | |
params.add(new BasicNameValuePair("data[1].input", "12345")); | |
// 選択型 | |
params.add(new BasicNameValuePair("data[2].selects", "2")); | |
params.add(new BasicNameValuePair("data[2].selects", "3")); | |
// 日付型 | |
params.add(new BasicNameValuePair("data[3].input", "2011-09-26")); | |
// 日時型 | |
params.add(new BasicNameValuePair("data[4].input", "2011-09-26")); | |
params.add(new BasicNameValuePair("data[4].time", "12:34")); | |
// ユーザ型 | |
params.add(new BasicNameValuePair("data[6].email", "[email protected]")); | |
// 掲示板型 | |
params.add(new BasicNameValuePair("data[7].console", "掲示板型です")); | |
// テーブル型 | |
params.add(new BasicNameValuePair("data[9].input", "<list><row><col>文字</col><col>54321</col></row></list>")); | |
try { | |
post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); | |
HttpResponse response = client.execute(post); | |
int statusCode = response.getStatusLine().getStatusCode(); | |
HttpEntity responseEntity = response.getEntity(); | |
switch (statusCode) { | |
case 200 : | |
// 成功 | |
System.out.println("プロセス開始に成功しました。"); | |
break; | |
default : | |
// エラー応答が返ってきた場合 | |
System.out.println("プロセス開始に失敗しました。 status: " + statusCode); | |
System.out.println(EntityUtils.toString(responseEntity)); | |
} | |
} catch (UnsupportedEncodingException e) { | |
e.printStackTrace(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment