以下OutInterceptor拦截器代码部分实现,因为webservice返回报文太长,导致数据无法回写到流中,无法拿到返回报文,求大大们帮忙解决啊。。。
public class WebLogOutInterceptor extends AbstractPhaseInterceptor<SoapMessage> {
private static final Logger logger = LoggerFactory.getLogger(WebLogOutInterceptor. class);
public WebLogOutInterceptor() {
super(Phase.PRE_STREAM);
}
public void handleMessage(SoapMessage message) throws Fault {
try {
OutputStream os = message.getContent(OutputStream.class);
CachedStream cs = new CachedStream();
message.setContent(OutputStream.class, cs);
message.getInterceptorChain().doIntercept(message);
CachedOutputStream csnew = (CachedOutputStream) message
.getContent(OutputStream.class);
InputStream in = csnew.getInputStream();
xml = IOUtils.toString(in);
Document document = DocumentHelper.parseText(xml);
IOUtils.copy(new ByteArrayInputStream(xml.getBytes(encoding)), os);
cs.close();
os.flush();
message.setContent(OutputStream.class, os);
} catch (Exception e) {
e.printStackTrace();
}finally{
}
}