Hi Andrei,

Currently, I am simply removing <stackTrace> node from SOAPFault Element.

We are required to log the stack traces to a table, via sending the logs to
an MQ server, and have a listener application (of some sort) to insert them
to the database table as they become available (haven't defined the process
thoroughly at this point).

And the main reason we are using JAX-WS Handlers (CXF implementation),
again, is due to requirements (the client does not want dependency on CXF
features, which makes you wonder why not just use IBM's WebSphere
implementation!). And all the messages sent to queues and streaming,
specially when a heavy load is to be expected... it's going to be a problem.


On Wed, Apr 23, 2014 at 4:15 PM, Andrei Shakirin <[email protected]>wrote:

> Hi,
>
> I do not think that it can be done automatically, but you can manipulate
> stack trace (reading, removing, etc) in JAX-WS Handler.
> Some questions of curiosity:
> 1) why stack trace in server log files is not enough for you proposals?
> Are you going to implement kind of automated stack trace processing?
> 2) Is there any special reason why you using JAX-WS Handlers instead CXF
> Interceptors? Despite of fact that handlers are JAX-WS standard, they can
> introduce performance bottleneck, because handlers do not support message
> streaming.
>
> Regards,
> Andrei.
>
> > -----Original Message-----
> > From: Evan J [mailto:[email protected]]
> > Sent: Mittwoch, 23. April 2014 16:01
> > To: [email protected]
> > Subject: Re: Accessing Stack Trace in CXF implementation of JAX-WS
> Handler
> >
> > Thank you Andrei.
> >
> > That's actually my intent to simply log the stack trace. However, it
> seems like
> > the only way to trigger the SOAPFault to contain stack trace in its
> content is to
> > enable stack tracing in the config file, i.e.:
> >
> >     <cxf:bus>
> >         <cxf:features>
> >             <cxf:logging/>
> >         </cxf:features>
> >
> >         <cxf:properties>
> >                    <entry key="faultStackTraceEnabled" value="true"
> > />
> >         </cxf:properties>
> >     </cxf:bus>
> >
> > However, this would force the SOAP response to contain
> > <details><stackTrace>...</stackTrace></details>. I wonder if there is a
> way to
> > force CXF implementation of JAX-WS Handler to provide the stack trace
> but to
> > strip it before sending it back. I know you can manually manipulate the
> > stackTrace element, i.e.:
> >
> >             SOAPFault soapFault =
> ctx.getMessage().getSOAPBody().getFault();
> >             if (soapFault.hasDetail()) {
> >                 NodeList nodeList =
> > soapFault.getDetail().getElementsByTagName("stackTrace");
> >
> >                 for (int i = 0; i < nodeList.getLength(); i++) {
> >                     Node node = nodeList.item(i);
> >
> >                     if (node.getNodeType() == Node.ELEMENT_NODE) {
> >                         Element stackTraceElement = (Element) node;
> >
> >
> > LOG.error(stackTraceElement.getTextContent().substring(0, 4000));
> >                         soapFault.getDetail().setTextContent("Something
> > dreadfully went wrong!");
> >                     }
> >                 }
> >             }
> >
> > Is there a way to exclude the stackTrace automatically but have it
> available for
> > logging in SOAPHandler<SOAPMessageContext>?
> >
> >
> > On Wed, Apr 23, 2014 at 4:16 AM, Andrei Shakirin
> > <[email protected]>wrote:
> >
> > > Hi,
> > >
> > > I assume that you mean JAX-WS Handlers.
> > > Basically you have access to SOAPFault message from public boolean
> > > handleFault(SOAPMessageContext ctx).
> > > If SOAPFault contains stack trace or doesn't depends on service side
> > > implementation and type of exception throwing by service.
> > > The best practice is to include only error message in SOAPFault and
> > > log stack trace. The reason is security (stack trace exposes
> > > implementation details can give hint to attacker) and exception
> > > layering (normal service user should receive corresponded business
> > > error message, not the technical details).
> > >
> > > Regards,
> > > Andrei.
> > >
> > > > -----Original Message-----
> > > > From: Evan J [mailto:[email protected]]
> > > > Sent: Montag, 21. April 2014 04:33
> > > > To: [email protected]
> > > > Subject: Accessing Stack Trace in CXF implementation of JAX-WS
> > > > Handler
> > > >
> > > > Hi,
> > > >
> > > > 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 a 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.
> > > >
> > > >
> > > > Thank you
> > >
>

Reply via email to