使用CXF拦截HTTP响应 [英] Intercept HTTP response with CXF
问题描述
我正在使用CXF作为SOAP框架。
我同时拥有用于同步和异步调用的服务器和客户端接口。
I'm using CXF as SOAP framework. I've both server and client interfaces for synchronous and asynchronous calls.
我需要截获HTTP响应。详细信息:
What I need is intercept the HTTP response. More in detail:
-
对于服务器接口(双向同步):
我需要拦截客户端HTTP响应(如果一切正常,则为200)
For server interface (two way - sync): I need to intercept the client HTTP response (i.e. 200 if everything is fine)
对于客户端界面(一种方式-无肥皂响应):
与上述类似,我需要拦截服务器的HTTP响应
For Client interface (one way - no soap reponse): Similar as above, I need to intercept the server HTTP response
我试图同时配置inInterceptor和outInterceptor,但是我只能看到inBound和出界肥皂消息。相反,我需要的是查看outBound消息的HTTP响应。
I've tried to configure both inInterceptor and outInterceptor, but I can only see the inBound and outBound soap messages. Instead what I need is see the HTTP response on outBound messages.
预先感谢。
推荐答案
也许答案还为时不晚:-)
Maybe it is not too late for the answer :-)
我遇到了同样的问题,调试后我发现一个CXF客户端正在运行从输入流读取响应实体之前的侦听器。
因此,获得响应的唯一方法是:
I encounter the same problem and after debuging I found out that a CXF client runs interceptors before reading response entity from input stream. So the only way to get reponse is:
InputStream is = inMessage.getContent(InputStream.class)
然后阅读并整理适当的回复。
And read and marshall to proper response.
这篇关于使用CXF拦截HTTP响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!