Announcement Announcement Module
Collapse
No announcement yet.
Spring+XFire+JSR181 HandlerMapping Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring+XFire+JSR181 HandlerMapping

    ok i am trying to use xfire and jsr181 annotations for my web service. I am trying to follow the example here http://xfire.codehaus.org/JSR+181+HandlerMapping
    My problem is with the HandlerMapping. It is not working. I cannot get to my webservice via http://localhost:8080/ws/EdirSyncMDB

    ok here is my code
    web.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="ws" version="2.4" 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">
    	<display-name>ws</display-name>
    	
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>/WEB-INF/wsApp-context.xml,/WEB-INF/acegi-common-context.xml,classpath:org/codehaus/xfire/spring/xfire.xml</param-value>
    	</context-param>
    
      <context-param>
        <param-name>webAppRootKey</param-name>
        <param-value>wsapp</param-value>
      </context-param>
    
    	<listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    
    	<listener>
    		<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    	</listener>
    	
    	<servlet>
    		<servlet-name>wsApp</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    	</servlet>
        <servlet-mapping>
            <servlet-name>wsApp</servlet-name>
            <url-pattern>/*</url-pattern>
        </servlet-mapping>
    	<welcome-file-list>
    		<welcome-file>index.jsp</welcome-file>
    	</welcome-file-list>
        <error-page>
          <error-code>500</error-code>
          <location>/jsps/error500.jsp</location>
        </error-page>
        <error-page>
          <error-code>404</error-code>
          <location>/jsps/error404.jsp</location>
        </error-page>
        <error-page>
          <error-code>403</error-code>
          <location>/jsps/error403.jsps</location>
        </error-page>
    </web-app>
    wsApp-servlet.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans SYSTEM "lib/spring-beans.dtd" >
    <beans>
      
    <!-- ===================== xfire ==================== -->
      <bean id="webAnnotations" class="org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations"/>
      <bean id="handlerMapping" class="org.codehaus.xfire.spring.remoting.Jsr181HandlerMapping">
        <property name="typeMappingRegistry">
          <ref bean="xfire.typeMappingRegistry"/>
        </property>
        <property name="xfire">
          <ref bean="xfire"/>
        </property>
        <property name="webAnnotations">
          <ref bean="webAnnotations"/>
        </property>
        <property name="urlPrefix">
    		<value>/</value>
    	</property>
      </bean>
      
      <bean id="edirSync" class="edu.bju.ws.ldap.edir.EdirSyncMDBImpl"/>
       
     <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="urlMap">
          <map>
            <entry key="/service">
              <ref bean="handlerMapping"/>
            </entry>
          </map>
        </property>
      </bean>
    </beans>
    EdirSyncMDBImpl.java
    Code:
    package edu.bju.ws.ldap.edir;
    
    import edu.bju.shared.ws.ldap.EdirSync;
    
    import javax.jws.WebMethod;
    import javax.jws.WebService;
    
    @WebService(serviceName = "EdirSyncMDB")
    public class EdirSyncMDBImpl {
    	@WebMethod()
    	    public String echo( String echo )
    	    {
    	    	System.out.print("Sending back " + echo);
    	        return echo;
    	    }
    }

  • #2
    Found an error

    <bean class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
    <property name="urlMap">
    <map>
    <entry key="/service">
    <ref bean="handlerMapping"/>
    </entry>
    </map>
    </property>
    </bean>

    Keep key pointing to '/' and your service will be accessible at http://HOST/CONTEXT/services/serviceName
    The 'services' is added automatically by Jsr181 handler.

    So, your url mapping bean definition should look like

    <bean class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
    <property name="urlMap">
    <map>
    <entry key="/">
    <ref bean="handlerMapping"/>
    </entry>
    </map>
    </property>
    </bean>


    Good luck

    Comment

    Working...
    X