Announcement Announcement Module
Collapse
No announcement yet.
Help with Basic Tutorial. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with Basic Tutorial.

    Hello,

    I'm trying to integrate simple web service tutorial into my existing Sprng MVC application.

    I'm using Dispatcher Servlet instead of Message Dispatcher servlet, because I would like to use Hibernate bean attached to this application.

    My web.xml is following:

    Code:
    <servlet>
        <servlet-name>doolloop</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>doolloop</servlet-name>
        <url-pattern>*.dlp</url-pattern>
      </servlet-mapping>
       <servlet-mapping>
        <servlet-name>doolloop</servlet-name>
        <url-pattern>/holidayService/*</url-pattern>
      </servlet-mapping>
    Then my all my web services relevant part of doolloop-servlet.xml looks like this:

    Code:
    <bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/>
        <bean class="org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter">
    <property name="messageFactory" ref="messageFactory"/>
    </bean>
        <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="defaultHandler" ref="messageDispatcher"/>
        </bean>
    
        <bean id="messageDispatcher" class="org.springframework.ws.server.MessageDispatcher"/>
    
        <bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>	
    <bean id="holidayEndpoint" class="com.doolloop.services.HolidayEndpoint">
      <constructor-arg ref="hrService" /> 
      </bean>
      <bean id="hrService" class="com.doolloop.services.StubHumanResourceService" /> 
      <bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
      <property name="mappings">
      <props>
      <prop key="{http://mycompany.com/hr/schemas}HolidayRequest">holidayEndpoint</prop> 
      </props>
      </property>
      <property name="interceptors">
      <bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor" /> 
      </property>
      </bean>
      <bean id="holiday" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
      <property name="schema" ref="schema" /> 
      <property name="portTypeName" value="HumanResource" /> 
      <!--  we use a relative uri that will be transformed by spring-ws dep
      --> 
      <property name="locationUri" value="/holidayService/" /> 
      <property name="targetNamespace" value="http://mycompany.com/hr/definitions" /> 
      </bean>
      <bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
      <property name="xsd" value="/WEB-INF/hr.xsd" /> 
      </bean>
    and then I have my EndPoint which is actually the same as in tutorial:

    Code:
    public class HolidayEndpoint extends AbstractJDomPayloadEndpoint {
    
        private XPath startDateExpression;
        private XPath endDateExpression;
        private XPath nameExpression;
        private HumanResourceService humanResourceService;
    
        public HolidayEndpoint(HumanResourceService humanResourceService) throws JDOMException {
            this.humanResourceService = humanResourceService;
            Namespace namespace = Namespace.getNamespace("hr", "http://mycompany.com/hr/schemas");
            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);
        }
    
        protected Element invokeInternal(Element holidayRequest) throws Exception {
            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 null;
        }
    }
    and then service implementation classes are absolutely the same and in example.

    when I trying to browse web service
    http://[host]/[project]/holidayService/

    I'm getting error 405.

    and my log looks like this:

    2010-11-15 15:27:07,969 DEBUG [org.springframework.web.servlet.DispatcherServlet] - DispatcherServlet with name 'doolloop' processing GET request for [/dlp/holidayService/]
    2010-11-15 15:27:07,969 DEBUG [org.springframework.web.servlet.handler.SimpleUrlH andlerMapping] - Mapping [/] to HandlerExecutionChain with handler [org.springframework.ws.server.MessageDispatcher@68 487fb7] and 2 interceptors
    2010-11-15 15:27:07,970 DEBUG [org.springframework.web.servlet.DispatcherServlet] - Last-Modified value for [/dlp/holidayService/] is: -1
    2010-11-15 15:27:07,970 DEBUG [org.springframework.web.servlet.DispatcherServlet] - Null ModelAndView returned to DispatcherServlet with name 'doolloop': assuming HandlerAdapter completed request handling
    2010-11-15 15:27:07,970 DEBUG [org.springframework.web.servlet.DispatcherServlet] - Successfully completed request

    What am i doing wrong please help me.
Working...
X