Two classes have the same XML type name 排错【转】
今天遇到一个问题,webservice发布的时候报下面的错误:
<strong>Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "{http://xxx.yyyy.com}createProcessResponse". Use @XmlType.name and @XmlType.namespace to assign different names to them.
this problem is related to the following location:
at xxx.yyy.gwfp.ws.dto.CreateProcessResponse
at private xxx.yyy.gwfp.ws.dto.CreateProcessResponse xxx.yyy.gwfp.ws.jaxws_asm.CreateProcessResponse._return
at xxx.yyy.gwfp.ws.jaxws_asm.CreateProcessResponse
this problem is related to the following location:
at xxx.yyy.gwfp.ws.jaxws_asm.CreateProcessResponse at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:472)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:302)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1140)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:363)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
at org.apache.cxf.jaxb.JAXBDataBinding.createContext(JAXBDataBinding.java:562)
at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:502)
at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:322)</strong>
代码如下
@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, 这个注解其实会改变生成的类的名称,对接口是没有影响的.
Two classes have the same XML type name 排错【转】的更多相关文章
- 【webservice】Two classes have the same XML type name(转)
引言 需要调用另一个系统的提供的webservice接口,但是调用之后总是报错,用SoapUI测试接口却没有问题: 那就应该是代码的问题了,但是同样的代码也调用过其他系统却没有问题,不过最终还是解决了 ...
- 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 IllegalA ...
- 【Webservice】2 counts of IllegalAnnotationExceptions Two classes have the same XML type name
在使用客户端调用服务端的时候发生了2 counts of IllegalAnnotationExceptions Two classes have the same XML type name的错误, ...
- Maven项目编译后classes文件中没有.xml问题
在做spring+mybatiss时,自动扫描都配置正确了,却在运行时出现了如下错误.后来查看target/classes/.../dao/文件夹下,发现只有mapper的class文件,而没有xml ...
- [原]Maven项目编译后classes文件中没有.xml问题
在做spring+mybatiss时,自动扫描都配置正确了,却在运行时出现了如下错误.后来查看target/classes/.../dao/文件夹下,发现只有mapper的class文件,而没有xml ...
- CXF生成client注意事项
1. 在使用wsdl2java命令生成client文件时在Service的Java文件中面出现super构造错误,这是因为jax-ws2.2规约与java6冲突 故须要减少jax-ws规约版本号. ...
- The error occurred while setting parameters 错误解析--Bad value for type timestamp : 3
错误信息:nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying datab ...
- 【转】Open XML SDK class structure
Open XML SDK class structure March 27, 2012 by Vincent I’ve gotten a few questions on the class stru ...
- python处理xml的常用包(lib.xml、ElementTree、lxml)
python处理xml的三种常见机制 dom(随机访问机制) sax(Simple APIs for XML,事件驱动机制) etree python处理xml的三种包 标准库中的xml Fredri ...
随机推荐
- java复习基础知识——java保留字
ava 关键字列表 (依字母排序 共51组): abstract, assert,boolean, break, byte, case, catch, char, class, const, cont ...
- 6.7 Binder机制
Binder在Android系统中江湖地位非常之高.在Zygote孵化出system_server进程后,在system_server进程中出初始化支持整个Android framework的各种各样 ...
- Linux下运行jar包
方法① 1.vim xxx.jar 2.配置程序入口:找到MANIFEST.MF,添加Main-Class:+空格+package.class 3.引入第三方jar包:①在MANIFEST.MF中加入 ...
- Android--持久化技术
1.Android中的持久化技术主要有三种: 1)文件存储: 2)SharedPreference存储: 3)数据库存储(SQLite);2.文件存储: 1)Context 类中提供了一个 openF ...
- 01背包问题:Charm Bracelet (POJ 3624)(外加一个常数的优化)
Charm Bracelet POJ 3624 就是一道典型的01背包问题: #include<iostream> #include<stdio.h> #include& ...
- kafka go producer 启动基本配置
1.官网上下载kafka安装包:http://kafka.apache.org/downloads.html 2.执行命令运行zookeeper 实例(单点): bin/zookeeper-serve ...
- ArcMap 连接SDE 出错“Failed to connect to the specified server. Entry for SDE instance no found in services file.”
问题描述 环境: ARCMAP 10.0 ARCSDE FOR ORACLE 10.0 在通过用ArcMap 连接ORACLE SDE时出现上面的错. 解决方式 在 C:\Windows\Sy ...
- [转]解决WebClient或HttpWebRequest首次连接缓慢问题
http://blog.csdn.net/rrrfff/article/details/6170653?reload 设置代理为空: <?xml version="1.0"? ...
- [算法] [常微分方程] [欧拉法 改进欧拉法 经典R-K算法]
#include<iostream> #include<cmath> #include<cstdio> #include<iomanip> using ...
- 汇编语言hello world
DOS下: ;栈段 stack segment stack db dup(?) stack ends ;数据段 data segment szHello db 'Hello,world',0dh,0a ...