CXF处置不规则SOAP message(转)
CXF处理不规则SOAP message(转)2011-03-04 11:05:14|??分类: java |??标签: |字号大中小?订阅 在CXF Chain
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);