目录

Search

  1. 前言
  2. 业务实体服务简介
  3. Enterprise Java Bean 业务实体服务调用
  4. 具象状态传输业务实体服务调用
  5. 简单对象访问协议业务实体服务调用
  6. 用于交叉引用记录和 BVT 计算的服务
  7. 支持企业关联服务
  8. 清理、分析和转换业务实体数据的外部调用
  9. 使用 REST API 添加业务实体记录

业务实体服务指南

业务实体服务指南

JavaScript 示例

JavaScript 示例

资源工具包含有示例 Java 源代码,该代码显示了如何执行 REST 业务实体服务调用。
该示例代码位于以下文件:
<
MDM Hub 安装目录
>\hub\resourcekit\samples\COS\source\resources\webapp\rest-api.html
以下代码显示的 REST API 调用可以创建 Person 根记录、添加多个子记录、删除一个子记录以及删除该 Person 记录和所有子记录:
<html> <head> <script type="text/javascript" src="jquery-1.11.1.js"></script> <script type="text/javascript" src="cs-client.js"></script> </head> <body> <script type="text/javascript" language="javascript"> $(document).ready(function () { $("#run").click(function () { log = function(msg, json) { $('#log').before("<hr/><b>" + msg + "</b>"); $('#log').before("<pre>" + JSON.stringify(json, undefined, 2) + "</pre>"); }; CSClient.createCo( "/Person", { firstName: "John", lastName: "Smith" }, { systemName: "Admin" } ).then( function (result) { log("PERSON CREATED:", result); return CSClient.readCo( "/Person/" + result.Person.rowidObject.trim(), { depth: 1 } ); } ).then( function (result) { log("READ CREATED PERSON:", result); return CSClient.updateCo( "/Person/" + result.rowidObject.trim(), { genderCd: { genderCode: "M" }, TelephoneNumbers: { item: [ { phoneNumber: "111-11-11" }, { phoneNumber: "222-22-22" } ] } }, { systemName: "Admin" } ); } ).then( function (result) { log("PERSON UPDATED:", result); return CSClient.readCo( "/Person/" + result.Person.rowidObject.trim(), { depth: 3, readSystemFields: true } ); } ).then( function (result) { log("READ UPDATED PERSON:", result); return CSClient.deleteCo( "/Person/" + result.rowidObject.trim() + "/TelephoneNumbers/" + result.TelephoneNumbers.item[0].rowidObject.trim(), { systemName: "Admin" } ); } ).then( function (result) { log("TELEPHONE DELETED:", result); return CSClient.readCo( "/Person/" + result.Person.rowidObject.trim(), { depth: 3 } ); } ).then( function (result) { log("READ PERSON AFTER TELEPHONE IS DELETED:", result); return CSClient.deleteCo( "/Person/" + result.rowidObject.trim(), { systemName: "Admin" } ); } ).then( function (result) { log("PERSON DELETED:", result); return CSClient.readCo( "/Person/" + result.Person.rowidObject.trim(), { depth: 1, recordStates: "ACTIVE,PENDING,DELETED", readSystemFields: true } ); } ).then( function (result) { log("READ PERSON AFTER DELETE (HSI -1):", result); } ); }); }); </script> <input type="button" id="run" value="Run..."/> <p/> <div id="log"></div> </body> </html>