JAXB,CXF:没有ObjectFactory和元素的@XmlElementDecl ...

rah*_*hul 10 java wsdl cxf jaxb

我正在使用JAXB和CXF创建WSDL第一个Web服务.我没有WSDL,所以我不能对它进行更改.我使用ftp://ftp.ihe.net/TF_Implementation_Material/ITI/wsdl/PIXManager.wsdl作为我的WSDL.我使用CXF 2.3.0生成Java类.

Java类生成很顺利,但是当我尝试在Web应用程序中运行它时,我收到错误

com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 17 counts of IllegalAnnotationExceptions
Run Code Online (Sandbox Code Playgroud)

17个计数的格式

There's no ObjectFactory with an @XmlElementDecl for the element {urn:hl7-org:v3}assignedDevice.
        this problem is related to the following location:
            at protected javax.xml.bind.JAXBElement org.hl7.v3.QUQIMT021001UV01AuthorOrPerformer.assignedDevice
Run Code Online (Sandbox Code Playgroud)

当我去上面提到的类,即QUQIMT021001UV01AuthorOrPerformer并查看已分配设备的字段时,我看到了这个

@XmlElementRef(name = "assignedDevice", namespace = "urn:hl7-org:v3", type = JAXBElement.class)
protected JAXBElement<COCTMT090300UV01AssignedDevice> assignedDevice;
Run Code Online (Sandbox Code Playgroud)

当我查看包的ObjectFactory时,我看到了这一点

private final static QName _COCTMT090303UV01AssignedDeviceAssignedDevice_QNAME = new QName("urn:hl7-org:v3", "assignedDevice");
Run Code Online (Sandbox Code Playgroud)

我的所有17个错误都是相似的.在我的codegen或运行时期间我可以做些什么来使我的服务工作?

Dav*_*ski 3

您在运行时使用什么 Java 版本?在使用 Java 6 运行时,我遇到了类似的 OTA 模式问题。我通过对 Maven 配置进行以下更改消除了该问题:

  1. 将 JAXB impl 2.1.*(而不是 2.2)与provided作用域一起使用,以匹配 Java 6 中包含的 JAXB 版本。
  2. 使用 JAX-WS 2.1(而不是 2.2)来匹配 Java 6 和 JAXB 2.1.x。
  3. 将选项添加frontEnd到 Mavencxf-codegen-plugin插件并将其设置为jaxws21(或者如果wsdl2java在命令行上使用,则使用“ -fe jaxws21”选项)。