zoukankan      html  css  js  c++  java
  • CXF报错[1 counts of IllegalAnnotationExceptions]and[Two classes have the same XML type name]and[Use @XmlType.name and @XmlType.namespace to assign different names to them]

    启动时CXF报错如下:

    Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
    Two classes have the same XML type name "{http://service.facade.masopen.shengpay.com/}verifyResponse". Use @XmlType.name and @XmlType.namespace to assign different names to them.
        this problem is related to the following location:
            at com.shengpay.masopen.facade.model.verify.VerifyResponse
            at private com.shengpay.masopen.facade.model.verify.VerifyResponse com.shengpay.masopen.facade.service.jaxws_asm.VerifyResponse._return
            at com.shengpay.masopen.facade.service.jaxws_asm.VerifyResponse
        this problem is related to the following location:
            at com.shengpay.masopen.facade.service.jaxws_asm.VerifyResponse

    提示很明确:

    Two classes have the same XML type name "{http://service.facade.masopen.shengpay.com/}verifyResponse"

    存在两个类名=verifyResponse的xml type name

    给出的处理方案是

    Use @XmlType.name and @XmlType.namespace to assign different names to them.

    使用@xmlType的name和namespace做区分

    原来,WebService在发布的时候:对webservice里面得每个方法都生成一个类,生成的类名为: methodName + "Response",所以就回导致生成的类和原来的类有两个相同的xml type。

    请看接口定义:

    @WebService
    public interface RealNameVerifyService {
        /**
         * 实名认证处理...
         * @param request
         * @return
         */
        
        VerifyResponse verify(VerifyRequest request) throws BusinessException;
    }

    方法名是verify,返回值是VerifyResponse,而webSwevice也会为我的方法生成一个类verifyResponse,这就冲突了。

    解决方案常用有两个:

    1.修改返回对象名称,不再使用VerifyResponse类名

    2.使用@WebMethod指定生成的类名

    @WebService
    public interface RealNameVerifyService {
        /**
         * 实名认证处理...
         * @param request
         * @return
         */
        @WebMethod(operationName="wsVerify")
        VerifyResponse verify(VerifyRequest request) throws BusinessException;
    }

     

    参考:

    http://stackoverflow.com/questions/4254334/illegalannotationexception-two-classes-have-the-same-xml-type-name

    http://asialee.iteye.com/blog/1913480

  • 相关阅读:
    Linux 笔记:文件名
    Linux 一些有用的能力
    理解Linux内核注释
    Linux 的三种软件安装包介绍
    idea 2019 激活
    wget免登陆下载jdk 8u221
    PowerDesigner每点击一次就会提示打印错误对话框
    FormData使用方法详解
    springboot:配置多个数据源
    CSS3绘制不规则图形,代码收集
  • 原文地址:https://www.cnblogs.com/huahua035/p/5575208.html
Copyright © 2011-2022 走看看