Reputation: 17795
I have a SOAP service which one of the methods accepts a String as a parameter. However, the expectation is that this String is XML.
When I call this service, CXF encodes the XML for me by default, like so:
<ORM_O01><MSH>
Even though when I called it, I called it like so:
<ORM_O01><MSH>
Is there a way to turn this off? I would like CXF to just send what I've specified and not an encoded version.
I am using CXF 2.7.8 and JDK 1.7.
Thanks in advance.
Upvotes: 0
Views: 932
Reputation: 17795
I'm pretty sure this is not the best way to do it, but it worked for me:
public class MyClass extends AbstractPhaseInterceptor< Message > {
public MyClass () {
super( Phase.PRE_STREAM );
addAfter( AttachmentOutInterceptor.class.getName() );
}
@Override
public void handleMessage( final Message message ) throws Fault {
message.put( "disable.outputstream.optimization", Boolean.TRUE );
final SimpleNsStreamWriter writer = (SimpleNsStreamWriter)StaxUtils.createXMLStreamWriter( message.getContent( OutputStream.class ) );
message.setContent( XMLStreamWriter.class, new DelegatingXMLStreamWriter( writer ) {
@Override
public void writeCharacters( final String text ) throws XMLStreamException {
System.out.println( "text -> " + text );
writer.writeRaw( text );
}
} );
}
Upvotes: 2