Using the Wireless Connection Tools


The Wireless Connection Tool is a utility that greatly simplifies the process of developing Java ME applications that connect to third-party web services or other kinds of back-end systems.

The tool can generate two kinds of clients that connect to external services over HTTP. If the device for which you are developing is JSR-172 compliant, you can easily generate a client application from a WSDL file or a URL. If the device does not support JSR-172, the wizard will create a web service proxy in the container, which can then be accessed via a generated servlet over a simple HTTP connection. In addition, you can write your own database proxy and the wizard will also generate a servlet in the container that you can use to access the database via the proxy.

For all the scenarios the wizard will generate a client application that is ready to run on the device and can be edited using the Visual Designer. However, it is a good idea to modify this client application to suite your needs before deploying.

Creating Applications that Consume WS-I Compliant Web Services

If the device you are developing for is JSR-172 compliant, you can easily create a client application that will consume the web service provided that it is WS-I compliant. To generate a client application:

  1. Make sure you have the Sun Java System Application Server installed and properly configured to work with the IDE.

  2. Using the New Project wizard, create a new Mobile Application project.

  3. Using the New File wizard, create a new J2ME Web Service Client.

  4. In the New J2ME Web Service Client wizard (as shown in Figure 14-16), paste the URL of the WSDL file into the WSDL URL field. Then click Retrieve WSDL.

    Figure 14-16. New J2ME Web Service Client wizard

  5. Make sure the Create Sample MIDlet checkbox is marked and click Finish.

    Once the build process finishes, the Visual Designer will open the application for you. You can then edit and customize the Visual MIDlet to your liking.

Creating Applications Using the Web Service Proxy

At the time of this writing, there are very few available devices that implement JSR-172. Because of this, the tool supports an alternate method of connecting to web services via a web service proxy, which sits in the container and talks to the web service for the device. The device talks to a proxy servlet that acts as a liaison between the web service and the device over a simple HTTP protocol.

To create an application that connects to a web service via a web service proxy:

  1. Using the New Project wizard create a Web Application project.

  2. Right-click the web application you have just created, and choose New | Web Service Client.

  3. In the New Web Service Client wizard, paste a URL of a WSDL file very much like when you would be creating J2ME Web Service client, and click Retrieve WSDL. Then click Finish.

  4. Create a new empty Mobile Application project using the New Project wizard.

  5. Right-click the new Mobile Application project, and choose New | Mobile Client to Web Application. (If the Mobile Client to Web Application template does not appear in the New submenu, choose New | File/Folder to access all available templates.)

  6. In the New Mobile Client to Web Application wizard (shown in Figure 14-17), select the web application and the web service client that you have just created.

    Figure 14-17. New Mobile Client to Web Application wizard

  7. In the Package field, name the package into which the classes will be generated.

  8. Select the Web Service Client in Web Application radio button, fill in the web service client to which to link, and click Next.

  9. Select the services whose results you wish to use in your J2ME client application and click Next.

  10. Fill out the client options to your liking and click Finish.

Again, a Visual MIDlet that you can use as a basis for your application will be generated and opened in the Visual Designer. Also, by double-clicking a node with an extension named wsclient in your Mobile Application project, you can change or review the options you have selected previously and regenerate the client.

Using a very similar procedure you can easily connect to any application you might have running in the web container. For example, if you have an application that requires massive processing power to compute a complex mathematical formula, it would be better to perform the calculation on the back end rather than on the device. To do so, you just need to select the Methods in Web Application radio button on the Servlet and Client Type page of the New Mobile Client in Web Application wizard. The wizard will then generate a servlet that will take parameters from the device, pass them to the method, and then send back the result when it becomes available.



NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 279

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net