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 中,对异常的处理有 ...
随机推荐
- 把url后面的.html去掉
$url = "http://haichuang1997.bmlink.com/supply/dc_355472.html";echo rtrim($url, '.html');
- HTML5 manifest ApplicationCache
使用 HTML5,通过创建 cache manifest 文件,可以轻松地创建 web 应用的离线版本. HTML5引入了应用程序缓存,这意味着 web 应用可进行缓存,并可在没有因特网连接时进行访问 ...
- Linux5.8下安装PhpMyadmin无法关联php-mcrypt问题
一.yum安装php-mcrypt ##发现没办法安装 原来CentOS 官方默认不在对mcrypt模块 进行支持,所以必须另想办法折腾了2个小时总算搞定,这里主要使用了Fedora的扩展库, E ...
- SequoiaDB数据库集群部署
一般在多机环境下部署数据库的集群模式是比较繁琐的,下面我来分享一个如何通过shell脚本的方式简单.方便地部署我们的集群. 首先,我们要给机器配置信任关系,这样我们就无需手动的输入密码来执行ssh和s ...
- 用nodejs删除mongodb中ObjectId类型数据
mongodb中"_id"下面有个ObjectId类型的数据,想通过这个数据把整个对像删除,费了半天劲终于搞定费话少说上代码 module.exports = function ( ...
- 在Centos7上安装漏洞扫描软件Nessus
本文摘要:简单叙述了在Centos7上安装Nessus扫描器的过程 Nessus 是目前全世界最多人使用的系统漏洞扫描与分析软件,Nessus的用户界面是基于Web界面来访问Nessus漏洞扫描器 ...
- Oracle SQL 劈开字符串
一.数据样例 二.劈开单行 , rownum) h2 FROM (select id_,name_ from test_reg_count t ) CONNECT ; --或者 , rownum) h ...
- ASP.NET MVC +EasyUI 权限设计(一)开篇
在前一段时间中,老魏的确非常的忙碌,Blog基本上没有更新了,非常的抱歉,那么在后面的时间中,老魏会尽量的抽时间来写的,可能时间上就不太富裕了.今天开始呢,老魏会和大家分享一下关于权限设计的有关文章, ...
- RUP(Rational Unified Process)
RUP Rational Unified Process 目前阶段在学习UML,怎么会写RUP呢?学习UML是为了更好的把系统搭建好,RUP也是一样,为系统服务! 软件危机 美国国家总审计局,在198 ...
- WebAPi性能
提高WebAPi性能 前言 WebAPi作为接口请求的一种服务,当我们请求该服务时我们目标是需要快速获取该服务的数据响应,这种情况在大型项目中尤为常见,此时迫切需要提高WebAPi的响应机制,当然 ...