Java代码的实例

 public interface IPoApplyWs
{   
    /**
     * 根据产品线、产品族、产品、审核人来查询所有.
     * @param aJsonStr 客户端传递过来的aJsonStr转成的字符串
     * @return 返回结果字符串
     * @author hubing.tang,tong.jiang
     * @throws ApplicationException ApplicationException
     */

    String getSecondCheckerInfo(String aJsonStr) throws ApplicationException;
}
/**
     * 根据产品线、产品族、产品、审核人来查询所有.
     * @param aJsonStr 客户端传递过来的aJsonStr转成的字符串
     * @return 返回结果字符串
     * @author hubing.tang,tong.jiang
     * @throws ApplicationException ApplicationException
     */
@WebService
public class PoApplyWsImpl implements IPoApplyWs{
    public String getSecondCheckerInfo(String aJsonStr)
        throws ApplicationException
    {
        Map<String, Object> aMap = JsonUtil.jsonStringToMap(aJsonStr);
        List<Map<String, Object>> aCheckerInfo = mPoApplySev.
                    getSecondCheckerInfo(aMap);
        String resultAllJsonStr = JsonUtil.transferStringByList(aCheckerInfo);

        int allRecords = mPoApplySev.getSecondCheckerTotalRecordsByidS(aMap);
        JSONObject json = new JSONObject();
        try
        {
            //存入记录总数
            json.put("total_row", allRecords);
            //存入记录列表
            json.put("secondCheckerList", resultAllJsonStr);
        }
        catch (JSONException e)
        {
            e.printStackTrace();
        }

        return json.toString();
    }
}


后台一侧的代码如下
           //调用查询所有审核人webservice接口
        IPoApplyWsProxy iPoApplyWsProxy=new IPoApplyWsProxy();
        String  output = iPoApplyWsProxy.getSecondCheckerInfo(sJson.toString());
        JSONObject resultJson = new JSONObject(output);     
        String resultListStr = resultJson.getString("secondCheckerList");        
        Integer records = (Integer)resultJson.get("total_row");
  List<CheckerConfigFormBean> list = commonResultList(output, resultListStr);


函数封装
      /**
     * <把查询出的数据封装成map>
     * @throws JSONException [参数说明]
     *
     * @return List<CheckerConfigFormBean> [返回类型说明]
     * @exception throws [违例类型] [违例说明]
     * @see [类、类#方法、类#成员]
     */
    private List<CheckerConfigFormBean> commonResultList(String output, String handler) throws AppException, JSONException
    {
        //把查询出的数据封装成map
        List<CheckerConfigFormBean> list = new ArrayList<CheckerConfigFormBean>();
        if (!"[]".equals(output.trim()))
        {

            List<Map<String, Object>> returnList = JsonUtil.jsonArrayToList(new JSONArray(handler));
            CheckerConfigFormBean checkerConfigFormBean = null;
            for(Map<String, Object> lists : returnList)
            {
               checkerConfigFormBean  = new CheckerConfigFormBean();
               checkerConfigFormBean.setProductLine((String)lists.get("PRODUCT_LINE"));
               checkerConfigFormBean.setProductFamily((String)lists.get("PRODUCT_FAMILY"));
               checkerConfigFormBean.setProduct((String)lists.get("PRODUCT"));
               checkerConfigFormBean.setChecker((String)lists.get("SECOND_HANDLER"));
               checkerConfigFormBean.setCode((String)lists.get("CODE"));
               list.add(checkerConfigFormBean);
             }
        }
        return list;
    }


你可能感兴趣的:(webservice)