Я пытаюсь создать простую веб-службу Hello World, используя этот учебник.
Я использую Java 1.7.0 _04, Spring 2.1, все собрано с помощью Maven и развернуто с помощью Tomcat6. Однако при попытке отправить SOAP-запрос (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?
Я думаю, что проблема с аннотациями, однако мои файлы выглядят так:
web.xml
Khozzy custom WebService
spring-ws
org.springframework.ws.transport.http.MessageDispatcherServlet
transformWsdlLocations
true
spring-ws
/*
весна -ws -servlet.xml
HolidayEndpoint.java
package com.mycompany.hr.ws;
import com.mycompany.hr.service.HumanResourceService;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.Namespace;
import org.jdom.xpath.XPath;
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;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;
import java.text.SimpleDateFormat;
import java.util.Date;
@Endpoint
public class HolidayEndpoint {
private static final String NAMESPACE_URI = "http://mycompany.com/hr/schemas";
private XPath startDateExpression;
private XPath endDateExpression;
private XPath nameExpression;
private HumanResourceService humanResourceService;
@Autowired
public HolidayEndpoint(HumanResourceService humanResourceService) throws JDOMException {
this.humanResourceService = humanResourceService;
Namespace namespace = Namespace.getNamespace("hr",NAMESPACE_URI);
startDateExpression = XPath.newInstance("//hr:StartDate");
startDateExpression.addNamespace(namespace);
endDateExpression = XPath.newInstance("//hr:EndDate");
endDateExpression.addNamespace(namespace);
nameExpression = XPath.newInstance("concat(//hr:FirstName, ' ',//hr:LastName)");
nameExpression.addNamespace(namespace);
}
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "HolidayRequest")
@ResponsePayload
public Element handleHolidayRequest(@RequestPayload Element holidayRequest) throws Exception {
Element toReturn = null;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date startDate = dateFormat.parse(startDateExpression.valueOf(holidayRequest));
Date endDate = dateFormat.parse(endDateExpression.valueOf(holidayRequest));
String name = nameExpression.valueOf(holidayRequest);
humanResourceService.bookHoliday(startDate,endDate,name);
return toReturn;
}
}
hr.xsd