异常: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. jquery.tmpl.min.js--前端实现模版--数据绑定--详解

    动态请求数据来更新页面是现在非常常用的方法,比如博客评论的分页动态加载,微博的滚动加载和定时请求加载等. 这些情况下,动态请求返回的数据一般不是已拼好的 HTML 就是 JSON 或 XML,总之不在 ...

  2. [大牛翻译系列]Hadoop(15)MapReduce 性能调优:优化MapReduce的用户JAVA代码

    6.4.5 优化MapReduce用户JAVA代码 MapReduce执行代码的方式和普通JAVA应用不同.这是由于MapReduce框架为了能够高效地处理海量数据,需要成百万次调用map和reduc ...

  3. Crusher Django 学习笔记4 使用Model

    http://crusher-milling.blogspot.com/2013/09/crusher-django-tutorial4-using-basic.html 顺便学习一下FQ Crush ...

  4. jquery trigger伪造a标签的click事件取代window.open方法

    $(function() { $('#btnyes').click(function () { $('#ssss').attr("href", "http://www.b ...

  5. 利用Jmeter做接口测试

    本文作者:大道测试团队-孙云 1.在安装jmeter之前先配置好JDK,再配置jmeter环境变量. 2.启动jmeter 启动jmeter: 双击Jmeter解压路径(apache-jmeter-3 ...

  6. Jquery LigerUI框架学习(二)之Tree于Tab标签实现iframe功能

    LigerUI框架Tree于Tab标签动态使用,当点击Tree后动态创建Tab标签,和通常用的iframe框架功能类似 Tree中的关键代码 //Tree初始化 $("#tree1" ...

  7. 相同的 birthday

    Description Sometimes some mathematical results are hard to believe. One of the common problems is t ...

  8. ActiveMQ之TemporaryQueue和TemporaryTopic

    TemporaryQueue和TemporaryTopic,从字面上就可以看出它们是“临时”的目的地.可以通过Session来创建,例如: TemporaryQueue replyQueue = se ...

  9. jQuery 单选按钮切换

    html代码片段一: <div class="row"> <div class="col-sm-12"> <label for=& ...

  10. iOS 进阶 第十二天(0413)

    0413 - Quartz2D 使用Quartz2D画图形步骤:(drawRect: 方法 是 在view第一次显示到屏幕上的时候会调用一次.是系统主动去掉用的,不能直接调用.那么问题来了,比如我要通 ...