Hi All,

I am writing an SAAJInInteceptor to manipulate the incoming response
message. I want to trim all the empty elements specifically Calendar Objects
because CXF is trying to parse an null object during unmarshalling. 

I've added the interceptor to my factoryBean before creating the port

factoryBean.inInterceptors.add(new
SAAJTrimEmptyElementsInInterceptor(cxfRequestData,
excludeFromTrimOperationNames))
factoryBean.create()

and returns the port created by factoryBean

in my interceptor class

public SAAJTrimEmptyElementsInInterceptor(CxfRequestData cxfRequestData,
List<String> excludeOutboundRequests) {
        super(Phase.PRE_PROTOCOL)
        addAfter(SAAJInInterceptor.class.getName())
        this.cxfRequestData = cxfRequestData
        excludeFromTrimOperationNames = excludeOutboundRequests
    }

@Override
    void handleMessage(SoapMessage soapMessage) {
        if(shouldTrimMessage(soapMessage)){
            if (soapMessage.getContent(SOAPMessage.class) == null) {
                getSaajInInterceptor().handleMessage(soapMessage)
            }
            SOAPMessage msg = soapMessage?.getContent(SOAPMessage.class)
            
            SOAPBody body = msg?.SOAPBody

            body?.childElements?.each {
                if (it instanceof SOAPElement) {
                    removeNil(it)
                }
            }
        }
    }

where removeNil is a recursive method which trims the xsi:nil child nodes. 

I println() the soap body at the beginning the method to make sure it's
created and at the end of method to make ensure the method has worked.
However, after this interceptor, my response data is all null.

Interceptor happens on this line of code.

def response = port.getData(some arguments) 

If I remove the interceptor or the content my handleMessage, the response
data comes back just fine. But, with println(), I can see the body message
pass through the handleMessage method. I've tried a lot of things, including
changing the Phase of the interceptor and none has worked.

Why is my soap message/response data disappearing? Please let me know what
else I can provide to clarify my issue. Thanks!!




--
View this message in context: 
http://cxf.547215.n5.nabble.com/Response-data-equals-to-null-after-SAAJInInterceptor-handle-message-tp5726342.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to