2014-01-21 2 views
2

У меня возникли проблемы с попыткой получить сопоставление конечных точек для работы в моем веб-сервисе. Я использую Tomcat для размещения моего веб-сервиса, и я использую soapUI для отправки тестовых сообщений на него.Нет сопоставления конечных точек для SaajSoapMessage

следующее сообщения из журнала Tomcat показывает создание отображения конечных точек боба:

6458 [http-apr-8080-exec-6] DEBUG org.springframework.ws.soap.server.endpoint.mapping.SoapActionEndpointMapping - Mapped key [{http://endpoint.ws.example.com}pushAbcToXyzOperation] onto endpoint [[email protected][...]] 

Однако отображение конечных точек компонента должна быть неправильной, потому что я получаю следующее «нет отображения конечных точек не найдено» сообщение:

6739 [http-apr-8080-exec-6] WARN org.springframework.ws.server.EndpointNotFound - No endpoint mapping found for [SaajSoapMessage {http://endpoint.ws.example.com}pushAbcToXyzOperation] 

Вот файл web.xml

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" 
     version="2.4"> 

    <display-name>abc2xyzWS</display-name> 

    <servlet> 
     <servlet-name>spring-ws</servlet-name> 
     <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class> 
    <init-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value>WEB-INF/spring-ws-context.xml</param-value> 
    </init-param> 
    </servlet> 

    <servlet-mapping> 
     <servlet-name>spring-ws</servlet-name> 
     <url-pattern>/*</url-pattern> 
    </servlet-mapping> 

</web-app> 

Вот весна-WS-context.xml

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:sws="http://www.springframework.org/schema/web-services" 
     xmlns:context="http://www.springframework.org/schema/context" 
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd 
     http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd"> 

    <sws:annotation-driven/> 
    <context:annotation-config /> 

    <import resource="classpath:/xyz-endpoint-context.xml" /> 

    <!--========================================================== 
    * 
    * Spring Web Service Configuration 
    * 
    =============================================================--> 

    <bean name="loadPayload" class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping"> 
     <description> 
      Detects @PayloadRoot annotations on @Endpoint bean methods. 
     </description> 

     <property name="interceptors"> 
      <list> 
       <bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"/> 
       <bean class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor"> 
        <property name="schema" value="classpath:/AbcAPI.xsd"/> 
        <property name="validateRequest" value="true"/> 
        <property name="validateResponse" value="true"/> 
       </bean> 
      </list> 
     </property> 

     <property name="order" value="1"/> 
    </bean> 

    <bean id="pushService" class="com.abc.xc.model.PushAbcToXyzRequest"/> 

    <bean id="endpointMapping" class="org.springframework.ws.soap.server.endpoint.mapping.SoapActionEndpointMapping"> 
     <property name="mappings"> 
      <props> 
       <prop key="{http://endpoint.ws.example.com}pushAbcToXyzOperation">pushService</prop> 
      </props> 
     </property> 

    </bean> 

</beans> 

Здесь хуг-конечная точка-context.xml

<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:context="http://www.springframework.org/schema/context" 
     xsi:schemaLocation="http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
     http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context-3.0.xsd"> 

    <import resource="classpath:/applicationContext.xml" /> 
    <context:component-scan base-package="com.abc.ws.endpoint"/> 
</beans> 

Вот applicationContext.xml

<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" 
     xmlns:context="http://www.springframework.org/schema/context" 

     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd 
     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> 

    <!--=========================================================================== 
    * 
    * opis2pips service module configuration. 
    * 
    =============================================================================--> 
    <context:property-placeholder location="classpath:/applicationContext.properties"/> 
    <context:component-scan base-package="com.abc.xc.service"/> 

    <bean id="serviceURL" class="java.lang.String"> 
     <constructor-arg><value>${serviceURL}</value></constructor-arg> 
    </bean> 
    ... 
    <bean id="emailerrormessage" class="java.lang.String"> 
     <constructor-arg><value>${emailerrormessage}</value></constructor-arg> 
    </bean> 

</beans> 

Здесь конечная точка

package com.abc.ws.endpoint.endpoint; 

import com.abc.xc.model.WSstatusType; 
import com.abc.xc.model.PushAbcToXyzRequest; 
import com.abc.xc.model.QueryXyzRequest; 
import com.abc.xc.model.XyzResponse; 
import com.abc.xc.service.XyzClient; 
import com.abc.xc.service.WSemailService; 
import com.abc.xc.service.AbcToXyzTranslationService; 
import com.abc.xc.exception.WSexception; 

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 contracts.xyz.GetTicketResponse; 
import contracts.xyz.PostTicketResponse; 
import contracts.xyz.Ticket; 
import contracts.xyz.TicketMessageProcessingResult; 

@Endpoint 
public class XyzWebServiceController { 
    @Autowired 
    private XyzClient XyzClientservice; 
    @Autowired 
    private AbcToXyzTranslationService translationservice; 
    @Autowired 
    WSemailService mailservice; 

    protected static final String NAMESPACE_URI = "http://www.example.com/schema"; 

    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "PushAbcToXyzRequest") 

    @ResponsePayload 
    public XyzResponse PushAbcToXyzOperation(@RequestPayload PushAbcToXyzRequest PushAbcToXyzRequest){ 

     XyzResponse XyzResponse = null; 
     Ticket ticket = null; 
     try { 
      ticket = translationservice.abcInputToXyzTicket(PushAbcToXyzRequest); 
      PostTicketResponse response = XyzClientservice.postTicket(ticket); 
      Long transactionid = response.getInteractionId(); 

      if(transactionid != null){ 
       GetTicketResponse gtresponse = XyzClientservice.getTicket(); 
       Ticket gtresponseTicket = gtresponse.getTicket().getValue(); 
       XyzResponse = translationservice.XyzTicketToXyzResponse(gtresponseTicket); 
      } 

      XyzResponse.setWSstatus(WSstatusType.SUCCESS); 
      mailservice.sendEmail(true, PushAbcToXyzRequest, transactionid); 
... 

Адрес: запрос SOAP

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:end="http://endpoint.ws.example.com" xmlns:mod="http://model.xc.example.com"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <end:pushAbcToXyzOperation> 
     <end:pushAbcToXyzRequest> 
      ... 
     </end:pushAbcToXyzRequest> 
     </end:pushAbcToXyzOperation> 
    </soapenv:Body> 
</soapenv:Envelope> 

Вот часть журнала Tomcat, от создания отображения конечных точек боба, через «не отображения конечных точек найдено» сообщение:

6349 [http-apr-8080-exec-6] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'loadPayload' 
6349 [http-apr-8080-exec-6] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'pushService' 
6349 [http-apr-8080-exec-6] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'pushService' 
6365 [http-apr-8080-exec-6] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'pushService' to allow for resolving potential circular references 
6427 [http-apr-8080-exec-6] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'pushService' 
6427 [http-apr-8080-exec-6] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'endpointMapping' 
6427 [http-apr-8080-exec-6] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'endpointMapping' 
6427 [http-apr-8080-exec-6] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'endpointMapping' to allow for resolving potential circular references 
6443 [http-apr-8080-exec-6] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'pushService' 
6458 [http-apr-8080-exec-6] DEBUG org.springframework.ws.soap.server.endpoint.mapping.SoapActionEndpointMapping - Mapped key [{http://endpoint.ws.example.com}pushAbcToXyzOperation] onto endpoint [[email protected][requestID=<null>, ...]] 
6458 [http-apr-8080-exec-6] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'endpointMapping' 
6458 [http-apr-8080-exec-6] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0' 
6474 [http-apr-8080-exec-6] DEBUG org.springframework.web.context.support.XmlWebApplicationContext - Unable to locate LifecycleProcessor with name 'lifecycleProcessor': using default [[email protected]a0067] 
6474 [http-apr-8080-exec-6] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'lifecycleProcessor' 
6505 [http-apr-8080-exec-6] INFO org.springframework.ws.soap.saaj.SaajSoapMessageFactory - Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol 
6505 [http-apr-8080-exec-6] DEBUG org.springframework.ws.soap.saaj.SaajSoapMessageFactory - Using MessageFactory class [com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl] 
6505 [http-apr-8080-exec-6] DEBUG org.springframework.ws.transport.http.MessageDispatcherServlet - No WebServiceMessageFactory found in servlet 'spring-ws': using default 
6505 [http-apr-8080-exec-6] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter#0' 
6521 [http-apr-8080-exec-6] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.ws.soap.server.endpoint.SoapFaultAnnotationExceptionResolver#0' 
6521 [http-apr-8080-exec-6] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.ws.soap.server.endpoint.SimpleSoapExceptionResolver#0' 
6521 [http-apr-8080-exec-6] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping#0' 
6521 [http-apr-8080-exec-6] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping#0' 
6521 [http-apr-8080-exec-6] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.ws.soap.addressing.server.AnnotationActionEndpointMapping#0' 
6521 [http-apr-8080-exec-6] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'loadPayload' 
6521 [http-apr-8080-exec-6] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'endpointMapping' 
6521 [http-apr-8080-exec-6] DEBUG org.springframework.ws.transport.http.MessageDispatcherServlet - No MessageDispatcher found in servlet 'spring-ws': using default 
6521 [http-apr-8080-exec-6] DEBUG org.springframework.ws.transport.http.MessageDispatcherServlet - Published WebApplicationContext of servlet 'spring-ws' as ServletContext attribute with name [org.springframework.web.servlet.FrameworkServlet.CONTEXT.spring-ws] 
6521 [http-apr-8080-exec-6] INFO org.springframework.ws.transport.http.MessageDispatcherServlet - FrameworkServlet 'spring-ws': initialization completed in 6053 ms 
6521 [http-apr-8080-exec-6] DEBUG org.springframework.ws.transport.http.MessageDispatcherServlet - Servlet 'spring-ws' configured successfully 
6583 [http-apr-8080-exec-6] DEBUG org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter - Accepting incoming [[email protected]c] at [http://localhost:8080/abc2xyzWS/services/XyzWebServiceController] 
6677 [http-apr-8080-exec-6] DEBUG org.springframework.ws.server.MessageTracing.received - Received request [SaajSoapMessage {http://endpoint.ws.example.com}pushAbcToXyzOperation] 
6723 [http-apr-8080-exec-6] DEBUG org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping - Looking up endpoint for [{http://endpoint.ws.example.com}pushAbcToXyzOperation] 
6723 [http-apr-8080-exec-6] DEBUG org.springframework.ws.soap.server.SoapMessageDispatcher - Endpoint mapping [org.springframework.ws.ser[email protected]14481bb] has no mapping for request 
6723 [http-apr-8080-exec-6] DEBUG org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping - Looking up endpoint for [] 
6723 [http-apr-8080-exec-6] DEBUG org.springframework.ws.soap.server.SoapMessageDispatcher - Endpoint mapping [org.springframework.ws.soap.se[email protected]a14fed] has no mapping for request 
6723 [http-apr-8080-exec-6] DEBUG org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping - Looking up endpoint for [{http://endpoint.ws.example.com}pushAbcToXyzOperation] 
6723 [http-apr-8080-exec-6] DEBUG org.springframework.ws.soap.server.SoapMessageDispatcher - Endpoint mapping [org.springframework.ws.ser[email protected]868c6d] has no mapping for request 
6723 [http-apr-8080-exec-6] DEBUG org.springframework.ws.soap.server.SoapMessageDispatcher - Endpoint mapping [org.springfram[email protected]45484a] has no mapping for request 
6723 [http-apr-8080-exec-6] DEBUG org.springframework.ws.soap.server.SoapMessageDispatcher - Endpoint mapping [org.springfram[email protected]8d00c6] has no mapping for request 
6739 [http-apr-8080-exec-6] WARN org.springframework.ws.server.EndpointNotFound - No endpoint mapping found for [SaajSoapMessage {http://endpoint.ws.example.com}pushAbcToXyzOperation] 

Пожалуйста, дайте мне знать, если вы необходимо увидеть какую-либо дополнительную информацию и заранее заблаговременно за любую помощь в решении этой проблемы.

ответ

0

Не должно ли значение NAMESPACE_URI быть таким же, как пространство имен, указанное в wsdl и xml endpointMapping в spring-ws-context.xml? Пространство имен, указанное в NAMESPACE_URI, не включает «.ws», который включен в пространство имен wsdl и конфигурацию конечной точки.

Чтобы помочь устранить эту проблему и в качестве теста регрессии в будущем, вы можете написать «тест интеграции конечных точек», который вы можете запустить из Eclipse и как часть процесса сборки (http://docs.spring.io/spring-ws/site/reference/html/server.html#d5e1526).

0

Я думаю, ваша проблема в том, что у вас есть несколько ApplicationContexts (несколько XML-s, содержащие бин) и PayloadRootAnnotationMethodEndpointMapping по умолчанию выглядит только для конечных точек в своем собственном ApplicationContext (в его собственном XML). Чтобы заставить обнаружение конечных точек в другой XML-х, у вас есть, чтобы установить detectEndpointsInAncestorContexts свойства PayloadRootAnnotationMethodEndpointMapping к истинной.

2

Мы столкнулись с аналогичной проблемой, и в нашем случае EndPoint не был включен в директиву проверки компонентов в конфигурации пружины.

В конфигурации вы указали используете:

<context:component-scan base-package="com.abc.ws.endpoint"/> 

Но ваша конечная точка находится в следующем пакете:

package com.abc.ws.endpoint.endpoint; 

Таким образом, вы должны изменить компонент сканирования тег, что-то вроде:

<context:component-scan base-package="com.abc.ws.endpoint.endpoint"/> 

Или реорганизуйте конечную точку в другую упаковку.

+0

Где я ставлю эту строку, в каком файле? – powder366

+0

В файле конфигурации, загруженном весной во время инициализации, если вы используете xml-конфигурацию вместо аннотаций – ftrujillo

0

В моем случае я просто добавить в контексте пакеты тегов с классом конечных точек и классом реализации, как:

<context:component-scan base-package="com.abc.ws.services ,com.abc.ws.endpoint"/> 
0

Я следовал Spring's guide on creating a SOAP web service using Springboot и получил ту же ошибку. Я не уверен, что вызвало это, но я обнаружил, что, когда я пытался сделать такой запрос, используя WebServiceTemplate в своем тесте интеграции, я получил 404, хотя во время выполнения моего теста сервер был включен и WSDL был доступен. Это то, что я сделал, когда он не работал:

final String request = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n" + 
      "\t\t\t\t xmlns:gs=\"http://spring.io/guides/gs-producing-web-service\">\n" + 
      " <soapenv:Header/>\n" + 
      " <soapenv:Body>\n" + 
      "  <gs:getCountryRequest>\n" + 
      "   <gs:name>Spain</gs:name>\n" + 
      "  </gs:getCountryRequest>\n" + 
      " </soapenv:Body>\n" + 
      "</soapenv:Envelope>"; 

    StreamSource source = new StreamSource(new StringReader(request)); 
    StreamResult result = new StreamResult(System.out); 

    webServiceTemplate.sendSourceAndReceiveToResult("http://localhost:8080/ws", source, result); 

Когда я изменил это использовать маршаллер вместо запроса сырой строки, как это:

 Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); 
    marshaller.setContextPath("io.spring.guides.gs_producing_web_service"); 
    marshaller.setSchema(new ClassPathResource("countries.xsd")); 
    webServiceTemplate.setMarshaller(marshaller); 
    webServiceTemplate.setUnmarshaller(marshaller); 

    GetCountryRequest getCountryRequest = new GetCountryRequest(); 
    getCountryRequest.setName("Spain"); 
    GetCountryResponse getCountryResponse = (GetCountryResponse) webServiceTemplate.marshalSendAndReceive("http://localhost:" + serverPort + "/ws", getCountryRequest); 

    assertThat(getCountryResponse.getCountry().getName()).isEqualTo("Spain"); 
    assertThat(getCountryResponse.getCountry().getCapital()).isEqualTo("Madrid"); 
    assertThat(getCountryResponse.getCountry().getCurrency()).isEqualTo(Currency.EUR); 
    assertThat(getCountryResponse.getCountry().getPopulation()).isEqualTo(46704314); 

где я использовал сгенерированный WSDL классов, то тот же запрос был успешным. У меня такое ощущение, что исходная строка необработанного запроса была несовместима, хотя я мог использовать эту ту же строку с помощью запроса на завивку к моей конечной точке SOAP, и это работает (как это говорит вам делать в руководстве).

0

переименовать класс XyzWebServiceController к XyzWebServiceControllerEndpoint

Смежные вопросы