Пример #1
0
  public String resChange(String paramStr) throws AppException, SysException {
    String urlStr = "";
    try {
      RmsServiceForMos service = new RmsServiceForMosLocator();
      RmsServiceForMosDelegate client = null;

      // 如果初始化缓存则使用缓存地址
      if (!StringUtil.isBlank(
              SysConfigData.getSysConfigCurValue(
                  SysConstants.SYS_CONFIG_MOS_INIT_CONFIG, null, null, null, null, null))
          && SysConstants.TRUE.equals(
              SysConfigData.getSysConfigCurValue(
                  SysConstants.SYS_CONFIG_MOS_INIT_CONFIG, null, null, null, null, null))) {
        urlStr =
            SysConfigData.getSysConfigCurValue(
                SysConstants.SYS_CONFIG_MOS_SERVER_ADDR, null, null, null, null, null);
      } else {
        // 没有初始化则使用常量
        urlStr = SysConstants.MOS_SERVER_ADDR_FOR_ACTION;
      }

      URL url = new URL(urlStr);
      client = service.getRmsServiceForMosPort(url);
      String mosCallLog = client.resChange(paramStr);
      return mosCallLog;
    } catch (RemoteException e) {
      throw new AppException("", "调用远程webservice方法失败!" + urlStr + e.getMessage());
    } catch (MalformedURLException e) {
      log.info(e.toString());
      throw new AppException("", "webserviceURL地址错误!" + urlStr + e.getMessage());
    } catch (ServiceException e) {
      log.info(e.toString());
      throw new AppException("", "调用远程webservice方法失败!" + urlStr + e.getMessage());
    }
  }
Пример #2
0
  /**
   * MOS native 从sysconfig中取得MOS需要的缓存
   *
   * @return
   * @throws SysException
   * @throws AppException
   */
  public String getSysConfig4MOS() throws SysException, AppException {

    IM4MOSServicesService service = new IM4MOSServicesServiceLocator();
    IM4MOSServices_PortType client = null;
    // String urlStr = "http://127.0.0.1:7001/web/services/";

    String urlStr = "";
    // 如果初始化缓存则使用缓存地址
    if (!StringUtil.isBlank(
            SysConfigData.getSysConfigCurValue(
                SysConstants.SYS_CONFIG_MOS_INIT_CONFIG, null, null, null, null, null))
        && SysConstants.TRUE.equals(
            SysConfigData.getSysConfigCurValue(
                SysConstants.SYS_CONFIG_MOS_INIT_CONFIG, null, null, null, null, null))) {
      urlStr =
          SysConfigData.getSysConfigCurValue(
              SysConstants.SYS_CONFIG_MOS_LOCAL_SERVER_ADDR, null, null, null, null, null);
    } else {
      // 没有初始化则使用常量
      urlStr = SysConstants.MOS_SELF_SERVER_ADDR_FOR_ACTION;
    }

    //		String urlStr = SysConfigData.getSysConfigCurValue(
    //				SysConstants.SYS_CONFIG_MOS_SERVER_ADDR, null, null, null,
    //				null, null);
    urlStr = urlStr + "IM4MOSServices";
    URL url;
    String vesion = null;
    try {
      url = new URL(urlStr);
      client = service.getIM4MOSServices(url);
      vesion =
          client.svcCallIOMByMosNative(SysConstants.SYS_CONFIG_MOS_QUERY_SYS_CONFIG, null, null);
    } catch (RemoteException e) {
      throw new AppException("", "调用远程webservice方法失败!");
    } catch (MalformedURLException e1) {
      throw new AppException("", "调用远程webservice方法失败!");
    } catch (ServiceException e) {
      throw new AppException("", "调用远程webservice方法失败!");
    }
    log.debug("client: " + client);

    if (StringUtil.isExcetionInfo(vesion)) {
      throw new AppException("", "调用远程webservice方法失败!" + StringUtil.getExcetionInfo(vesion));
    }

    return vesion;
  }
Пример #3
0
  public String resQuery(String paramStr) throws AppException, SysException {
    String urlStr = "";
    try {
      RmsServiceForMos service = new RmsServiceForMosLocator();
      RmsServiceForMosDelegate client = null;

      urlStr =
          SysConfigData.getSysConfigCurValue(
              SysConstants.SYS_CONFIG_MOS_SERVER_ADDR, null, null, null, null, null);

      // urlStr = "http://10.21.1.29:8080/trms/services/RmsForMosService";
      //			urlStr = "http://192.168.100.233:1991/trms/services/RmsForMosService";

      URL url = new URL(urlStr);
      client = service.getRmsServiceForMosPort(url);
      String mosCallLog = client.resQuery(paramStr);
      return mosCallLog;
    } catch (RemoteException e) {
      throw new AppException("", "调用远程webservice方法失败!" + urlStr + e.getMessage());
    } catch (MalformedURLException e) {
      log.info(e.toString());
      throw new AppException("", "webserviceURL地址错误!" + urlStr + e.getMessage());
    } catch (ServiceException e) {
      log.info(e.toString());
      throw new AppException("", "调用远程webservice方法失败!" + urlStr + e.getMessage());
    }
  }
Пример #4
0
  public String queryDevice(String paramStr) throws AppException, SysException {
    String urlStr = "";
    try {
      RmsServiceForMos service = new RmsServiceForMosLocator();
      RmsServiceForMosDelegate client = null;
      // String urlStr = SysConfigData.getSysConfigCurValue(
      // SysConstants.SYS_CONFIG_MOS_SERVER_ADDR, null, null, null,
      // null, null);

      // 如果初始化缓存则使用缓存地址
      if (!StringUtil.isBlank(
              SysConfigData.getSysConfigCurValue(
                  SysConstants.SYS_CONFIG_MOS_INIT_CONFIG, null, null, null, null, null))
          && SysConstants.TRUE.equals(
              SysConfigData.getSysConfigCurValue(
                  SysConstants.SYS_CONFIG_MOS_INIT_CONFIG, null, null, null, null, null))) {
        urlStr =
            SysConfigData.getSysConfigCurValue(
                SysConstants.SYS_CONFIG_MOS_SERVER_ADDR, null, null, null, null, null);
      } else {
        // 没有初始化则使用常量
        urlStr = SysConstants.MOS_SERVER_ADDR_FOR_ACTION;
      }

      // String urlStr = SysConstants.SYS_CONFIG_MOS_SERVER_ADDR;
      //			urlStr = "http://10.22.1.41:8080/trms/services/RmsForMosService";
      URL url = new URL(urlStr);
      client = service.getRmsServiceForMosPort(url);
      String mosLoginRep = client.deviceQuery(paramStr);

      return mosLoginRep;
    } catch (RemoteException e) {
      throw new AppException("", "调用远程webservice方法失败!" + urlStr + e.getMessage());
    } catch (MalformedURLException e) {
      log.info(e.toString());
      throw new AppException("", "webserviceURL地址错误!" + urlStr + e.getMessage());
    } catch (ServiceException e) {
      log.info(e.toString());
      throw new AppException("", "调用远程webservice方法失败!" + urlStr + e.getMessage());
    }
  }
Пример #5
0
  /**
   * 查询知识库讨论主题
   *
   * @param paraMap 输入参数所有对象封装在Map
   * @return 输出参数所有对象封装在Map
   * @throws SysException
   * @throws AppException
   */
  public Map findKbTopic4REST(Map paraMap) throws SysException, AppException {
    Map resultMap = new HashMap();
    try {
      // String urlStr = SysConfigData.getSysConfigCurValue(
      //	SysConstants.SYS_CONFIG_SMS_SERVER_ADDR, null, null, null,
      // null, null);
      paraMap.put("module", "topicApi");
      paraMap.put("action", "list");
      paraMap.put("api_key", "userapi");
      String paramStr = prepareParam(paraMap);
      String urlStr =
          SysConfigData.getSysConfigCurValue(
              SysConstants.SYS_CONFIG_MOS_JFORUM_ADDR, null, null, null, null, null);
      urlStr = urlStr + "topicApi/list.page";
      urlStr = urlStr + "?" + paramStr;
      URL url = new URL(urlStr);
      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
      // 设置发送请求的方式
      conn.setRequestMethod("POST");
      // 设置参数的格式类型
      conn.setRequestProperty("Content-Type", "text/html;charset=utf-8");
      // 打开输入输出,在output中传输参数
      conn.setDoInput(true);
      conn.setDoOutput(true);
      OutputStream os = conn.getOutputStream();
      os.close();
      // 正常时返回的状态码为200
      if (conn.getResponseCode() == 200) {
        // 获取返回的内容
        BufferedReader br =
            new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"));
        // 输出返回的信息
        String line;
        StringBuffer contentBuffer = new StringBuffer();
        while ((line = br.readLine()) != null) {
          System.out.println(line);
          contentBuffer.append(line);
        }
        System.out.print(contentBuffer.toString());
        br.close();
        Document doc = null;
        List topicList = new ArrayList();
        // 下面的是通过解析xml字符串的
        doc = DocumentHelper.parseText(contentBuffer.toString()); // 将字符串转为XML
        Element rootElt = doc.getRootElement(); // 获取根节点
        Element forumsElement = rootElt.element("topics");
        Iterator topicItr = forumsElement.elementIterator("topic"); // 获取topic节点列表
        // 遍历forum节点
        while (topicItr.hasNext()) {
          Element topicElt = (Element) topicItr.next();
          KbTopicSVO kbTopicSVO = new KbTopicSVO();
          kbTopicSVO.setTopicId(topicElt.attributeValue("id"));
          kbTopicSVO.setTopicTitle(topicElt.attributeValue("title"));
          kbTopicSVO.setTopicDesc(topicElt.getText());
          kbTopicSVO.setTopicReplies(Integer.parseInt(topicElt.attributeValue("replies")));
          kbTopicSVO.setPostUserName(topicElt.attributeValue("postUserName"));
          kbTopicSVO.setTopicTime(
              DateUtil.to_date(topicElt.attributeValue("firstPostTime"), DATE_FORMAT));
          kbTopicSVO.setFirstPostTime(DateUtil.date2Str(kbTopicSVO.getTopicTime()));
          topicList.add(kbTopicSVO);
        }
        resultMap.put("topicList", topicList);
      } else {
        log.info("POST" + " [ERROR] CODE: " + conn.getResponseCode());
      }

    } catch (ProtocolException ptclEx) {
      log.info(ptclEx.toString());
      throw new AppException("", "调用RESTful接口时协议异常!");
    } catch (IOException ioEx) {
      log.info(ioEx.toString());
      throw new AppException("", "方法体内进行输入输出操作时异常!");
    } catch (DocumentException docEx) {
      log.info(docEx.toString());
      throw new AppException("", "解析调用RESTful接口返回参数时异常!");
    }
    return resultMap;
  }