CXF JAXB JAXBEncoderDecoder解组错误:具有限定元素时的意外元素 [英] CXF JAXB JAXBEncoderDecoder unmarshalling error : unexpected element when having qualified elements
问题描述
我遇到以下问题但无法找到解决方案:
WSDL在我收到的回复中有 elementFormDefault =qualified
我的CXF客户端所有元素都以命名空间为前缀,但JAXB抛出异常
I have the following problem and cannot find a solution:
The WSDL has elementFormDefault="qualified"
, in the response that I receive in my CXF client all the elements are prefixed with namespace but JAXB throws an exception
org.apache.cxf.interceptor.Fault: Unmarshalling Error: unexpected element (uri:"unm:ENTSCWS", local:"searchReturn"). Expected elements are
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:661)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:533)
at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:128) ...
如果我更改了WSDL elementFormDefault =unqualified
它正在运行,但我不允许更改WSDL,它应该具有前缀为命名空间的元素。
If i change in the WSDL elementFormDefault="unqualified"
it is working, but I am not allowed to change the WSDL, it should have the elements prefixed with the namespace.
package-info.java包含annotaction:
The package-info.java contains the annotaction:
@javax.xml.bind.annotation.XmlSchema(namespace = "unm:ENTSCWS", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package entscws;
响应类包含注释:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"searchReturn"
})
@XmlRootElement(name = "searchResponse")
public class SearchResponse {
你知道我为什么会收到这个错误吗?
Do you have any idea why I get this error?
推荐答案
你在跑步吗? OSGi的?我已经看到一些类似的问题,包裹信息没有在那里正确选择。
Are you running in OSGi? I've seen some similar issues with package-info's not being picked up properly there.
另一种选择可能是添加 -xjc-npa 标记为wsdl2java命令,让它根本不使用package-info并将名称空间粘贴在所有其他位置。
Another option could be to add the -xjc-npa flag to the wsdl2java command to have it not use the package-info at all and stick the namespaces in all the other places.
这篇关于CXF JAXB JAXBEncoderDecoder解组错误:具有限定元素时的意外元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!