异常:NAMESPACE_ERR: An attempt is made to create or change an object in a way whi---- 这是我自己写客户端调用webservice 控制台显示的部分异常代码。

或者直接通过soapUI 调用:

异常信息如下

No adapter for endpoint [public org.jdom.Element com.mycompany.hr.ws.HolidayEndpoint.handleHolidayRequest(org.jdom.Element) throws java.lang.Exception]: Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?

官方搭建 spring webserivce 项目的文档:  http://docs.spring.io/spring-ws/site/reference/html/tutorial.html  官方的使用webservice 的案例 是个员工休假的webservice系统,采用domj 做endpoint的元素mapping

出现错误的原因:

http://stackoverflow.com/questions/11683468/no-adapter-for-endpoint-sws

I think the problem lies here jira.springsource.org/browse/… There's a bug in endpoint mapping for JDOM elements 

 

solution 复制黏贴如下: 将 jdom2 取代jdom

This is the working solution to your problem:

add this dependencies to your pom.xml

Change the imports in your source for jdom to jdom2

And this is the updated version of HolidayEndpoint:

package com.mycompany.ws_template.endpoint;

import com.mycompany.ws_template.service.HumanResource;
import java.text.SimpleDateFormat;
import java.util.Date; import org.jdom2.JDOMException;
import org.jdom2.Namespace;
import org.jdom2.Element;
import org.jdom2.filter.Filters;
import org.jdom2.xpath.XPathExpression;
import org.jdom2.xpath.XPathFactory; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload; @Endpoint
public class HolidayEndpoint { private static final String NAMESPACE_URI = "http://www.mycompany.com/holiday-service/schemas/holiday-request"; private XPathExpression<Element> startDateExpression;
private XPathExpression<Element> endDateExpression;
private XPathExpression<Element> nameExpression;
private XPathExpression<Element> surnameExpression; @Autowired private HumanResource holidayService; public HolidayEndpoint() throws JDOMException { Namespace namespace = Namespace.getNamespace("hr", NAMESPACE_URI); XPathFactory xpathFactory = XPathFactory.instance();
startDateExpression = xpathFactory.compile("//hr:StartDate", Filters.element(), null, namespace);
endDateExpression = xpathFactory.compile("//hr:EndDate", Filters.element(), null, namespace);
nameExpression = xpathFactory.compile("//hr:EmployeeName", Filters.element(), null, namespace);
surnameExpression = xpathFactory.compile("//hr:EmployeeSurname", Filters.element(), null, namespace);
} @PayloadRoot(namespace = NAMESPACE_URI, localPart = "HolidayRequest")
public void handleHolidayRequest(@RequestPayload Element holidayRequest) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date startDate = sdf.parse(startDateExpression.evaluate(holidayRequest).get(0).getValue());
Date endDate = sdf.parse(endDateExpression.evaluate(holidayRequest).get(0).getValue());
String name = nameExpression.evaluate(holidayRequest).get(0).getValue() + surnameExpression.evaluate(holidayRequest).get(0).getValue(); holidayService.bookHoliday(startDate, endDate, name);
} }

spring webservice 搭建出现的异常处理。异常: NAMESPACE_ERR: An attempt is made to create or change an object in a way whi的更多相关文章

  1. NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.

    解决办法: http://stackoverflow.com/questions/4037125/namespace-err-an-attempt-is-made-to-create-or-chang ...

  2. Spring Boot搭建Web项目常用功能

    搭建WEB项目过程中,哪些点需要注意: 1.技术选型: 前端:freemarker.vue 后端:spring boot.spring mvc 2.如何包装返回统一结构结果数据? 首先要弄清楚为什么要 ...

  3. 转:Spring Boot应用中的异常处理

    引自:https://www.cnblogs.com/yangfanexp/p/7616570.html 楼主前几天写了一篇“Java子线程中的异常处理(通用)”文章,介绍了在多线程环境下3种通用的异 ...

  4. Spring环境搭建及简单demo

    1. Spring框架简介(以下这段话可用于面试求职) Spring为JavaEE开发提供了一个轻量级的解决方案,主要表现为, IOC(或者叫做DI)的核心机制,提供了bean工厂(Spring容器) ...

  5. 使用Spring进行统一日志管理 + 统一异常管理

    http://blog.csdn.net/king87130/article/details/8011843原文地址 统一日志异常实现类: 1 package com.pilelot.web.util ...

  6. Springmvc+Spring+Hibernate搭建方法

    Springmvc+Spring+Hibernate搭建方法及example 前面两篇文章,分别介绍了Springmvc和Spring的搭建方法,本文再搭建hibernate,并建立SSH最基本的代码 ...

  7. Spring Boot 中关于自定义异常处理的套路!

    在 Spring Boot 项目中 ,异常统一处理,可以使用 Spring 中 @ControllerAdvice 来统一处理,也可以自己来定义异常处理方案.Spring Boot 中,对异常的处理有 ...

  8. Spring ThreadPoolTaskExecutor队列满的异常处理

    <!-- 配置线程池 --> <bean id="threadPool" class="org.springframework.scheduling.c ...

  9. Spring Boot2 系列教程(十三)Spring Boot 中的全局异常处理

    在 Spring Boot 项目中 ,异常统一处理,可以使用 Spring 中 @ControllerAdvice 来统一处理,也可以自己来定义异常处理方案.Spring Boot 中,对异常的处理有 ...

随机推荐

  1. java 反射的踩的一个坑

    今天工作的时候用到了一个反射.其业务简单描述为:系统启动时将需要定时调用的方法签名保存到数据库中,开启线程定时从数据库中读取对应的方法签名,通过反射生成实例后调用方法.完成一定的定时任务. 写到的方法 ...

  2. hibernate数据库配置

    在文件夹etc中 ## MySQL #hibernate.dialect org.hibernate.dialect.MySQLDialect #hibernate.dialect org.hiber ...

  3. Selenium-RC Python 2.7 环境配置

    1.下载并安装Python http://www.python.org/getit/,我使用的是2.7.3的python版本 2.下载并安装setuptools[这个工具是python的基础包工具] ...

  4. JavaScript中使用console调试程序的坑

    上DEMO a = {key1: [1, 2], 'key2': {'key4': '11'}, 'key3': [1, 2]} console.info(1,a) a.key2.key4 = '22 ...

  5. linux 标准io笔记

    三种缓冲 1.全缓冲:在缓冲区写满时输出到指定的输出端. 比如对磁盘上的文件进行读写通常是全缓冲的. 2.行缓冲:在遇到'\n'时输出到指定的输出端. 比如标准输入和标准输出就是行缓冲, 回车后就会进 ...

  6. android连接本地tomcat服务器,报timeout

    1.在eclipse环境下连接时,没有任何问题 2.直接将服务端发布到tomcat服务下,报timeout 3.查明原因: 3.1打开IE访问,一切正常,可以获取到数据,说明不是服务端的问题 3.2打 ...

  7. Mininet安装及使用

    最简单的方法是开始 下载一个预包装Mininet / Ubuntu VM . 这个虚拟机包括Mininet本身,所有预装OpenFlow二进制文件和工具,调整内核配置,以支持更大的Mininet网络. ...

  8. Redis 四:存储类型之无序集合

    .sadd num a b c 向num集合中添加abc三个元素 .srem num b 从num集合中删除b元素 .smembers num 获取num集合中所有的元素 .sismember num ...

  9. Express/Koa/Hapi

    Express/Koa/Hapi 本文翻译自: https://www.airpair.com/node.js/posts/nodejs-framework-comparison-express-ko ...

  10. Timer定时器

    try { mTimerGoOut = new Timer(); SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd" ...