开发者

web service - client classes

The web service that I implemented is up and running, when I try to run the client I get the following error with regard to the classes that were generated using wsimport,

    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)

But I can't figure out what exactly is meant by the error. I am assuming I need to change something in annotations in these classes as pointed out by the compiler:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "userJoinedResponse")
public class UserJoinedResponse {


}


@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "userJoined", propOrder = {
    "arg0"
})
public class UserJoined {

could someone please point out why there's 开发者_运维技巧a name collision and what annotations I need to change?

thanks


My teacher has suggested (among other reasons) that maybe there is something wrong with the way i ran the wsimport utility, so I regenerated the client class files using wsimport and the problem was solved. it might have been that I didn't specify the package name at the beginning and did it manually first time but I am uncertain.


I got the same exception. The reason is a similarity of names both classes. When you have class with name UserJoined during wsdl generation process JAXB generate element with name UserJoinedResponse (see your wsdl file).

And the you try to add another class with the same name (UserJoinedResponse). So just rename UserJoinedResponse class or annotate it as mentioned in the exception.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜