问题
is there a way to manipulate the marshaller used in jaxws. I like to send a cdata filed in a webservice request and for this i want to try something like describet here: http://odedpeer.blogspot.de/2010/07/jaxb-sun-and-how-to-marshal-cdata.html
in short they does this:
Marshaller m = JAXBContext.newInstance( Item.class ).createMarshaller();
m.setProperty( "com.sun.xml.internal.bind.characterEscapeHandler", new CharacterEscapeHandler() {
@Override
public void escape( char[] ac, int i, int j, boolean flag, Writer writer ) throws IOException
{
// do not escape
writer.write( ac, i, j );
}
});
is this possible with jaxws somehow?
回答1:
Well, the answer to your question is:
JAX-WS is based on JAXB so yes, it is possible, just create JAXB related stuff (as you showed in your question) in your application and you'll be able to process XML from your request in your web service.
来源:https://stackoverflow.com/questions/9907855/manipulate-marshaller-in-jax-ws