接收xml请求流并解析字符串的例子

 //接收请求发来的xml消息体,并返回xml字符串
public static String recieveData(HttpServletRequest request)
    {
       
        String inputLine = null;
        // 接收到的数据
        StringBuffer recieveData = new StringBuffer();
       
        BufferedReader in = null;
        try
        {
            in = new BufferedReader(new InputStreamReader(
                    request.getInputStream(), "UTF-8"));
            while ((inputLine = in.readLine()) != null)
            {
                recieveData.append(inputLine);
            }
        }
        catch (IOException e)
        {
        }
        finally
        {
           
            try
            {
                if (null != in)
                {
                    in.close();
                }
            }
            catch (IOException e)
            {
            }
           
        }
       
        return recieveData.toString();
    }

原文地址:https://www.cnblogs.com/qqzy168/p/3136962.html