spring webservice 搭建出现的异常处理。异常: NAMESPACE_ERR: An attempt is made to create or change an object in a...

本文介绍了一种解决在Spring WebService项目中使用JDOM作为Endpoint元素映射时遇到的异常问题的方法。通过更新依赖库到JDOM2并调整源代码中的导入路径,可以有效避免异常并确保系统的正常运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

异常: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

enter image description here

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",

转载于:https://www.cnblogs.com/IamThat/p/4622426.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值