解决由于服务器调用删除或添加字段后CXF客户端未更新导致异常问题org.apache.cxf.interceptor.Fault: Unmarshalling Error: Unexpected element

采用CXF客户端调用Webservice服务,由于服务端时不时会对Webservice服务删除或添加一些字段,而CXF未及时更新客户端代码导致再次调用服务时报异常错误:

Interceptor for {Mystifly.OnePoint}OnePoint#{Mystifly.OnePoint}AirRevalidate has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Unmarshalling Error: 意外的元素 (uri:"http://schemas.datacontract.org/2004/07/Mystifly.OnePoint", local:"NameNumbers")。所需元素为<{http://schemas.datacontract.org/2004/07/Mystifly.OnePoint}Services> 

解决这个问题有二个方式:
1、根据最新的服务wsdl规范更新CXF客户端代码

2、给CXF设置属性禁用CXF的Jabx对xml的检验

client.getRequestContext().put("set-jaxb-validation-event-handler", false);

转载:https://www.iflym.com/index.php/code/201307310001.html

原文地址:https://www.cnblogs.com/boazy/p/10570677.html