CXF-Web服务端点已更改,WSDL尚未更改 [英] CXF - webservice endpoint has changed, WSDL has not

查看:83
本文介绍了CXF-Web服务端点已更改,WSDL尚未更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序使用CXF WSDL2JAVA从客户端提供的WSDL生成Java类.

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

他们现在已经更改了Web服务,以在响应中添加3个其他字符串字段.对于我们来说,重新生成Java类将需要一些工作,但是我们遇到了一个例外:

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:编组错误:意外元素(newElement)

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

有没有办法让CXF忽略响应中的多余元素?

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

推荐答案

如果添加以下端点属性:

If you add an endpoint property of:

将"set-jaxb-validation-event-handler"设置为"false"

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

然后,CXF不会将事件处理程序添加到JAXB解组器中,而意外元素将被静默忽略.您需要确保消息的其余部分完全正确,因为如果消息不正确,您将不会收到任何错误或任何消息.例如,通常发生的事情是,当JAXB期望不合格的元素时,有人发送了合格的元素.如果不设置处理程序,则对象中的所有字段最终都将变为"null".使用处理程序,您将收到如下消息:

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:

意外元素(uri:" http://my.namespace.com ",本地:"myField").期望的元素是< {} myField>

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

,因此您可以看到名称空间限定是原因.

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

这篇关于CXF-Web服务端点已更改,WSDL尚未更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆