啟動時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