`
huiseyiyu
  • 浏览: 102477 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

CXF处理不规则SOAP message(转)

 
阅读更多

CXF处理不规则SOAP message  

2011-03-04 11:05:14|  分类: java |  标签: |字号 订阅


在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("<IfService")>0){
                    inputLine="      <tns:IfService xmlns:tns=\"http://service.jsict.com/\">";
                }
                if(inputLine.indexOf("</IfService")>0){
                    inputLine="      </tns:IfService>";
                }
                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);
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics