cxf 框架 搭建的webservice 客户端 配置了 outInterceptor 消息就发不到server 就超时报错。去掉这个拦截器 就好使了。。。。 但是这个拦截器 也没看出什么问题 。
流的问题? client端流没关闭,server端收不到?
跪求大神指点
以下是这个拦截器代码:
public class ClientOutInterceptor extends AbstractPhaseInterceptor {
public ClientOutInterceptor() {
super(Phase.PRE_STREAM);
}
public ClientOutInterceptor(String phase) {
super(phase);
}
@Override
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();
String xml = IOUtils.toString(in);
System.out.println(xml);
//这里对xml做处理,处理完后同理,写回流中
IOUtils.copy(new ByteArrayInputStream(xml.getBytes("UTF-8")), os);
cs.close();
os.flush();
message.setContent(OutputStream.class, os);
} catch (Exception e) {
e.printStackTrace();
}
}
private class CachedStream extends CachedOutputStream {
public CachedStream() {
super();
}
protected void doFlush() throws IOException {
currentStream.flush();
}
protected void doClose() throws IOException {
}
protected void onWrite() throws IOException {
}
}
}