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