我必须从非 RESTful API 访问数据,并尝试构建一个新的 Web 服务来访问原始 API 并将其重新公开为 RESTful API。
我想使用LoopBack来实现这一点。
到目前为止,我有:
var loopback = require("loopback");
var ds = loopback.createDataSource({
connector: require("loopback-connector-rest"),
debug: false,
operations: [
{
"template": {
"method": "POST",
"url": "http://192.168.1.20/OLD_API/Web_SVC.ASMX/CALLFUNC",
"headers": {
"accepts": "application/json",
"content-type": "application/json"
},
"body": "{body}"
},
"functions": {
"create": ["body"]
}
}
]});
var model = ds.createModel('debtor');
model.create({ "DLLNAME":"WEB_DLLS.GET_AGED", "FUNCTIONNAME":"M_GET_AGED", "PARAMETERNAME":"1234" },function (err, result, response) {
console.log(JSON.parse(result.d));
});
理想情况下,我想将其公开POST
为通话中GET
的/api/debtors/{clientId}
位置。clientId
PARAMETERNAME
model.create