Reputation: 514
After setting up
<cxf:properties>
<entry key="faultStackTraceEnabled" value="true" />
</cxf:properties>
I was able to get the stack trace. But I am struggling to remove it from the outgoing message.
I tried with following code:
Fault fault = (Fault) message.getContent(Exception.class);
StackTraceElement[] stackTrace = fault.getCause().getStackTrace();
List<StackTraceElement> tempList = new ArrayList<StackTraceElement>(Arrays.asList(stackTrace));
tempList.removeAll(tempList);
stackTrace = tempList.toArray(new StackTraceElement[0]);
fault.getCause().setStackTrace(stackTrace);
message.setContent(Exception.class, fault);
Even though the last line is setting the content back with empty stackTrace but the outgoing message still has the full stack trace.
Can you provide some code snippet how to remove the <stackTrace>
?
Upvotes: 2
Views: 1106
Reputation: 514
@soilworker I was able to achieve what I was looking for. I was looking for stackTrace for logging.
I removed the following lines
<cxf:properties>
<entry key="faultStackTraceEnabled" value="true" />
</cxf:properties>`
Code:
Fault fault = (Fault) message.getContent(Exception.class);
String exceptionMsg = null;
for (StackTraceElement element : fault.getCause().getStackTrace()) {
exceptionMsg = // concatenate
}
So no <stackTrace>
present in outgoing message.
But it will interesting to know how to modify the outgoing fault (like add additional tags) in the outgoing interceptor.
Thanks.
Upvotes: 1