从HttpServletRequest中提取SOAP对象

Mor*_*gel 3 soap servlets cxf

如何从HttpServletRequest中提取SOAP对象.

在我的过滤器AuthenticationEntryPoint中,我有方法

        public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException 
Run Code Online (Sandbox Code Playgroud)

我想从HttpServletRequest中提取SOAP请求?

小智 8

试试这个:

    MessageFactory messageFactory = MessageFactory.newInstance();
    InputStream inStream = request.getInputStream();
    SOAPMessage soapMessage = messageFactory.createMessage(new MimeHeaders(), inStream);
    PrintWriter writer = response.getWriter(); 
    ByteArrayOutputStream out = new ByteArrayOutputStream(); 
    soapMessage.writeTo(out); 
    String strMsg = new String(out.toByteArray()); 
    writer.println(strMsg); 
Run Code Online (Sandbox Code Playgroud)