CXF - webservice endpoint has changed, WSDL has not

拜拜、爱过 提交于 2021-01-29 11:25:43

问题


My application used CXF WSDL2JAVA to generate the Java classes from a client supplied WSDL.

They've now changed their webservice to have 3 additional string fields in the response. It would be a bit of rework for us to regenerate the java classes, but we're getting an exception:

javax.xml.ws.soap.SOAPFaultException: Unmarshalling Error: unexpected element (newElement)

Is there a way to get CXF to ignore the extra elements in the response?


回答1:


If you add an endpoint property of:

"set-jaxb-validation-event-handler" to "false"

then CXF will not add an event handler into the JAXB unmarshaller and the unexpected elements are silently ignored. You'll need to make sure the rest of the message is exactly correct though as you will not get any errors or anything if the message isn't correct. For example, the common thing to happen is someone sends qualified elements when JAXB is expecting unqualified elements. Without setting the handler, all the fields in the object would end up as "null". With the handler, you would get a message like:

unexpected element (uri:"http://my.namespace.com", local:"myField"). Expected elements are <{}myField>

so you can see that the namespace qualification is the reason.



来源:https://stackoverflow.com/questions/17798196/cxf-webservice-endpoint-has-changed-wsdl-has-not

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!