cdata标记特殊字符cxf注解怎么写
1个回答
2017-02-27 · 知道合伙人互联网行家
关注
展开全部
public class CDATAInterceptor extends AbstractPhaseInterceptor<Message> {
public CDATAInterceptor(String phase) {
super(phase);
}
public void handleMessage(Message message) {
XMLStreamWriter writer = (XMLStreamWriter) message.getContent(XMLStreamWriter.class);
if (writer != null && !(writer instanceof MyXmlWriter)) {
message.setContent(XMLStreamWriter.class, new MyXmlWriter(writer));
}
}
}
我已经把它添加到任何可能的阶段(以防万一-也许我应该把在编组或PRE_MARSHAL)。下面是代码,我怎么添加拦截器:MyService service = new MyService(new URL(http://my_url_adress?wsdl));
proxy = service.getMyServiceSoap12();
Client client = ClientProxy.getClient(proxy);
client.getOutInterceptors().add(new CDATAInterceptor(Phase.INVOKE));
client.getOutInterceptors().add(new CDATAInterceptor(Phase.MARSHAL));
client.getOutInterceptors().add(new CDATAInterceptor(Phase.MARSHAL_ENDING));
client.getOutInterceptors().add(new CDATAInterceptor(Phase.POST_INVOKE));
client.getOutInterceptors().add(new CDATAInterceptor(Phase.POST_LOGICAL));
client.getOutInterceptors().add(new CDATAInterceptor(Phase.POST_LOGICAL_ENDING));
public CDATAInterceptor(String phase) {
super(phase);
}
public void handleMessage(Message message) {
XMLStreamWriter writer = (XMLStreamWriter) message.getContent(XMLStreamWriter.class);
if (writer != null && !(writer instanceof MyXmlWriter)) {
message.setContent(XMLStreamWriter.class, new MyXmlWriter(writer));
}
}
}
我已经把它添加到任何可能的阶段(以防万一-也许我应该把在编组或PRE_MARSHAL)。下面是代码,我怎么添加拦截器:MyService service = new MyService(new URL(http://my_url_adress?wsdl));
proxy = service.getMyServiceSoap12();
Client client = ClientProxy.getClient(proxy);
client.getOutInterceptors().add(new CDATAInterceptor(Phase.INVOKE));
client.getOutInterceptors().add(new CDATAInterceptor(Phase.MARSHAL));
client.getOutInterceptors().add(new CDATAInterceptor(Phase.MARSHAL_ENDING));
client.getOutInterceptors().add(new CDATAInterceptor(Phase.POST_INVOKE));
client.getOutInterceptors().add(new CDATAInterceptor(Phase.POST_LOGICAL));
client.getOutInterceptors().add(new CDATAInterceptor(Phase.POST_LOGICAL_ENDING));
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询