Announcement Announcement Module
Collapse
No announcement yet.
Problems getting HttpInvoker to work Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems getting HttpInvoker to work

    I've been reading about the new HttpInvoker and thought I'd give it a try. I ran the example in jpetstore and decided to implement my own. To demonstrate the concept to others I've pared things down to the absolute minimum and I just cannot get it to work.

    Tomcat shows the request coming in but the client reports :-

    Exception in thread "main" org.springframework.remoting.RemoteAccessException : Cannot access HTTP invoker remote service at [http://192.168.254.205:8080/camserv/request]; nested exception is java.io.FileNotFoundException: http://192.168.254.205:8080/camserv/request
    My application is very simple :-

    Code:
    package webservice;
    public interface IRequestServer {
    	public String ping( );
    }
    
    package webservice;
    public class RequestServer implements IRequestServer {
    	public String ping( ) {
    		return "pong";
    	}
    }
    
    public class PingClient {
    	public static void main( String[] args ) throws	Exception {
    		ApplicationContext ctx = new FileSystemXmlApplicationContext( 
    								"RequestClient.xml" );
    		IRequestServer req = (IRequestServer) ctx.getBean( "ping" );
    		System.out.println( "Ping: " + req.ping( ) );
    	}
    }
    
    <web-app>
    	<servlet>
    		<servlet-name>camserv</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    	<servlet-mapping>
    		<servlet-name>camserv</servlet-name>
    		<url-pattern>/camserv/*</url-pattern>
    	</servlet-mapping>
    </web-app>
    
    <beans>
    	<bean id="requestService" class="webservice.RequestServer"/>
    	<bean
    		name="/request"
    		class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter"
    	>
    		<property name="service"><ref bean="requestService"/></property>
    		<property name="serviceInterface">
    			<value>webservice.IRequestServer</value>
    		</property>
    	</bean>
    </beans>
    
    <beans>
    	<bean
    		id="ping"
    		class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean"
    	>
    		<property name="serviceUrl">
    			<value>http&#58;//192.168.254.205&#58;8080/camserv/request</value>
    		</property>
    		<property name="serviceInterface">
    			<value>webservice.IRequestServer</value>
    		</property>
    	</bean>
    </beans>
    I'm sure it's something simple but I can't for the life of me spot what it is. Any ideas?

  • #2
    It looks pretty good from what you've posted. I would make sure that your config file is being read into the camserv servlet dispatcher. I couldn't tell from looking at your posting.

    I think it needs to be in a file called camserv-config.xml, since you don't explicitly load the context.

    Regards
    Steve

    Comment


    • #3
      Problem sorted

      I confused myself. In the sample application the application is rooted at jpetstore, the servlet at remoting and the service at something else. By calling my application the same name as the servlet I forgot to add the extra component in the pathname. When I did this it worked!

      Comment


      • #4
        yes,need add

        Code:
        	<servlet>
        		<servlet-name>remoting</servlet-name>
        		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        		<load-on-startup>4</load-on-startup>
        	</servlet>
        and

        Code:
        	<servlet-mapping>
        		<servlet-name>remoting</servlet-name>
        		<url-pattern>/remoting/*</url-pattern>
        	</servlet-mapping>
        in web.xml,i was confused by this wholely night.

        Comment

        Working...
        X