web service错误Use @XmlType.name and @XmlType.namespace to assign different names to them.
来源:互联网 发布:淘宝的退款率怎么看 编辑:程序博客网 时间:2024/06/07 07:23
记录下!!,今天webService 生成客户端 运行报错 Use @XmlType.name and @XmlType.namespace to assign different names to them.
错误如下:
Exception in thread "main" javax.xml.ws.WebServiceException: Unable to create JAXBContextat com.sun.xml.internal.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:156)at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:84)at com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:235)at com.sun.xml.internal.ws.client.WSServiceDelegate.createSEIPortInfo(WSServiceDelegate.java:672)at com.sun.xml.internal.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:660)at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:329)at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:312)at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:294)at javax.xml.ws.Service.getPort(Service.java:119)at com.bqjr.storesys.base.vo.com.bqjr.storesys.base.entity.TestWebServicesService.getTestWebServicesPort(TestWebServicesService.java:72)at com.bqjr.storesys.base.vo.com.bqjr.storesys.base.entity.test.main(test.java:6)Caused by: java.security.PrivilegedActionException: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptionsTwo classes have the same XML type name "{http://entity.base.storesys.bqjr.com/}sayResponse". Use @XmlType.name and @XmlType.namespace to assign different names to them.this problem is related to the following location:at com.bqjr.storesys.base.vo.com.bqjr.storesys.base.entity.SayResponseat public com.bqjr.storesys.base.vo.com.bqjr.storesys.base.entity.SayResponse com.bqjr.storesys.base.vo.com.bqjr.storesys.base.entity.ObjectFactory.createSayResponse()at com.bqjr.storesys.base.vo.com.bqjr.storesys.base.entity.ObjectFactorythis problem is related to the following location:at com.bqjr.storesys.base.entity.SayResponseat java.security.AccessController.doPrivileged(Native Method)at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:143)... 10 moreCaused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptionsTwo classes have the same XML type name "{http://entity.base.storesys.bqjr.com/}sayResponse". Use @XmlType.name and @XmlType.namespace to assign different names to them.this problem is related to the following location:at com.bqjr.storesys.base.vo.com.bqjr.storesys.base.entity.SayResponseat public com.bqjr.storesys.base.vo.com.bqjr.storesys.base.entity.SayResponse com.bqjr.storesys.base.vo.com.bqjr.storesys.base.entity.ObjectFactory.createSayResponse()at com.bqjr.storesys.base.vo.com.bqjr.storesys.base.entity.ObjectFactorythis problem is related to the following location:at com.bqjr.storesys.base.entity.SayResponseat com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:451)at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:283)at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:126)at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1148)at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:173)at com.sun.xml.internal.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:96)at com.sun.xml.internal.ws.developer.JAXBContextFactory$1.createJAXBContext(JAXBContextFactory.java:98)at com.sun.xml.internal.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:151)at com.sun.xml.internal.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:143)... 12 more
代码如下
@Stateless@WebService()public class AccountWS {@WebMethod()public CreateProcessResponse createProcess(@WebParam(name = "request") CreateProcessRequest request) { return null;}
起初找不出来原因,后来才发现,由于JAX-WS对webservice里面得每个方法都生成一个类,生成的类名为: methodName
+ "Response",所以就回导致生成的类和原来的类有两个相同的xml type。
知道原因后,除了我们修改方法名外,还有下面的3种解决方法:
- 更换返回值对象的name
@XMLType(name="CreateProcessResponseMsg", namespace="http://xxx.yyy.com")
- 更换返回值对象的namespace
@XMLType(name="CreateProcessResponse", namespace="http://xxx.yyy.com/message")
- 给方法上加上下面的注解
@WebMethod(operationName="differentFromMethodName")
其实在最开始的时候说生成的class的名称是方法名+Response,是不准确的,operationName的默认值就是方法名,其实就是operationName+Response, 这个注解其实会改变生成的类的名称,对接口是没有影响的.
阅读全文
0 0
- web service错误Use @XmlType.name and @XmlType.namespace to assign different names to them.
- xmltype
- CXF之"@XmlType.name 和 @XmlType.namespace 为类分配不同的名称"异常
- Mapping Oracle XMLType to Document with Hibernate
- cxf(3.1.1) 客户端异常 请使用 @XmlType.name 和 @XmlType.namespace 为类分配不同的名称。
- Exception:两个类具有相同的 XML 类型名称,请使用 @XmlType.name 和 @XmlType.namespace 为类分配不同的名称
- 两个类具有相同的 XML 类型名称。请使用 @XmlType.name 和 @XmlType.namespace 为类分配不同的名称。
- How To Setup Partitioned Linux Block Devices Using UDEV (Non-ASMLIB) And Assign Them To ASM
- Effective Objective-C 2.0:Item 15: Use Prefix Names to Avoid Namespace Clashes
- How to use SCAN and node listeners with different ports?
- Use data define file and colmap to map different column
- Different ways to get the symbol name and ...
- Use VBA to call Web Service
- Use Http Post to call Web Service
- xmltype.extractValue
- How to assign the different php files
- How to use VC++6.0 to develop web Service Client
- use python zsi to create and publish a web service (rpc-encoded)
- CentOS 7.4下使用yum安装MySQL
- C++#ifndef/#define/#endif的用法
- ue4 ApplyRadialDamage
- Python进阶(五):特殊方法
- struts-config.xml配置文件的scope
- web service错误Use @XmlType.name and @XmlType.namespace to assign different names to them.
- 如何用低廉的成本高效提高事务吞吐量
- Replugin插件化框架简要分析
- 2-2 Time类的定义
- Educational Codeforces Round 30C-模拟&贪心-Strange Game On Matrix
- Android : 隐藏软键盘
- Eric6与pyqt5学习笔记 2【页面基本布局】
- 【安全牛学习笔记】windows系统域和工作组的区别
- Hadoop之MapReduce