2

我的 apache cxf 客户端 Web 服务出现异常,如下所示。但是,“XML 类型名称“地址””是我的 WSDL 的soap:address 位置。问题是什么?

Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "address". Use @XmlType.name and @XmlType.namespace to assign different names to them.
    this problem is related to the following location:
        at com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Address
        at public com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Address com.sun.xml.ws.developer.MemberSubmissionEndpointReference.addr
        at com.sun.xml.ws.developer.MemberSubmissionEndpointReference
    this problem is related to the following location:
        at javax.xml.ws.wsaddressing.W3CEndpointReference$Address
        at private javax.xml.ws.wsaddressing.W3CEndpointReference$Address javax.xml.ws.wsaddressing.W3CEndpointReference.address
        at javax.xml.ws.wsaddressing.W3CEndpointReference
Two classes have the same XML type name "elements". Use @XmlType.name and @XmlType.namespace to assign different names to them.
    this problem is related to the following location:
        at com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements
        at public com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements com.sun.xml.ws.developer.MemberSubmissionEndpointReference.referenceProperties
        at com.sun.xml.ws.developer.MemberSubmissionEndpointReference
    this problem is related to the following location:
        at javax.xml.ws.wsaddressing.W3CEndpointReference$Elements
        at private javax.xml.ws.wsaddressing.W3CEndpointReference$Elements javax.xml.ws.wsaddressing.W3CEndpointReference.referenceParameters
        at javax.xml.ws.wsaddressing.W3CEndpointReference
4

2 回答 2

1

这很有趣。这不是一个完整的答案,但这可能会有所帮助。

该类com.sun.xml.ws.developer.MemberSubmissionEndpointReference.Address没有注释,也没有package-info.java. 所以类型应该是命名的address,没有命名空间。

该类javax.xml.ws.wsaddressing.W3CEndpointReference.Address也没有注释,但是有一个package-info.java

@javax.xml.bind.annotation.XmlSchema(namespace=W3CEndpointReference.NS,
                                     location="http://www.w3.org/2006/03/addressing/ws-addr.xsd")
package javax.xml.ws.wsaddressing;

所以应该命名为{http://www.w3.org/2005/08/addressing:address. 所以理论上应该没有冲突。

我建议如下:

  • 检查你的类和包。
    • 你有package-info.javajavax.xml.ws.wsaddressing吗?
    • 你有一个com.sun.xml.ws.developer吗?
  • 尝试更新库的版本。也许这是版本之间的临时故障。

更新

我在 java.net 上发现了完全相同的问题。那里发布的解决方案之一基本上是“更新您的版本”。似乎也以某种方式与 NetBeans 相关。

于 2014-10-15T13:25:39.890 回答
0

我遇到了完全相同的问题。这不是一个解决方案,而是一种解决方法

首先,我构建客户端所基于的 wsdl 是一个自动生成的 wsdl。这种类型的 wsdls 通常包含多个 shema,就像在我的例子中一样(4 个模式)。我并不是说这是错误的,但在我的情况下,我所做的是删除最后 3 个模式并将第一个模式中的所有元素连同所需要的内容一起移动(命名空间的更改等)。完成此操作后,我再次构建了我的客户端并解决了错误。

于 2021-09-29T14:15:03.083 回答