|
使用biz-client调用 blobDownloadAction获取blob字段,报“返回值必须是JSON或XML格式”
- public static JSONObject getImageUrlAction(JSONObject params, ActionContext context) throws SQLException, NamingException, ClientProtocolException, IOException {
- // 登录
- String bSessionID = login();
- String dataModel = params.getString("dataModel");
- String concept = params.getString("concept");
- String relation = params.getString("relation");
- String id = params.getString("id");
- String process = params.getString("process");
- String activity = params.getString("activity");
- JSONObject json = new JSONObject();
- try {
- Action action = new Action();
- // 指定动作的process、activity和action,这里要注意登录的用户应该有执行这个功能中的这个动作的权限
- action.setName("blobDownloadAction");
- action.setProcess(process);
- action.setActivity(activity);
- // 设置动作参数
- action.setParameter("blobDataModel", dataModel);
- action.setParameter("blobConcept", concept);
- action.setParameter("blobRelation", relation);
- action.setParameter("blobConceptValue", id);
- // 调用动作
- ActionResult actionResult = ActionEngine.invokeAction(action, ActionUtils.JSON_CONTENT_TYPE, bSessionID, null, null);
- // 判断是否调用成功
- if (actionResult.isSuccess()) {
- // 返回值
- json.put("url", convertStreamToString ( (InputStream)actionResult.getDatas().get(0) ));
- return json;
- } else {
- throw new RuntimeException(actionResult.getMessage());
- }
- } finally {
- // 要保证注销,否则会占用在线人数
- ActionEngine.logout(bSessionID);
- }
- }
复制代码
|
|