-
1. Re: CXF - activate XML_DECLARATION from soap exchange
jcs_jean-claude.souvignet May 27, 2010 10:19 AM (in response to jcs_jean-claude.souvignet)Hello,
more detail on my need :
Client side, the XML result from my web service need the xml definition in the beginning of the message :
<?xml version="1.0" encoding="XXXXXXX"?>
<soap:Envelope ....
By default, my message begin with : <soap:Envelope ....
I don't know if it is possible to do so by CXF configuration. Does anybody have had the same need ?
Should I create my own interceptor and activate it in WRITE phase ?
thanks in advance for your help.
Edited by: jcs on May 27, 2010 2:18 PM
-
2. Re: CXF - activate XML_DECLARATION from soap exchange
njiang Jun 23, 2010 4:58 AM (in response to jcs_jean-claude.souvignet)Hi,
Because CXF write the XML message without using the SOAPMessage write method to write the message, so setting the SOAPMessage.WRITE_XML_DECLARATION to be true doesn't help you.
Here is CXF interceptor that did the trick, it will tell StaxOutInterceptor to write the xml start document for you.
public class WriteXmlDeclarationInterceptor extends AbstractPhaseInterceptor<SoapMessage> { public WriteXmlDeclarationInterceptor() { super(Phase.PRE_STREAM); addBefore(StaxOutInterceptor.class.getName()); } public void handleMessage(SoapMessage message) throws Fault { message.put("org.apache.cxf.stax.force-start-document", Boolean.TRUE); } }
Willem
-
3. Term Papers
albertwilson Aug 18, 2010 12:35 AM (in response to jcs_jean-claude.souvignet)I'm very thankful to the author for posting such an amazing development post. Continuing to the post. Thanks.
-
4. Re: CXF - activate XML_DECLARATION from soap exchange
jcs_jean-claude.souvignet Aug 23, 2010 5:30 AM (in response to jcs_jean-claude.souvignet)Thanks to Willen Njiang.
WriteXmlDeclarationInterceptor do the stuff.