原文链接:http://damonshell.sinaapp.com/?p=81
今天在调用接口时,报了个错误,意思为两个类调用了同一个XML TYPE;
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 4 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "{http://ws.check4AChannel.channel.asiainfo.com/}createCCMappingResponse". Use @XmlType.name and @XmlType.namespace to assign different names to them.
this problem is related to the following location:
at com.boco.iam.module_bj.application.utils.webservice.channel.check4achannel.ws.jaxws_asm.CreateCCMappingResponse
this problem is related to the following location:
at com.boco.iam.module_bj.application.utils.webservice.channel.check4achannel.ws.CreateCCMappingResponse
at public javax.xml.bind.JAXBElement com.boco.iam.module_bj.application.utils.webservice.channel.check4achannel.ws.ObjectFactory.createCreateCCMappingResponse(com.boco.iam.module_bj.application.utils.webservice.channel.check4achannel.ws.CreateCCMappingResponse)
at com.boco.iam.module_bj.application.utils.webservice.channel.check4achannel.ws.ObjectFactory
Two classes have the same XML type name "{http://ws.check4AChannel.channel.asiainfo.com/}check4AChannel". Use @XmlType.name and @XmlType.namespace to assign different names to them.
经过一番查询,觉得是服务端在生成WSDL时,将相应类的命名空间都默认为同一个了,因此网上才有了修改命名空间的建议;即在相应类(即客户端调用的java实体类)中加入@XmlType
(namespace=”http://namespace.thats.not.the.same.as.the.generated”),即改变响应类的命名空间。
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "createCCMapping", propOrder = {
"channelCode",
"channelType",
"crmCode",
"doneType"
},namespace="http://namespace.thats.not.the.same.as.the.generated")
public class CreateCCMapping {
}
另外,还有一种修改相应类的名称,若如此修改,可能会影响服务端调用,建议修改命名空间。