This really depends on what your "third party transformer" expects.
If the thirdparty thing expects a DOM or is optimized for a DOM type thing, the easier thing to do is configure in the SAAJOutInterceptor. See: http://cxf.547215.n5.nabble.com/How-To-Modify-The-Raw-XML-message-of-an-Outbound-CXF-Request-td4659707.html#a4662921 for an example that manipulates things on a DOM level. If you NEED to do String things, it's a bit more complicated. You'd likely want to create a StringWriter, save that on the message. Wrapper that with an XMLStreamWriter, set that into the message content saving the original. That would all be in PRE_PROTOCOL I think. Then, in a second interceptor in POST_PROTOCOL, grab those from the message, transform, grab the original XMLStreamWriter, and copy the events to it. (Use the CXF StaxUtils class to help) Dan On Monday, August 15, 2011 10:10:42 AM Sally Naga wrote: > Hello, > > I consider myself as a beginner in CXF so pardon me if these are naive > questions. > > We are using CXF to expose a java service/api as a soap webservice. The > service works well accepting an incoming soap request, unmarshalling to > java objects, exeuting the webmethod and marshalling the xml response. > > Now, I have a requirement to intercept the response soapbody, pass the xml > to a 3rd party transformer api. The transformer will return new xml and > this needs to be replaced and returned as soapbody (instead of the default > one generated from return objects). > > The pseudo code for the requirement is as follows: > String strResponseBody = GetSoapBodyForResponse(); > String strNewResponseBody = > thirdPartyTransformer.transform(strResponseBody); > SetOutSoapBodyContent(strNewResponseBody); > > I must extract and replace the response soap body in xml format and cannot > transform at the java object level. > > What phase should this interceptor intercept and in what order? What base > interceptor class should be used? What would be the api's to extract and > set soap body content for response? > > Thank you > Sally -- Daniel Kulp [email protected] http://dankulp.com/blog Talend - http://www.talend.com
