Store Axis raw XML request/response in session (to

2019-03-22 02:33发布

How, if possible, do I get the raw XML request/response that is invoked/retrieved by Axis in my application?

I'm using WSDL2Java that is included with Axis to generate the Java stubs.

EDIT:

What I currently have is an app that uses Axis to handle the remote API calls.

One of the requirement is to 'store' all the XML request/response from these calls in the session so that it will be available in the JSP (for debugging purposes). How can I achieve this?

I tried writing a custom handler that extends BasicHandler but in that handler, I still can't get the HttpServletRequest/HttpServletResponse pair from the MessageContext

3条回答
狗以群分
2楼-- · 2019-03-22 02:42

I end up using the solution described in this question

Basically, I use it to get a hold of the HttpServletRequest and from there I set the proper item in the session.

查看更多
贪生不怕死
3楼-- · 2019-03-22 02:50

Why don't you write a server side soap handler, get hold of MessageContext and I believe there is a way to get hold of the payload from there. If you want to pass it to downstream then put it in thread local. See e.g. of handler here

查看更多
forever°为你锁心
4楼-- · 2019-03-22 02:51

After a while searching its as simple as this:

//After your _call.invoke(...);

//Request
String request = _call.getMessageContext().getRequestMessage().getSOAPPart().getEnvelope().getBody().toString();

//Response
String response = _call.getMessageContext().getResponseMessage().getSOAPPart().getEnvelope().getBody().toString();

where _call is org.apache.axis.client.Call

Then you can save it in a file where you want...

查看更多
登录 后发表回答