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.
- Generate grouped calls. Generates additional code to
support making multiple calls to server-side services in a single HTTP
request or response. When turned on with the Generate Stub Methods option
also turned on, a generated method is created on the client for each exported
service with the stub method name ending in Grouped. Using HelloService
for example, the sayHello() method is exported. The generated
stub method
creates a method on the client called example_HelloService_sayHelloGrouped().
When the option is selected, the server is called only after several
grouped calls are made and the getGroupedResults() method on
the client class is called. All the method calls are invoked in a single
HTTP request and response. Methods are invoked in the order they were
called. Results are returned in an enumeration object.
If a server call causes an exception, the exception is thrown when
getGroupedResults() is called. When an exception is thrown
in a sequence of grouped calls, the calls following the exception are
not processed.
- Allow floating point. Activates support for float and
double data types.
- Generate tracing code. Generates tracing code that
provides runtime information during the execution of remote calls. Client
tracing output goes to the MIDP implementation standard output. Server
tracing output goes to the server log file. Turn this option on to generate
versions of client and server tracing code to help you if connection problems
occur between the client and the server.
- Optionally, choose Create sample MIDlet.
- 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