Нет адаптера для конечной точки; Является ли ваша конечная точка аннотированной с помощью @Endpoint или реализует поддерживаемый интерфейс, например MessageHandler или PayloadEndpoint?
Я борюсь с Spring -WS с примером JMS. Я установил проводку Spring -WS и JMS в соответствии с рекомендациями Spring. Но я продолжал получать следующую ошибку. Я не знаю, как обойти эту проблему, любая помощь будет высоко оценена:
[org.springframework.ws.soap.server.endpoint.SoapFaultAnnotationExceptionResolver] -
Resolving exception from endpoint
[[email protected]c8b0b1]:
java.lang.IllegalStateException: No adapter for endpoint
[[email protected]c8b0b1]:
Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?
[org.springframework.ws.soap.server.endpoint.SimpleSoapExceptionResolver] - Resolving exception from endpoint
[[email protected]c8b0b1]:
java.lang.IllegalStateException: No adapter for endpoint [[email protected]c8b0b1]:
Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?
[org.springframework.ws.soap.server.SoapMessageDispatcher] -
Endpoint invocation resulted in exception - responding with Fault
java.lang.IllegalStateException: No adapter for endpoint [[email protected]c8b0b1]:
Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?
Моя проводка веб-службы
<bean id="imageRepository"
class="org.springframework.ws.samples.mtom.service.StubImageRepository" />
<!-- JMS WIRING TO WS START -->
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory" />
<bean id="messageDispatcher"
class="org.springframework.ws.soap.server.SoapMessageDispatcher">
<property name="endpointMappings">
<bean
class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping">
<property name="defaultEndpoint">
<bean
class="org.springframework.ws.samples.mtom.ws.ImageRepositoryEndpoint">
<constructor-arg ref="imageRepository" />
</bean>
</property>
</bean>
</property>
</bean>
<bean
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="jmsConnectionFactory" />
<property name="destinationName" value="WS.JMS.EXAMPLE.V1.IMAGE.REPO.REQUEST" />
<property name="messageListener">
<bean
class="org.springframework.ws.transport.jms.WebServiceMessageListener">
<property name="messageFactory" ref="messageFactory" />
<property name="messageReceiver" ref="messageDispatcher" />
</bean>
</property>
</bean>
Мой код конечной точки
@PayloadRoot(localPart = "StoreImageRequest", namespace = "http://www.springframework.org/spring-ws/samples/mtom")
@ResponsePayload
public String store(@RequestPayload JAXBElement<Image> requestElement) throws IOException {
Image request = requestElement.getValue();
return imageRepository.storeImage(request.getName());
}
Моя схема
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.springframework.org/spring-ws/samples/mtom"
xmlns:tns="http://www.springframework.org/spring-ws/samples/mtom"
xmlns:xmime="http://www.w3.org/2005/05/xmlmime" elementFormDefault="qualified">
<element name="StoreImageRequest" type="tns:Image"/>
<element name="LoadImageRequest" type="string"/>
<element name="LoadImageResponse" type="tns:Image"/>
<complexType name="Image">
<sequence>
<element name="name" type="string"/>
</sequence>
</complexType>
</schema>
Мой запрос клиента
<ns2:StoreImageRequest xmlns:ns2="http://www.springframework.org/spring-ws/samples/mtom"><ns2:name>spring-ws-logo.png</ns2:name></ns2:StoreImageRequest>
Может кто-нибудь помочь?
Ответы
Ответ 1
У меня было подобное сообщение об ошибке. Моя проблема была в классе запросов и ответов, которые я создал из XSD. Он пропустил аннотацию @XMLRootElement. Это вызвало то, что описание операции (в WSDL) и описание реализованного метода (в конечной точке) не совпадали. Добавление JAXBElement в мой метод конечной точки решает мою проблему.
import javax.xml.bind.JAXBElement;
@PayloadRoot(namespace = "http://foo.bar/books", localPart = "GetBook")
@ResponsePayload
public JAXBElement<MyReponse> getBook(@RequestPayload JAXBElement<MyRequest> myRequest) {
...
Смотрите этот блог для получения дополнительной информации: spring -ws: нет адаптера для конечной точки
Ответ 2
Я не уверен, как выглядит ваша полная Endpoint, но класс должен быть аннотирован с помощью @Endpoint
или он должен реализовать MessageHandler
или PayloadEndpoint
.
С другой стороны, с которой вы можете играть, есть подпись метода. Spring -WS 'отображение конечных точек довольно разумно: оно пытается сопоставить классы ввода и вывода из вашей сигнатуры метода с файлом WSDL. Вы уверены, что String является @ResponsePayLoad, а не StoreImageResponse
?
Например, здесь подпись метода одной из моих конечных точек
@PayloadRoot(
localPart = "GetHiredCandidatesRequest",
namespace = DEFAULT_NAMESPACE
)
@ResponsePayload
public GetHiredCandidatesResponse getCandidates (
@RequestPayload GetHiredCandidatesRequest getCandidate,
MessageContext messageContext) {
...
}
Определяется в моем WSDL следующим образом:
<wsdl:operation name="GetHiredCandidates">
<wsdl:input message="tns:GetHiredCandidatesRequest" name="GetHiredCandidatesRequest"></wsdl:input>
<wsdl:output message="tns:GetHiredCandidatesResponse" name="GetHiredCandidatesResponse"></wsdl:output>
</wsdl:operation>
Вы видите, как оно отображается? Возможно, вы потеряли что-то подобное в своей подписи.
Ответ 3
Во-первых, в соответствии с рекомендациями должен существовать класс Конечная точка
@Endpoint
public class EmpEndpoint {
@Autowired
private EmpService empService;
//This is like @RequestMapping of Spring MVC
@PayloadRoot(localPart = "EmpServiceRequest", namespace = "http://www.example.org/")
@ResponsePayload
public EmpServiceResponse getemployeeDetails(@RequestPayload EmpServiceRequest request) {
EmpServiceResponse response = new ObjectFactory().createEmpServiceResponse();
List<Employee> l = empService.getemployeeDetails(request.getName());
response.setName(l.get(0).getName());
response.setEmail(l.get(0).getEmail());
return response;
}
}
И один Сервис и класс реализации, который будет иметь PayloadRoot и другие аннотации (запрос и ответ)
И поместите это в свой spring -servlet.xml
<!-- To detect @Endpoint -->
<sws:annotation-driven/>
<!-- To detect @Service, @Component etc -->
<context:component-scan base-package="your package for eg com.employee" />
Ответ 4
Такая же проблема, но в моем случае я забыл разместить аннотации @ResponsePayload
и @RequestPayload
в функции обработчика. Просто проверьте это! Это, вероятно, все, что нужно.
Ответ 5
Я использовал файл WSDL и сделал, как показано ниже, тогда это сработало.
@PayloadRoot(namespace = "http://www.myservice/v1.0/query", localPart = "queryRequest")
@ResponsePayload
public JAXBElement<QueryResponse> query(@RequestPayload JAXBElement<QueryRequest> queryRequest) {
System.out.println("Welcome to " + queryRequest.getRequestName());
return new QueryResponse();
}
Ответ 6
У меня была та же ошибка, но я только запускал интеграционные тесты Spring Web Service.
Проблема заключалась в том, что я настроил Jaxb2Marshaller
с другой конфигурацией по сравнению с Jaxb2Marshaller
внутри теста. Я не использовал один и тот же компонент для приложения и тестирования.
Мой Jaxb2Marshaller
с запущенным приложением:
private Jaxb2Marshaller marshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("com.company.application");
marshaller.setMtomEnabled(true);
return marshaller;
}
Но на моих тестах я использовал:
@Before
public void init() throws Exception {
marshaller.setPackagesToScan(ClassUtils.getPackageName(Order.class));
marshaller.afterPropertiesSet();
}
Чтобы тест работал, я просто определил два отсутствующих свойства:
@Before
public void init() throws Exception {
marshaller.setPackagesToScan(ClassUtils.getPackageName(Order.class));
marshaller.afterPropertiesSet();
marshaller.setContextPath("com.company.application");
marshaller.setMtomEnabled(true);
}
Ответ 7
Этот метод работает при вызове из SOAPUI:
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "getOrderDetail")
public @ResponsePayload JAXBElement<OrderDetailResponse> getOrderDetail(@RequestPayload JAXBElement<String> customerId, @RequestPayload JAXBElement<String> promoCode)
В приведенном ниже методе значения внутри customerStatusRequest имеют значение NULL, хотя из SOAPUI я их заполняю.
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "getCustomerStatus")
public @ResponsePayload
JAXBElement<CustomerStatusResponse> getCustomerStatus(@RequestPayload JAXBElement<CustomerStatusRequest> customerStatusRequest)
(CustomerStatusRequest реализует Сериализуемый)
Похоже, значения параметров String делают это через вызов. Но не пользовательский класс.
Я аннотировал класс CustomerStatusRequest следующим образом:
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CustomerStatusRequest", propOrder = {
"customerId",
"gender",
"dob",
"lastName",
"sourceSystemId"
},namespace="http://www.mycompany.com/webservices")
а также каждое поле в CustomerStatusRequest следующим образом:
@XmlElement(name = "customerId", required = true, nillable = true)
Метод вызывается, но значения для customerId и т.д.... все еще имеют значение null. Нужны ли дополнительные аннотации для пользовательского класса?
--Thanks