web service cxf 问题
我用cxf的wsdl2java.bat 生成wsdl本地类,但是在写客户端调用的时候报错。
Exception in thread "main" javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:333)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:318)
at javax.xml.ws.Service.getPort(Unknown Source)
at com.poka.xx.DataProcessingImplService.getDataProcessingImplPort(DataProcessingImplService.java:58)
at com.test.WebServiceTest.main(WebServiceTest.java:16)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException
at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:324)
at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:430)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:534)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:248)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:205)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:90)
at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:155)
at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:156)
at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:464)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:331)
... 4 more
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 4 counts of IllegalAnnotationExceptions
两个类具有相同的 XML 类型名称 "{http://dao.poka.com/}shangHangJiaoKuanResponse"。请使用 @XmlType.name 和 @XmlType.namespace 为类分配不同的名称。
this problem is related to the following location:
at com.poka.xx.jaxws_asm.ShangHangJiaoKuanResponse
this problem is related to the following location:
at com.poka.xx.ShangHangJiaoKuanResponse
at public com.poka.xx.ShangHangJiaoKuanResponse com.poka.xx.ObjectFactory.createShangHangJiaoKuanResponse()
at com.poka.xx.ObjectFactory
两个类具有相同的 XML 类型名称 "{http://dao.poka.com/}shangHangJiaoKuan"。请使用 @XmlType.name 和 @XmlType.namespace 为类分配不同的名称。
this problem is related to the following location:
at com.poka.xx.jaxws_asm.ShangHangJiaoKuan
this problem is related to the following location:
at com.poka.xx.ShangHangJiaoKuan
at public com.poka.xx.ShangHangJiaoKuan com.poka.xx.ObjectFactory.createShangHangJiaoKuan()
at com.poka.xx.ObjectFactory
两个类具有相同的 XML 类型名称 "{http://dao.poka.com/}sayHelloResponse"。请使用 @XmlType.name 和 @XmlType.namespace 为类分配不同的名称。
this problem is related to the following location:
at com.poka.xx.jaxws_asm.SayHelloResponse
this problem is related to the following location:
at com.poka.xx.SayHelloResponse
at public javax.xml.bind.JAXBElement com.poka.xx.ObjectFactory.createSayHelloResponse(com.poka.xx.SayHelloResponse)
at com.poka.xx.ObjectFactory
两个类具有相同的 XML 类型名称 "{http://dao.poka.com/}sayHello"。请使用 @XmlType.name 和 @XmlType.namespace 为类分配不同的名称。
this problem is related to the following location:
at com.poka.xx.jaxws_asm.SayHello
this problem is related to the following location:
at com.poka.xx.SayHello
at public com.poka.xx.SayHello com.poka.xx.ObjectFactory.createSayHello()
at com.poka.xx.ObjectFactory
at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:106)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:466)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:298)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:141)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1163)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:145)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
at javax.xml.bind.ContextFinder.find(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at org.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:268)
at org.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:267)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.cxf.common.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:266)
at org.apache.cxf.common.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:172)
at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:454)
at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:322)
... 15 more
[解决办法]
删除所有生成的文件重新试下