java - Spring MVC Web Services Dispatcher -
i'm trying build web service integrated in dispatcherservlet insted of messagedispatcherservlet, according spring ws it's possible. i'm tying follow tutorials , implement code according tutorials.
tomcat starts normally. however, have page 404 when i'm trying access web service using http://[host]/[project]/holidayservice/ i"m doing wrong?
here implementation:
<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>/index.dlp</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>doolloop</servlet-name> <url-pattern>/scene/*</url-pattern> </servlet-mapping>
the relevant part of doolloop-servlet.xml following:
<tx:annotation-driven /> <mvc:annotation-driven /> <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" /> <!-- use relative uri transformed 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>
now endpoint looks this:
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; } }
beside have service implementation, don't think it's relevant , have feeling has dispatcher servlet, have no idea problem is.
i added follow
<servlet-mapping> <servlet-name>doolloop</servlet-name> <url-pattern>/holidayservice/*</url-pattern> </servlet-mapping>
this log4j file showing:
2010-11-15 15:27:07,969 debug [org.springframework.web.servlet.dispatcherservlet] - dispatcherservlet name 'doolloop' processing request [/dlp/holidayservice/] 2010-11-15 15:27:07,969 debug [org.springframework.web.servlet.handler.simpleurlhandlermapping] - mapping [/] handlerexecutionchain handler [org.springframework.ws.server.messagedispatcher@68487fb7] , 2 interceptors 2010-11-15 15:27:07,970 debug [org.springframework.web.servlet.dispatcherservlet] - last-modified value [/dlp/holidayservice/] is: -1 2010-11-15 15:27:07,970 debug [org.springframework.web.servlet.dispatcherservlet] - null modelandview returned dispatcherservlet name 'doolloop': assuming handleradapter completed request handling 2010-11-15 15:27:07,970 debug [org.springframework.web.servlet.dispatcherservlet] - completed request
i'm not familiar spring web-services, note dispatcherservlet
not mapped /holidayservice
.
something this:
<servlet-mapping> <servlet-name>doolloop</servlet-name> <url-pattern>/holydayservice/*</url-pattern> </servlet-mapping>
you need configure mapping of messagedispatcher
described in 5.3.2. wiring spring-ws in dispatcherservlet.
Comments
Post a Comment