1

我正在使用 Axis2 作为移动应用程序的 REST Web 服务,我正在编写一个进入 Axis2 IN 流的自定义阶段的安全处理程序,并且我在从请求中获取 POST 参数时遇到了一些麻烦;使用 GET 方法时,我能够成功检索这些参数,但在 POST 情况下,我得到的只是空值。非常感谢任何帮助

这是我的代码片段:

public InvocationResponse invoke(MessageContext mc) throws AxisFault {
    AxisMessage axisMessage = mc.getAxisMessage();

    System.out.println("***SecurityHandler Starting***");
    HttpServletRequest req =(HttpServletRequest)mc.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
    System.out.println("Method : "+req.getMethod());

    String username = req.getParameter(ARG_LOGIN);
    System.out.println("User login : "+ username);// User login : null
}
4

1 回答 1

0
HttpServletRequest obj = (HttpServletRequest)msgContext .
                                            getProperty("transport.http.servletRequest");
  if (obj != null) {
   System.out.println("Method :"+ obj.getMethod());
   System.out.println("Content-type :" +obj.getContentType());
   System.out.println("Content-length :"+obj.getContentLength());
   System.out.println("Remote addtress"+obj.getSession().getLastAccessedTime());  
  }

查看这篇文章[1]

[1] http://vvratha.blogspot.com/2013/08/extracting-http-level-information-in.html

于 2014-03-24T06:46:11.003 回答