Creating a Three-Tier Mobile Web Services Client
See Also
With the Mobile Client to Web Application Generator, you create a MIDP client,
a servlet and supporting files to enable a MIDlet to communicate with a Web
service. This type of connection utilizes three "tiers": client, web
application containing servlet, and server. The client communicates with the generated
middleware servlet using a proprietary communication protocol. The servlet and
server communicate using standard Simple Object Access Protocol (SOAP) messages.
The code generated by the Mobile Client to Web Application Generator has
a footprint that can be as small as 3 kilobytes, so it can be deployed on
low-end Java ME MIDP devices. The network bandwidth used in calls from the
client to the server is also efficient, typically using only slightly more
than the minimum needed to transfer the raw data.
The Mobile Client to Web Application Generator creates:
- A Java ME client class
- A servlet and supporting classes
- A mapping file in xml format that can be used to regenerate the server
and Java ME client classes.
- Optionally, a MIDlet you can examine and modify.
To create a mobile client to Web service application:
- Right-click on a project node (or create a new
Mobile application project that is not a Hello MIDlet application) and
choose New File/Folder.
- In the New File wizard, choose MIDP under Categories. Under File Types,
choose Mobile Client to Web Application.
- In the Servlet and Client Type Selection page, select the desired Web application
(if more than one is available) .
The drop-down menu lists all open Web Applications. If you do not see the
Web Application you want, choose Open Web Application and navigate to the
project folder you want to open.
- Enter a name for the generated servlet, then choose a location and package
for the servlet from the drop-down menus.
- Specify whether the mobile client will connect through methods in the Web
application or a Web service client in the Web application. Click Next to
continue.
- If you choose Methods in Web Application, the next page is the Methods in
Web Project page.
If you choose Web Service Client in Web Application, the next page is the
Web Service Operations page.
- The Methods in Web Projects page shows the available methods within the
selected Web project. Check the methods you want the client to use.
- The Web Service Operations page shows the available services within the
selected Web project.
Check the methods you want the client to use.
Click Next.
- Then select from the following generation options:
- Generate stubs. Generates stub (client-side proxy)
methods on the client for each exported service. Method names are incorporated
in the class name. Using HelloService for example, the sayHello()
method is exported. The generated stub method creates a method on the
client called example_HelloService_sayHello(). If this option
is not selected, only one method is generated on the client.
- Allow floating point. Activates support for float and
double data types.
- Click the Finish button.
The settings file is opened in the Editor. Client stubs are generated in the
background.
- Build and deploy the server application. Note that new files were created
in the Web project.
- After the server application is deployed, you can run your Mobile project
and test the generated client.
- Only one client per one WSDL file is supported. You can create more clients
or create a composite service and access through the Mobile Client to Web
Application Generator via a generic service mode.
- The same applies for special data types like enumerations and other non
WS-I compliant data types. A wrapper class can be created and accessed via
the Mobile Client to Web Application Generator as well.
- Secure URLs are not currently supported by the Mobile Client to Web Application
Generator if they are behind a firewall and require proxy settings. In that
case, you must download the WSDL file using your web browser.
- JDK 1.5 is required for creating Web services. If you do not have JDK 1.5
or you are limited to JDK 1.4 , you can download extra modules from the Auto
Update center (Tools>Update Center).
- The generated files should not be edited. Any changes made to the files
(except the sample MIDlet) are lost when you regenerate
them.
- See Also
-
- Creating a MIDP Client/Server Application
- Updating Java ME Web Services Client Files
-
Legal Notices