LDSTechForumProjects

GWT RPC Lab 1

GWT RPC

Create a Google Web Application

  1. In the LDS Tech IDE, go to File | New | Web Application Project
  2. In the Project Name: field, enter "GWT RPC".
  3. In the Package: field, enter "org.lds.gwt.rpc".
  4. Uncheck the Use Google App Engine check box.
  5. Click Finish.

This will create a new web application that has both client and server side components. The web application that gets created also contains a sample RPC service.

Examine the Sample RPC Service

  1. Open the Java source file /GWT RPC/src/org/lds/gwt/rpc/client/GreetingService.java. Notice how it extends RemoteService and has the @RemoteServiceRelativePath.
  2. Open the Java source file /GWT RPC/src/org/lds/gwt/rpc/client/GreetingServiceAsync.java. Compare the greetServer method with the one in the GreetingService class.
  3. Open the Java source file /GWT RPC/src/org/lds/gwt/rpc/server/GreetingServiceImpl.java to see the service implementation.
  4. Open the web descriptor /GWT RPC/war/WEB-INF/web.xml. Line 9 starts the servlet declaration. Line 14 starts the servlet mapping. Notice how the first part of the url-pattern matches the module name specified in the module descriptor and the second part matches the value of the @RemoteServiceRelativePath annotation in the remote service interface.
  5. Open the Java source file /GWT RPC/src/org/lds/gwt/rpc/client/GWT_RPC.java. This is the entry point for the GWT module. Go to line 35 to see how the client async interface is instantiated using deferred binding. Go to line 122 to see how the async interface is used to invoke the RPC service.

Run the Sample Application

  1. Right click on the project and select Run As | Web Application. This will start the GWT shell embedded in Eclipse. You should see a new Eclipse view called Development Mode open instead of the GWT Shell as we saw in previous labs.
  2. Copy the URL from the Development Mode view into your web browser.
  3. Test the demo app and make sure everything works.

Create Your Own Service

  1. Create an interface that extends RemoteService. Model this interface after GreetingService. Put at least one method in your service. This method should do something simple like return a string.
  2. Create a corresponding async interface. Model this interface after GreetingServiceAsync. This method must match the name of your newly created remote service interface with the word "Async" appended to it.
  3. Create an implementation of your service interface. Model this implementation after GreetingServiceImpl.
  4. Create a mapping for your service in web.xml.
  5. Add some code to the entry point that instantiates your service and invokes it.
  6. Test your service.

If you finish this lab early, go back and add multiple methods to your remote service.

This page was last modified on 9 June 2010, at 09:33.

Note: Content found in this wiki may not always reflect official Church information. See Terms of Use.