Hello,

I have an inbound interceptor on the client side, that is correctly
contributed, added and invoked:

2012-04-03 16:58:07,453 DEBUG  [ClientImpl] Interceptors contributed by
client: [no.nki.stas.ws.client.interceptor.XmlInInterceptor@1fc3828,
org.apache.cxf.interceptor.LoggingInInterceptor@1cb048e]

2012-04-03 16:58:07,454 DEBUG  [PhaseInterceptorChain] Adding interceptor
no.nki.stas.ws.client.interceptor.XmlInInterceptor@1fc3828 to phase receive

2012-04-03 16:58:07,457 DEBUG  [PhaseInterceptorChain] Invoking
handleMessage on interceptor
no.nki.stas.ws.client.interceptor.XmlInInterceptor@1fc3828 
2012-04-03 16:58:07,457 DEBUG  [XmlInInterceptor] ============>> In client
handleMessage 

But its registered callback is not fired up.

The logger "============>> In LoggingCallback constructor" is not displayed
in the console log, nor is the logger "============>> In onClose".

Here is my interceptor class:

@NoJSR250Annotations
public class XmlInInterceptor extends AbstractSoapInterceptor {

        private Logger logger = LoggerFactory.getLogger(XmlInInterceptor.class);

        public XmlInInterceptor() {
                super(Phase.RECEIVE);
        }

        public void handleMessage(SoapMessage soapMessage) throws Fault {
                logger.debug("============>> In handleMessage");
                final OutputStream os = 
soapMessage.getContent(OutputStream.class);
                if (os == null) {
                        return;
                }
                final CacheAndWriteOutputStream newOut = new
CacheAndWriteOutputStream(os);
                soapMessage.setContent(OutputStream.class, newOut);

                newOut.registerCallback(new LoggingCallback(soapMessage, os));
        }

        private class LoggingCallback implements CachedOutputStreamCallback {
                
                private final Message message;
                private final OutputStream origStream;

                public LoggingCallback(final Message msg, final OutputStream 
os) {
                        this.message = msg;
                        logger.debug("============>> In LoggingCallback 
constructor");
                        this.origStream = os;
                }

                public void onFlush(CachedOutputStream cos) {
                }

                public void onClose(CachedOutputStream cos) {
                        logger.debug("============>> In onClose");
                        String encoding = (String) 
message.get(Message.ENCODING);
                        String ct = (String) message.get(Message.CONTENT_TYPE);
                        StringBuilder builder = new StringBuilder();
                        try {
                                writePayload(builder, cos, encoding, ct);
                        } catch (IOException ex) {
                                throw new RuntimeException("Cannot generate 
audit log for soap
response", ex);
                        }

                        String msg = builder.toString();
                        logger.debug("CLIENT IN MESSAGE {}", msg);
                        message.setContent(OutputStream.class, origStream);
                }

                protected void writePayload(StringBuilder builder, 
CachedOutputStream cos,
String encoding, String contentType) throws IOException {
                        if (StringUtils.isEmpty(encoding)) {
                                cos.writeCacheTo(builder);
                        } else {
                                cos.writeCacheTo(builder, encoding);
                        }
                }

        }

}

Kind Regards,

Stephane


--
View this message in context: 
http://cxf.547215.n5.nabble.com/Client-inbound-interceptor-registered-callback-not-fired-up-tp5615483p5615483.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to