The problem with your approach is that the original input stream of the request message is already gone/consumed when the control lands on the fault chain.
One idea would be to use a similar message capturing approach used by the logging interceptor in the in-chain but instead of always writing out the captured message after the stream is consumed, keep its reference in the exchange so that you can write it out from your fault handler when the control reaches there. In this approach, you would need another interceptor in the normal out-chain to clean up any temporary resource associated with this reference. regards, aki 2012/6/26 Sonoerin <[email protected]>: > Good day, > > Is there anyway to capture a SOAP request that causes a Unmarshall > Exception? I created a fault interceptor that fires off when the exception > occurs, but I have not been able to figure out how to capture the actual > request so I can store it on the file system. I have tried various parent > interceptors and various phases, but I only get partial request at best > > Here is my attempt: > p/ublic class MyFaultInterceptor extends AbstractSoapInterceptor { > > public MyFaultInterceptor() { > super(Phase.POST_PROTOCOL); // MARSHAL seems more promising? > } > > @Override > public void handleMessage(SoapMessage message) throws Fault { > > if (message instanceof SoapMessage) { > LOGGER.error("MyFaultInterceptor Invoked "); > try { > Exchange exchange = message.getExchange(); > if (exchange != null) { > SoapMessage exMessage = (SoapMessage) > exchange.getInMessage(); > InputStream inmessage = > exMessage.getContent(InputStream.class); > String payload = > MyRestUtilities.extractStringFromPayload(inmessage); > > savePayloadToFile(payload); > } > } catch (Exception e) { > LOGGER.error(e.getMessage()); > } > } > }/ > > And here is how I invoke it: > /<cxf:jaxws-service serviceClass="my.WebService" validationEnabled="false"> > > <cxf:outFaultInterceptors> > <spring:bean id="faultInterceptor" > class="MyFaultInterceptor"/> > </cxf:outFaultInterceptors> > </cxf:jaxws-service>/ > > This has been driving me nuts and I have not found a way to extract the > actual request (headers optional) into a string so I can write to a file. > > > > -- > View this message in context: > http://cxf.547215.n5.nabble.com/Interceptor-capture-of-SOAP-request-tp5710324.html > Sent from the cxf-user mailing list archive at Nabble.com.
