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 ...
随机推荐
- hdu 2586(LCA在线ST)
How far away ? Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): A ...
- 使用的组件:ckeditor
老牌Web文本编辑器,无需多言. 官网地址:http://ckeditor.com/
- Dynamic CRM 2013学习笔记(三十一)自定义用excel批量导入实体数据
有一个实体的子表数据量太大,于是客户想用execel来导入实体数据.首先想到的是用系统自带的Import Data,客户嫌太麻烦,比如lookup字段要做map等. 下面是具体的实现步骤: 一.定义e ...
- [云] 1、云服务器——从ILP\DLP\TLP谈起
1) ABOUT:ILP\DLP\TLP 1-1.ILP 大约在1985年之后的所有处理器都使用流水线来重叠指令的执行过,以提高性能.由于指令可以并行执行,所以指令之间可能实现这种重叠称为指令级并行( ...
- [C++] socket - 5 [API事件对象实现线程同步]
/*API事件对象实现线程同步*/ #include<windows.h> #include<stdio.h> DWORD WINAPI myfun1(LPVOID lpPar ...
- 我的cookie读写
前后台必须一致, 后台: public static void SetCookie(string cookieName, string value, int expiresDays){ var ...
- C#移除HTML标记
移除一段文字中的HTML标记,以消除其中包含的样式和段落等,最常用的办法可能就是正则表达式了.但是请注意,正则表达式并不能处理所有的HTML文档,所以有时采用一个迭代的方式会更好,如for循环.看下面 ...
- ASP.NET Entity Framework with MySql服务器发布环境配置
首先,.net应该自带Entity Framework,所以服务器只要有对应版本的.net Framework就OK! 我们在开发环境中一般会直接使用edmx来管理应用程序与数据库的交互操作,所有与数 ...
- C#课外实践——校园二手平台(技术篇3)
说明:生活中,又有谁,能真正摆脱周围环境的束缚,而追随自己的内心呢? ListView的简单用法. 最后展示几张效果图吧 主窗体 登录窗体,虽然没有角色 选择,但已经隐藏在代码里了. 选择购买窗体,这 ...
- 错误The request sent by the client was syntactically incorrect ()的解决
http://www.cnblogs.com/xiandedanteng/p/4168609.html 这个错误是SpringMVC报出来的,见到它意味着html/jsp页面的控件名称 和 contr ...