CXF注释:如何容错?

时间:2018-06-04 19:01:18

标签: java jaxb cxf jax-ws jaxb2

是否有注释告诉JAXB(或具有CXF 3.1的配置?)更具容错能力?

DTO类属性:

private List<Address> address;

解析了部分XML SOAP响应:

<address xsi:type="axis2ns185:anyType">
  <empty>true</empty>
</address>

抛出异常:

Caused by: com.sun.istack.SAXParseException2; ...; 
unexpected element (uri:"", local:"empty"). Expected elements are ...

我希望这个场景导致一个空的Address ...

列表

1 个答案:

答案 0 :(得分:0)

在解析过程中删除验证(和验证中的异常):

JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
Map<String, Object> propertiesMap = new HashMap<String, Object>();
propertiesMap.put("set-jaxb-validation-event-handler", "false");
factory.setProperties(propertiesMap);