Malvon
Malvon

Reputation: 1621

Capturing Stack Trace with CXF Handler

I have not been able getting CXF 2.7.x's Handlers to work with WebSphere v7 (web services without Handlers do work accordingly), however, I wanted to know whether it is possible to access the stack trace, if thrown by a web service, via CXF's Handler (not Interceptor)?

Namely, if I implement SOAPHandler<SOAPMessageContext>, would I be able to capture the stack trace in public boolean handleFault(SOAPMessageContext ctx), via, say, ctx.getMessage().getSOAPBody().getFault()?

Normally, when an exception is thrown, I see a brief description in the fault detail of SOAP response, so I do not know whether SoapFault object would contain information about the stack trace in the first place!

The reason I am asking is, before being able to get CXF Handler working with WebSphere, I need to know whether seeking a stack trace in handleFault() is a viable option to begin with or am I going down the wrong rabbit hole.

Upvotes: 1

Views: 704

Answers (1)

Malvon
Malvon

Reputation: 1621

One way to have CXF JAX-WS services to have the stack trace available in the Handler is to have the option enabled in the config file, i.e. Spring's:

<cxf:bus>
  <cxf:features>
        <cxf:logging/>
      </cxf:features>

      <cxf:properties>
     <entry key="faultStackTraceEnabled" value="true" />            
  </cxf:properties>
</cxf:bus>

However, if you wish to only have access to the stacktrace content but not to send it back to the service consumer, you have to manually/programmatically obtain <stacktrace> Element and set its content to empty, or better, remove the Element itself.

Upvotes: 2

Related Questions