cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jay Prakash <jayprakash2...@gmail.com>
Subject Unable to get SOAPBody in interceptor
Date Tue, 19 Aug 2014 22:00:08 GMT
Hello,
       I've reading about CXF interceptor and I'm writing one currently
which will read parts of incoming SOAP request and log them (for now).

public class SampleInterceptor extends AbstractSoapInterceptor {

       public SampleInterceptor () {
super(Phase.POST_PROTOCOL);
addAfter(SAAJInInterceptor.class.getName());
}

        @Override
public void handleMessage(final SoapMessage message) throws Fault {
                final SOAPMessage saaj =
message.getContent(SOAPMessage.class);
final SOAPBody document;
try {
document = saaj.getSOAPPart().getEnvelope().getBody();
//document = saaj.getSOAPBody();
} catch (final SOAPException e) {
logger.error("", "Unable to get SOAP body from request", e);
throw new Fault(e);
}
                // log some nodes in the document.
         }
}

Also I've added the SAAJ interceptor to the incoming interceptor chain at
the endpoint like this.

<jaxws:inInterceptors>
        <bean id="saajInInterceptor"
class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor"/>
        <ref bean="sampleInterceptor"/>
    </jaxws:inInterceptors>

The problem is that the document is coming out as null/empty (in both
forms).

(com.sun.xml.internal.messaging.saaj.soap.ver1_1.Body1_1Impl)
[soapenv:Body: null]

In debug mode I see that SAAJInInterceptor was executed in PRE_PROTOCOL
phase and thus I am expecting a SAAJ model (also
message.getContentFormats() shows SOAPMessage in it).

I'm using CXF 2.7.1 and I'd appreciate any pointers on why this is showing
up as empty.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message