CXF处理不规则SOAP message


在CXF ChainInitiationObserver 类的onMessage(Message)方法里修改 SOAP message。
修改 ChainInitiationObserver 类:

            addToChain(phaseChain, message);

            //新增代码
            InputStream is = message.getContent(InputStream.class);
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            String inputLine;
            String pisinfo = "";
            while ((inputLine = br.readLine()) != null) {
                if(inputLine.indexOf("0){
                    inputLine="      ";
                }
                if(inputLine.indexOf("
0){
                    inputLine="      ";
                }
                pisinfo=pisinfo+inputLine+"\r\n";
              }
            System.out.println(pisinfo);
            ByteArrayInputStream bais= new ByteArrayInputStream(pisinfo.getBytes());
            CachedOutputStream bos = new CachedOutputStream();
            IOUtils.copy(bais, bos);
            bos.flush();
            bais.close();
            is.close();

            message.setContent(InputStream.class, bos.getInputStream());
            //新增代码结束,下接原始代码
            phaseChain.doIntercept(message);

你可能感兴趣的:(CXF处理不规则SOAP message)