Web服务 - 客户端类
问题描述:
,我实行的是启动和运行,当我尝试运行客户端,我得到以下错误关于使用的wsimport生成的类Web服务,Web服务 - 客户端类
Caused by: java.security.PrivilegedActionException: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 4 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "{http://server.agency.hw2/}userJoined". Use @XmlType.name and @XmlType.namespace to assign different names to them.
this problem is related to the following location:
at hw2.chat.backend.main.generatedfromserver.UserJoined
at public javax.xml.bind.JAXBElement hw2.chat.backend.main.generatedfromserver.ObjectFactory.createUserJoined(hw2.chat.backend.main.generatedfromserver.UserJoined)
at hw2.chat.backend.main.generatedfromserver.ObjectFactory
this problem is related to the following location:
at ChatCompany.BackendChatServer.hw2.chat.backend.main.generatedfromserver.UserJoined
Two classes have the same XML type name "{http://server.agency.hw2/}userJoinedResponse". Use @XmlType.name and @XmlType.namespace to assign different names to them.
this problem is related to the following location:
at hw2.chat.backend.main.generatedfromserver.UserJoinedResponse
at public javax.xml.bind.JAXBElement hw2.chat.backend.main.generatedfromserver.ObjectFactory.createUserJoinedResponse(hw2.chat.backend.main.generatedfromserver.UserJoinedResponse)
但我无法弄清楚错误到底是什么意思。我假设我需要改变的东西的注解在这些类由编译器指出:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "userJoinedResponse")
public class UserJoinedResponse {
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "userJoined", propOrder = {
"arg0"
})
public class UserJoined {
可能有人请指出为什么有一个名称冲突,我需要改变什么注解?
感谢
答
我的老师曾建议(除其他原因外),也许有什么毛病我跑的wsimport实用的方式,让我再生利用的wsimport客户端类文件,问题就解决了。可能是因为我没有在开始时指定软件包名称,并且第一次手动执行了它,但我不确定。
答
我得到了同样的例外。原因是两个类的名称相似。当您在wsdl生成过程中使用名称为UserJoined
的类时,JAXB会生成名称为UserJoinedResponse
的元素(请参阅您的wsdl文件)。
而您尝试添加另一个具有相同名称的类(UserJoinedResponse
)。所以只需重命名UserJoinedResponse
类,或者按照例外中提到的注释它。
所有生成的代码是在'wsimport'的一次执行中产生的,还是多次执行的? – skaffman 2010-06-06 08:45:25
错误,wsimport的执行次数是什么意思?如果这回答我只是通过Windows CMD运行命令。 – Noona 2010-06-06 09:10:43
您可以粘贴UserJoined类中使用的注释吗?你在处理你自己没有写的代码吗?如果是,请在所有代码中搜索“name =”userJoinedResponse“”和“name =”userJoined“',看看是否找到重复的注释。 – 2010-06-06 09:56:17