2012-02-15 29 views
2

我是初學者,正在設置Spring Web應用程序。我得到了這麼多,但現在我發現自己卡住了。設置Spring Web Service時未找到端點映射

我得到以下錯誤:

WARNING: No endpoint mapping found for [SaajSoapMessage {http://mycompany.com/weather/schemas}GetCities] 

的主要問題是,我已經江郎才盡到哪裏尋找調試信息。我修復了許多我見過的錯誤,但現在我甚至無法在日誌中發現錯誤。所以我有點絕望。

這是我的web.xml

<web-app> 
    <display-name>Weather report webservice</display-name> 

    <servlet> 
     <servlet-name>spring-ws</servlet-name> 
     <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class> 
     <load-on-startup>1</load-on-startup> 
     <init-param> 
      <param-name>contextConfigLocation</param-name> 
      <param-value>/WEB-INF/spring-ws-servlet.xml</param-value> 
     </init-param> 
     <init-param> 
      <param-name>transformWsdlLocations</param-name> 
      <param-value>true</param-value> 
     </init-param> 
    </servlet> 

    <servlet-mapping> 
     <servlet-name>spring-ws</servlet-name> 
     <url-pattern>/weatherws</url-pattern> 
    </servlet-mapping> 
</web-app> 

這是我的春天,WS-servlet.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" 
    xmlns:sws="http://www.springframework.org/schema/web-services" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
    http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd 
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> 

    <context:component-scan base-package="path.to.weather"/> 

    <sws:annotation-driven/> 

</beans> 

這就是我的終點的樣子:

@Endpoint 
public class WeatherEndpoint { 

    private static final String NAMESPACE_URI = "http://mycompany.com/weather/schema"; 

    private WeatherReportManager manager; 

    @Autowired 
    public WeatherEndpoint(WeatherReportManager manager) throws JDOMException { 
     this.manager = manager; 
    } 

    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "GetCities") 
    @ResponsePayload 
    public Element getCities() { 
     Element toReturn = null; 

     for(City city : manager.getCities()) { 
      //To some stuff 
     } 

     return toReturn; 
    } 
} 

這是我現在看到的catalina.log。我試圖通過編輯logging.properties來讓Tomcat輸出DEBUG消息。這並沒有帶來任何額外的影響。

INFO: Deploying web application archive weather.war 
Feb 15, 2012 3:28:51 PM org.springframework.web.servlet.FrameworkServlet initServletBean 
INFO: FrameworkServlet 'spring-ws': initialization started 
Feb 15, 2012 3:28:51 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh 
INFO: Refreshing WebApplicationContext for namespace 'spring-ws-servlet': startup date [Wed Feb 15 15:28:51 EET 2012]; root of context hierarchy 
Feb 15, 2012 3:28:52 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-ws-servlet.xml] 
Feb 15, 2012 3:28:52 PM org.springframework.ws.soap.addressing.server.AbstractAddressingEndpointMapping afterPropertiesSet 
INFO: Supporting [WS-Addressing August 2004, WS-Addressing 1.0] 
Feb 15, 2012 3:28:52 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons 
INFO: Pre-instantiating singletons in org.s[email protected]36496381: defining beans [weatherEndpoint,weatherReportManagerWWW,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping#0,org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping#0,org.springframework.ws.soap.addressing.server.AnnotationActionEndpointMapping#0,org.springframework.ws.server.endpoint.adapter.method.dom.DomPayloadMethodProcessor#0,org.springframework.ws.server.endpoint.adapter.method.SourcePayloadMethodProcessor#0,org.springframework.ws.server.endpoint.adapter.method.jaxb.XmlRootElementPayloadMethodProcessor#0,org.springframework.ws.server.endpoint.adapter.method.jaxb.JaxbElementPayloadMethodProcessor#0,org.springframework.ws.server.endpoint.adapter.method.dom.JDomPayloadMethodProcessor#0,org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter#0,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy 
Feb 15, 2012 3:28:52 PM org.springframework.ws.soap.saaj.SaajSoapMessageFactory afterPropertiesSet 
INFO: Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol 
Feb 15, 2012 3:28:52 PM org.springframework.web.servlet.FrameworkServlet initServletBean 
INFO: FrameworkServlet 'spring-ws': initialization completed in 714 ms 
Feb 15, 2012 3:28:52 PM org.apache.catalina.startup.HostConfig deployDirectory 
INFO: Deploying web application directory docs 
Feb 15, 2012 3:28:52 PM org.apache.catalina.startup.HostConfig deployDirectory 
INFO: Deploying web application directory examples 
Feb 15, 2012 3:28:53 PM org.apache.catalina.startup.HostConfig deployDirectory 
INFO: Deploying web application directory host-manager 
Feb 15, 2012 3:28:53 PM org.apache.catalina.startup.HostConfig deployDirectory 
INFO: Deploying web application directory lib 
Feb 15, 2012 3:28:53 PM org.apache.catalina.startup.HostConfig deployDirectory 
INFO: Deploying web application directory manager 
Feb 15, 2012 3:28:53 PM org.apache.catalina.startup.HostConfig deployDirectory 
INFO: Deploying web application directory ROOT 
Feb 15, 2012 3:28:53 PM org.apache.coyote.http11.Http11Protocol start 
INFO: Starting Coyote HTTP/1.1 on http-8080 
Feb 15, 2012 3:28:53 PM org.apache.coyote.ajp.AjpProtocol start 
INFO: Starting Coyote AJP/1.3 on ajp-8009 
Feb 15, 2012 3:28:53 PM org.apache.catalina.startup.Catalina start 
INFO: Server startup in 8777 ms 
Feb 15, 2012 3:29:07 PM org.springframework.ws.server.MessageDispatcher dispatch 
WARNING: No endpoint mapping found for [SaajSoapMessage {http://mycompany.com/weather/schemas}GetCities] 

我將非常感謝您的任何幫助。如果你需要額外的東西,請告訴我。

+0

您正在將'MessageDispatcherServlet'映射到'weatherws'的基本路徑,但您的其他所有終端都建議您希​​望它成爲'weather'。 – 2012-02-15 14:09:48

+0

@ nicholas.hauschild糾正我,如果我錯了(剛剛在這個)。由於我部署了'weather.war'中的所有內容,因此我使用了soapUI端點'http:// localhost:8080/weather/weatherws'。之後,我將其映射爲「天氣」。然後,我必須使用端點'http:// localhost:8080/weather/weather',但後者具有相同的效果。正如我所看到的,映射似乎不是問題。由於它似乎找到了servlet本身(之前有過初始化servlet的問題)。 – Vampnik 2012-02-15 14:30:26

+0

我對Spring-WS並不熟悉,這對我來說看起來很奇怪。如果你確定你正在打'MessageDispatcherServlet',那麼請隨時忽略我的不瞭解的評論。 :) – 2012-02-15 14:33:47

回答

7

在您的端點代碼,您有:

private static final String NAMESPACE_URI = "http://mycompany.com/weather/schema"; 

但你的消息是從http://mycompany.com/weather/schemas命名空間。請注意最後的s

+1

謝謝你的回覆。這是問題所在。我說他們說的是真實的:「它總是最小的東西。」我開始瘋狂地對此置之不理。 – Vampnik 2012-02-15 14:53:30

+0

@soulcheck應該在XSD中的Request元素後面添加Request。這是一種告訴soap它是一個請求元素的方法嗎? – 2014-08-28 06:54:56

相關問題