Example: Creating a remote server connection

The example consists of a simple MIDlet that acts as a Web Service client interfacing with a remote server. The Web Service exposes one simple operation that returns the name of a nation's capital taking the country's name as a parameter. The service has only one operation: getCapital(String nation).

Note: The focus of the example is on the client side.

The example is a normal MIDlet with a simple user interface that allows calling the Web Service over the network. The MIDlet allows the user to enter a country name and it will proceed to contact the Web Service in a separate thread, following the recommendations of doing I/O operations outside the UI thread. Once the result is returned the capital value is displayed. Remote and local errors are also displayed when necessary.

The basic architecture of the example is described in the figure below, following what is shown in the figure Proxy/Stub model.

Figure 124: CapitalMIDlet architecture

Note: All files in this example application contain the Nokia copyright statement.

Note: The example is also provided on Forum Nokia. Instead of creating the example from scratch as shown in this document, you can download the example files and run them immediately with your SDK.