依然一叶
2017-12-23 15:13cxf client 添加输出拦截器,server端收不到消息。
5cxf 框架 搭建的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 {
}
}
}
- 点赞
- 回答
- 收藏
- 复制链接分享
1条回答
为你推荐
- WebSphere6.1成功部署了CXF应用,但不知道为什么要添加类装入器
- websphere
- webservice
- cxf
- 0个回答
- CXF怎样通过代码方式发布WebService到当前WEB容器?
- cxf
- 0个回答
- CXF怎样查看SOAP消息?
- it技术
- 互联网问答
- IT行业问题
- 计算机技术
- 编程语言问答
- 0个回答
- 使用cxf能不能查看soap
- soa
- 0个回答
- maven中 cxf包排除依赖问题。为什么无法排除依赖呢? 很奇怪,大家可以试一下。【请看下面图片】
- maven
- cxf
- 5个回答
换一换