|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jQueryを用いて、API Gatewayを呼び出す。 |
|
|
下記のサンプルソースでは、textboxの入力値をAPI Gatewayに渡し、LambdaでCOBOLが動いて、 |
|
|
COBOLから戻された値を受け取り、表示する仕様となっている。 |
|
|
|
参考: |
|
|
https://www.tantan-biyori.info/blog/2019/01/amazon-api-gatewayapi.html |
|
|
|
<html lang="ja"> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<head> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<meta charset="UTF-8"> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<title>API Gateway TestPage</title> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</head> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<body> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h3>WEB⇔COBOL連携</h3> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<input id="in1" type="text"></input><br> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<input id="in2" type="text"></input><br> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<button id="exec">実行</button><br><br> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div id="res"></div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> |
|
|
|
|
<script> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(function() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#exec').on('click', function() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ajax通信でAPI Gatewayへアクセスし、値を渡す。 |
|
|
type:'POST', |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
url:'https://xxxxxxx.execute-api.ap-northeast-1.amazonaws.com/cobo/cobol2020', |
|
|
API GatewayのURL+メソッド名 ※ |
|
|
data:JSON.stringify({ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"text1" : document.getElementById("in1").value, |
|
|
|
|
|
|
|
|
|
|
|
|
COBOLへのINPUT(TextBoxの値を渡す) |
|
|
"text2" : document.getElementById("in2").value |
|
|
|
|
|
|
|
|
|
|
|
|
|
COBOLへのINPUT(TextBoxの値を渡す) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).done(json => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#res').html("StatusCode:" + json['statusCode'] + "<br>" + |
|
|
|
|
|
|
|
|
COBOLソース内での固定値を受け取る |
|
|
"Message:" + json['body'] + "<br>" + |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
COBOLソース内での固定値を受け取る |
|
|
"入力値1:" + json['input']["text1"] + "<br>"+ |
|
|
|
|
|
|
|
|
|
|
|
|
|
COBOLへのINPUT(可変値)を受け取る |
|
|
"入力値2:" + json['input']["text2"]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
COBOLへのINPUT(可変値)を受け取る |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
※API Gatewayでデプロイされた後に表示されるURL+メソッド名 |
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</body> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</html> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|