CXF JAXB JAXBEncoderDecoder unmarshalling error : unexpected element when having qualified elements
I have the following problem and cannot find a solution:
The WSDL haselementFormDefault="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.cx开发者_运维百科f.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) ...
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.
The package-info.java contains the annotaction:
@javax.xml.bind.annotation.XmlSchema(namespace = "unm:ENTSCWS", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package entscws;
The response class contains the annotation:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"searchReturn"
})
@XmlRootElement(name = "searchResponse")
public class SearchResponse {
Do you have any idea why I get this error?
Are you running in OSGi? I've seen some similar issues with package-info's not being picked up properly there.
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.
精彩评论