Skip to main content
 首页 » 编程设计

servlets之从 HttpServletRequest 中提取 SOAP 对象

2024年07月26日8bonelee

如何从 HttpServletRequest 中提取 SOAP 对象。

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

        public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException  

我想从 HttpServletRequest 中提取 SOAP 请求吗?

请您参考如下方法:

试试这个:

    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);