spring webservice 搭建出现的异常处理。异常: NAMESPACE_ERR: An attempt is made to create or change an object in a way whi
异常: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的更多相关文章
- 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 ...
- Spring Boot搭建Web项目常用功能
搭建WEB项目过程中,哪些点需要注意: 1.技术选型: 前端:freemarker.vue 后端:spring boot.spring mvc 2.如何包装返回统一结构结果数据? 首先要弄清楚为什么要 ...
- 转:Spring Boot应用中的异常处理
引自:https://www.cnblogs.com/yangfanexp/p/7616570.html 楼主前几天写了一篇“Java子线程中的异常处理(通用)”文章,介绍了在多线程环境下3种通用的异 ...
- Spring环境搭建及简单demo
1. Spring框架简介(以下这段话可用于面试求职) Spring为JavaEE开发提供了一个轻量级的解决方案,主要表现为, IOC(或者叫做DI)的核心机制,提供了bean工厂(Spring容器) ...
- 使用Spring进行统一日志管理 + 统一异常管理
http://blog.csdn.net/king87130/article/details/8011843原文地址 统一日志异常实现类: 1 package com.pilelot.web.util ...
- Springmvc+Spring+Hibernate搭建方法
Springmvc+Spring+Hibernate搭建方法及example 前面两篇文章,分别介绍了Springmvc和Spring的搭建方法,本文再搭建hibernate,并建立SSH最基本的代码 ...
- Spring Boot 中关于自定义异常处理的套路!
在 Spring Boot 项目中 ,异常统一处理,可以使用 Spring 中 @ControllerAdvice 来统一处理,也可以自己来定义异常处理方案.Spring Boot 中,对异常的处理有 ...
- Spring ThreadPoolTaskExecutor队列满的异常处理
<!-- 配置线程池 --> <bean id="threadPool" class="org.springframework.scheduling.c ...
- Spring Boot2 系列教程(十三)Spring Boot 中的全局异常处理
在 Spring Boot 项目中 ,异常统一处理,可以使用 Spring 中 @ControllerAdvice 来统一处理,也可以自己来定义异常处理方案.Spring Boot 中,对异常的处理有 ...
随机推荐
- C++ 中的 const 详解
作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4235721.html 1.为什么使用 const int 而不使用 #define 在使用# ...
- FPGA统计摄像头输出-基于MD9T112
FPGA HDL源程序 FPGA统计摄像头的输出像素,窗口尺寸等等 //---------------------------------------------------------------- ...
- 基础学习总结(七)--子线程及Handler
使用子线程获取网络图片1.采用httpUrlConnection直连方式获取图片2.采用子线程方式获取 <LinearLayout xmlns:android="http://sche ...
- IP进制站群原理
百度搜索:“inurl:0×00”,会发现全是以八进制.十六进制形式显示的域名(如下图),当点击后,浏览器会自动将这些域名转换为十进制的ip.这种方式在黑帽圈目前挺火爆的,用于做长尾词排名,可以带来可 ...
- devpress控件属性说明表
XtraEditors 库中所有控件的公共功能 全部都可以绑定数据: 全部都可以独立使用或用于由 Developer Express 提供的容器控件(XtraGrid.XtraVerticalGrid ...
- 【quartz】 入门
把技术债务给还了,首先来一个最简单的demo: 2.x版比1.x有很多改进,1.x基于fw1.2: 2.x基于fw3.5以上:语法上有很大的不同,摒弃了很多1.x的很多东西: 直接以2.x来demo ...
- .NET基础之--C#中判断空字符串的3种方法性能分析
那么为什么if(a.Length==0)最快呢?因为整数判断等于最快,没有经过实例化等复杂的过程. 所以:建议大家判断字符串是否为空用 if(a.Length==0). 对于三种方法的评价: 1.if ...
- CoreLocation MKMapView 地图
系统自带地图 框架: CoreLocation MapKit CLLocationManager --> 定位管理者 CLGeocoder --> 地理编码器 MKMapView -- ...
- bzoj 1295: [SCOI2009]最长距离 暴力+bfs最短路
题目链接: http://www.lydsy.com/JudgeOnline/problem.php?id=1295 题解: 对每个点暴力跑一遍bfs,看能够到达的最远位置,这里如果有障碍物则距离为1 ...
- CSS基础知识学习笔记
1.css基本样式讲解 1.1 css背景background-attachment:背景图像是否固定或者随着页面的其余部分滚动background-color:设置元素的背景颜色background ...