webservice cxf error:类的两个属性具有相同名称 "password"
execption detail:
1 Caused by: javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException 2 at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:369) 3 at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:251) 4 at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:537) 5 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 6 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 7 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 8 at java.lang.reflect.Method.invoke(Method.java:597) 9 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1614) 10 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1555) 11 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1485) 12 ... 42 more 13 Caused by: org.apache.cxf.service.factory.ServiceConstructionException 14 at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:332) 15 at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86) 16 at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:478) 17 at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:690) 18 at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:540) 19 at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:252) 20 at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:205) 21 at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101) 22 at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:159) 23 at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211) 24 at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:454) 25 at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:334) 26 ... 51 more 27 Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions 28 类的两个属性具有相同名称 "appno" 29 this problem is related to the following location: 30 at public java.lang.String com.taiping.svc.bean.CardPasswardCheckMessageDTO.getAppno() 31 at com.taiping.svc.bean.CardPasswardCheckMessageDTO 32 at private com.taiping.svc.bean.CardPasswardCheckMessageDTO com.taiping.svc.webservice.jaxws_asm.CardPasswardCheck.cardPasswardCheckMessageDTO 33 at com.taiping.svc.webservice.jaxws_asm.CardPasswardCheck 34 this problem is related to the following location: 35 at protected java.lang.String com.taiping.svc.bean.CardPasswardCheckMessageDTO.appno 36 at com.taiping.svc.bean.CardPasswardCheckMessageDTO 37 at private com.taiping.svc.bean.CardPasswardCheckMessageDTO com.taiping.svc.webservice.jaxws_asm.CardPasswardCheck.cardPasswardCheckMessageDTO 38 at com.taiping.svc.webservice.jaxws_asm.CardPasswardCheck 39 类的两个属性具有相同名称 "password" 40 this problem is related to the following location: 41 at public java.lang.String com.taiping.svc.bean.CardPasswardCheckMessageDTO.getPassword() 42 at com.taiping.svc.bean.CardPasswardCheckMessageDTO 43 at private com.taiping.svc.bean.CardPasswardCheckMessageDTO com.taiping.svc.webservice.jaxws_asm.CardPasswardCheck.cardPasswardCheckMessageDTO 44 at com.taiping.svc.webservice.jaxws_asm.CardPasswardCheck 45 this problem is related to the following location: 46 at protected java.lang.String com.taiping.svc.bean.CardPasswardCheckMessageDTO.password 47 at com.taiping.svc.bean.CardPasswardCheckMessageDTO 48 at private com.taiping.svc.bean.CardPasswardCheckMessageDTO com.taiping.svc.webservice.jaxws_asm.CardPasswardCheck.cardPasswardCheckMessageDTO 49 at com.taiping.svc.webservice.jaxws_asm.CardPasswardCheck
解决方法:
com.taiping.svc.bean.CardPasswardCheckMessageDTO
该类本来是这么定义的:
1 @XmlRootElement(name = "REQUEST") 2 public class CardPasswardCheckMessageDTO { 3 4 @XmlElement(name = "app_no") 5 protected String appno; 6 7 @XmlElement(name = "password") 8 protected String password; 9 10 public String getAppno() { 11 return appno; 12 } 13 14 public void setAppno(String appno) { 15 this.appno = appno; 16 } 17 18 public String getPassword() { 19 return password; 20 } 21 22 public void setPassword(String password) { 23 this.password = password; 24 } 25 }
改为:
1 @XmlRootElement(name = "REQUEST") 2 public class CardPasswardCheckMessageDTO { 3 4 protected String appno; 5 6 protected String password; 7 8 public String getAppno() { 9 return appno; 10 } 11 12 @XmlElement(name = "app_no") 13 public void setAppno(String appno) { 14 this.appno = appno; 15 } 16 17 public String getPassword() { 18 return password; 19 } 20 21 @XmlElement(name = "password") 22 public void setPassword(String password) { 23 this.password = password; 24 } 25 }
马上OK!