今天遇到一个问题,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 排错【转】的更多相关文章

  1. 【webservice】Two classes have the same XML type name(转)

    引言 需要调用另一个系统的提供的webservice接口,但是调用之后总是报错,用SoapUI测试接口却没有问题: 那就应该是代码的问题了,但是同样的代码也调用过其他系统却没有问题,不过最终还是解决了 ...

  2. 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 ...

  3. 【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的错误, ...

  4. Maven项目编译后classes文件中没有.xml问题

    在做spring+mybatiss时,自动扫描都配置正确了,却在运行时出现了如下错误.后来查看target/classes/.../dao/文件夹下,发现只有mapper的class文件,而没有xml ...

  5. [原]Maven项目编译后classes文件中没有.xml问题

    在做spring+mybatiss时,自动扫描都配置正确了,却在运行时出现了如下错误.后来查看target/classes/.../dao/文件夹下,发现只有mapper的class文件,而没有xml ...

  6. CXF生成client注意事项

    1. 在使用wsdl2java命令生成client文件时在Service的Java文件中面出现super构造错误,这是因为jax-ws2.2规约与java6冲突  故须要减少jax-ws规约版本号. ...

  7. The error occurred while setting parameters 错误解析--Bad value for type timestamp : 3

    错误信息:nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying datab ...

  8. 【转】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 ...

  9. python处理xml的常用包(lib.xml、ElementTree、lxml)

    python处理xml的三种常见机制 dom(随机访问机制) sax(Simple APIs for XML,事件驱动机制) etree python处理xml的三种包 标准库中的xml Fredri ...

随机推荐

  1. html 问题

    1.footer处理 目标: 页面较短,footer位于页面底部,出现滚动条时,依然在原来的位置,不随滚动条移动 页面较长,位于元素底部 .container{ position: relative ...

  2. PHP生成迅雷、快车、旋风等软件的下载链接代码实例

    PHP生成迅雷.快车.旋风等软件的下载链接代码实例 <?php function Download() { $urlodd=explode('//',$_POST["url" ...

  3. [转]Python程序员必须知道的30条编程技巧

    30 tips & tricks for Python Programming 1  直接交换两个数字位置 x, y = 10, 20 print(x, y) x, y = y, x prin ...

  4. [leetcode 17]Letter Combinations of a Phone Number

    1 题目: Given a digit string, return all possible letter combinations that the number could represent. ...

  5. Knockout学习之模板绑定器

    模板绑定器 如今页面结构越来越复杂,仅仅依靠foreach已经不足以我们的使用,这个时候我们就需要模板的存在,模板的优点自然很多,首先会让页面整洁,同时修改起来也可以方面的定位,最重要的是ko可以条件 ...

  6. jenkins2 pipeline入门

    本文通过简单的pipeline的实例和详细的讲解,能够学习基本pipeline的groovy用法,然后开始实现自己的pipeline job. 翻译和修改自:https://github.com/je ...

  7. MongoDB与.NET结合使用一(mongodb在windows 2003上的安装)

    mongodb发展至今已经到2.6版本了,自从获得了1亿美元的风投之后,发展速度更是比以前快了很多,前段时间因为要用缓存,也比较了mongodb,大家也都觉得比较适合做无关系化的大数据存储,所以系统统 ...

  8. ASP.NET Entity Framework with MySql服务器发布环境配置

    首先,.net应该自带Entity Framework,所以服务器只要有对应版本的.net Framework就OK! 我们在开发环境中一般会直接使用edmx来管理应用程序与数据库的交互操作,所有与数 ...

  9. C/C++文件操作2

    一.流式文件操作 这种方式的文件操作有一个重要的结构FILE,FILE在stdio.h中定义如下: typedef struct { int level; /* fill/empty level of ...

  10. iis6.0报以下的错。。

    Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec8 ...