0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Talend WebAPI データ取得時cookie保存するコンポーネントの解決案

Last updated at Posted at 2017-11-30

Talend WebAPIでデータ取得する時、uniqidはどうやって取得できますか。

考え方:
・uniqidはcookieで保存している
・Talendはcookie取得するコンポーネントがないこと確認。
・手でcookie取得するjavaコンポーネント作成する。

画像:
11.jpg

javaソース:
//変数を定義する
String strPonit ="{"uniqid":"";
String domainurl = "xxxxxxxxxxxxxxxxxxxxxx";
String content_type = "application/x-www-form-urlencoded";
String apikey = "xxxxxxxxxxxxxxxxxxxxxx";
String login_id ="xxxxxxxxxxxxxxxxxxxxxx";
String login_password ="xxxxxxxxxxxxxxxxxxxxxx";
String udid ="xxxxxxxxxxxxxxxxxxxxxx";
context.put("udid",udid);
//画面請求のパラメータ
apikey =String.format(apikey, login_id, login_password,udid);
java.net.URL url = new java.net.URL(domainurl);
java.net.HttpURLConnection conn = (java.net.HttpURLConnection)url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", content_type);
conn.setDoOutput(true);
DataOutputStream out = new DataOutputStream(conn.getOutputStream());
out.writeBytes(apikey);
out.flush();
out.close();
java.util.Map> map = conn.getHeaderFields();
//画面のcookieを取得
context.put("Cookie",map.get("Set-Cookie").get(0));
java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(conn.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
int startPonit = inputLine.indexOf(strPonit) + strPonit.length();
int endPonit = inputLine.indexOf(""",startPonit);
//請求の成功したら、画面のuniqidを取得する
context.put("uniqid",inputLine.substring(startPonit, endPonit));
//System.out.println(inputLine);
}
in.close();

画像:
12.jpg

HTTPボディ:
"action=list&table=products_class&limit=50000000&offset=0&udid="+(String)context.get("udid")+"&uniqid="+(String)context.get("uniqid")

メモ:ジョブは個人GITにupdateする(非公開)

以上

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?