Skip Headers
Oracle® Application Server Wireless Developer's Guide
10g Release 2 (10.1.2)
B13819-02
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

12 J2ME Development and Provisioning

Each section of this document presents a different topic. These sections include:

12.1 Overview of J2ME

J2ME (Java 2, Micro Edition) is a technology for Java applications on small devices. As an application development platform, J2ME is standard-based and offers a rich UI, one that is comparable to browser-based solutions. In addition, J2ME-based applications are more resilient to network disruption because they do not depend on a wireless network to perform many sophisticated operations.

With the increasing market penetration of J2ME-capable handsets, enterprises are eager to develop J2ME applications to access their back-end applications for their mobile employees. Operators are also seeking to expand their revenue source by deploying new customer applications on these handsets.

OracleAS Wireless provides a complete J2ME offering, which includes a J2ME Developer Kit as a component of OracleAS Wireless Developer Kit for developing Web service-enabled J2ME applications, J2ME application management, and J2ME application provisioning which enables the flexible and reliable provisioning of J2ME applications to handsets.

The key features provided by the OracleAS Wireless J2ME solution include:

OracleAS Wireless J2ME solution not only enables Service Developers to quickly develop J2ME application that integrate with enterprise back-end systems through Web service technology, but also enables Content Managers to easily manage these applications. The provisioning and Digital Rights Management support offers a new means of creating revenue for the operators and service providers marketing J2ME applications to their consumers.

12.1.1 Overview of J2ME Features

The following sections provide an overview of the following features of the J2ME Client Library and J2ME Proxy Server:

12.1.1.1 Minimum Memory Requirement in the MIDlet Suite

MIDlets are packaged and deployed as MIDlet Suite. Each MIDlet suite contains the MIDlet's JAR file and its descriptor (JAD) file. The J2ME Client Library client JAR file requires only 26 KB of memory in a MIDlet suite. A currently available alternative is kSOAP 1.2, which is 41 KB and requires kXML, which adds another 21 KB for a total size of 62 KB.

The proxy server enables the 36 KB memory requirement because the server performs the operations on the Web services, thereby reducing the amount of work performed by MIDP device.

12.1.1.2 Simple Registration and Invocation of Web Services

The entire process of a J2ME MIDlet calling a Web service consists of:

  1. Registering a Web service with the J2ME Proxy Server using the Web service's WSDL (Web Services Definition Language) document.

  2. Generating a J2ME client stub class for the registered service.

  3. Calling a Java method on the generated stub class from your J2ME MIDlet. Each method in the generated J2ME client stub represents an operation of the Web service. For example, a MIDlet compiled with the J2ME Client Library JAR file makes a request to a Web service simply by making a Java method call.

12.1.1.3 Access to Both SOAP Web Services and Enterprise Applications

To register SOAP Web services with the J2ME Proxy Server, you provide the file location of the Web service's WSDL document. During WSDL Registration, the J2ME Proxy Server generates a SOAP client Java class. During execution, the J2ME Proxy Server calls this client class to invoke operations on the Web service.

The J2ME Proxy Server also supports a second type of registration called Class Registration, which enables you to register any Java class with the J2ME Proxy Server. This enables you to access enterprise applications from J2ME MIDlets by creating a Java client to these applications. Once you register this Java client with the J2ME Proxy Server, all of the public methods of the Java class become available for invocation from the J2ME MIDlet.

12.1.1.4 Result Caching and Call Queuing

The methods in the generated J2ME client stub classes contain additional parameters that allow you to cache the result from a Web service call in local persistent storage on the MIDP device. This enables the MIDlet to access the results returned from the Web service repeatedly without requiring additional network round-trips, even after the device has been turned off or has been moved to an area without network access.

Call queuing enables you to queue Web service operation invocations if a network error prevents calling a Web service normally. The J2ME Client Library runtime automatically retries the queued calls until they succeed, and then caches the responses in persistent storage until MIDlet retrieves them.

12.1.1.5 Request and Response Packetization and Compression

Request packetization enables you to specify a maximum request size for cases in which a wireless network cannot handle HTTP requests that exceed a certain size. The J2ME Client Library and J2ME Proxy Server automatically break up call requests and responses into pieces no larger than the maximum specified size.

The J2ME Client Library and J2ME Proxy Server compress requests and responses for improved bandwidth and memory usage. Requests and responses are encoded to reduce their size during network transmission and when cached in the MIDlet. This is done automatically.

12.1.1.6 Session Support

Session support is activated by default, meaning that an instance of the Java class registered with the J2ME Proxy Server (a class that was either generated during WSDL Registration or provided during Class Registration) is stored in an HttpSession object and then reused when the J2ME Proxy Server receives multiple requests from the same MIDlet. Session support can be turned off by setting a property in the J2ME Client Library.

12.1.1.7 Deployment to OracleAS Wireless

Once you complete the development of a MIDlet, the J2ME MIDlets and the Web services registered with the J2ME Proxy Server can be easily deployed to a complete OracleAS Wireless installation. The WDK and OracleAS Wireless contain migration scripts to facilitate this deployment.

12.1.2 Getting Started with the Wireless Development Kit

This section describes how to develop Web service-enabled J2ME MIDlets using the J2ME Web Services Client Library (J2ME Client Library) and the J2ME Web Services Proxy Server (J2ME Proxy Server) in the Wireless Development Kit (WDK).

12.1.2.1 Setup

The OracleAS Wireless Proxy Server consists of two sets of components: the actual server and the scripts to manage the server.

  1. First launch the WDK server, which includes the J2ME Proxy Server, by executing the following script:

    Windows: ORALCE_HOME\opmn\bin\opmnctl start wdk

    UNIX: ORACLE_HOME/opmn/bin/opmnctl.sh start wdk

  2. If you are running the Wireless Development Kit behind a firewall, you must also configure your HTTP proxy server settings in the j2mesdkmgr.bat (Windows) and j2mesdkmgr.sh (UNIX) scripts, located in ORACLE_HOME\wireless\bin/. The scripts contain commented-out examples for setting the HTTP proxy server for -registerwsdl option. If you want to register Java classes as services and the classes are at URLs which are outside of your firewall, you must also include HTTP proxy server settings in the –registerclass option of above scripts. As illustrated in the examples for the -registerwsdl option, setting the HTTP proxy server consists of defining the following variables in the Java command line:

    Dhttp.useProxy=true -Dhttp.proxyHost=<http proxy server>
    Dhttp.proxyPort=<port number> -Dhttp.nonProxyHosts=<hosts inside firewall>
    
    

12.1.2.2 J2ME Directory Structure in the WDK

The following are the WDK directories relevant to the J2ME Client Library and J2ME Proxy Server.

  • wireless/-- (OracleAS Wireless and WDK home)

    • bin/ (scripts for registration and management of Web services)

    • lib/ (libraries and properties files)

    • j2me/-- (J2me sdk home)

      • docs/Javadoc (J2me SKD API documentation)

      • lib/ (contains J2me DK JAR file)

      • sample/ (sample MIDlets and WSDL files)

  • j2ee/OC4J_Wireless/-- (OracleAS Wireless J2EE base)

    • applications/wdk/wdk-Web/Webservice -- (J2ME proxy server home)

      • repository/ (descriptions of registered Web services)

      • stage/ (source of classes generated during WSDL registration)

      • classes/ (compiled classes generated during WSDL registration)

      • lib/ (contains jar file with test services used by sample MIDlets)

      • src/ (source code)

12.1.3 Walk-Through: Developing a J2ME MIDlet

This section walks you through the following step for creating a J2ME MIDlet that calls a Web service:

  • Step 1: Registering a Web Service with the J2ME Proxy Server

  • Step 2: Generating a J2ME Client Stub Class for the Registered Web Service

  • Step 3: Calling the Methods in the J2ME Stub Class from the MIDlet

The Wireless Tools provide you with a graphical interface to the J2ME Proxy Server. In the Wireless Development Kit, however, the interface to the J2ME Proxy Server is through command-line scripts. The J2ME Proxy Server registration and management scripts are:

For Windows: ORACLE_HOME\wireless\bin\j2mesdkmgr.bat

For UNIX: ORACLE_HOME/wireless/bin/ j2mesdkmgr.sh

12.1.3.1 Step 1: Register a Web Service with the J2ME Proxy Server

You can register a Web service either through Web Service Registration or through Class Registration.

For Web Service Registration, you registering Web services with the J2ME Proxy Server to make those Web services accessible to J2ME MIDlets. You register a SOAP Web service with the J2ME Proxy Server by providing the WSDL document describing the Web service. Once registered, the Web service is available to J2ME MIDlets by calling methods of a J2ME stub class generated from the registered service.

In addition to registering SOAP Web services, you can also register any Java class with the J2ME Proxy Server using Class Registration. All of the public methods of the Java class become available for remote invocation from your MIDlet. This enables you to give your MIDlets access to any enterprise application simply by building a Java client to the enterprise application. This Java class must have either a public constructor with no arguments or a public static method called getInstance() with no arguments that returns an instance of the class.

Namespaces

When registering Web services, you can group them into namespaces. Associating services with a namespace enables you to group related Web services and to avoid naming conflicts. If you do not specify a namespace, then the Web service is registered under the default namespace.

WSDL Registration Script Option (registerwsdl)

j2mesdkmgr –registerwsdl registers a Web service using the Web service's WSDL document.

Usage:

j2mesdkmgr –registerwsdl <URL of the WSDL> [<namespace>]

For example, to register the Hello World service (hello.wsdl) available from the Oracle Technology Network (OTN), execute:

For Windows:

j2mesdkmgr.bat –registerwsdl http://www.oracle.com/technology/tech/Webservices/htdocs/live/hello.wsdl

For UNIX:

j2mesdkmgr.sh –registerwsdl http://www.oracle.com/technology/tech/Webservices/htdocs/live/hello.wsdl

To register the service inside a namespace, use the namespace as the third parameter to the script. For example, to register the Hello World application in a namespace called samples, execute:

For Windows:

j2mesdkmgr.bat –registerwsdl http://www.oracle.com/technology/tech/Webservices/htdocs/live/hello.wsdl samples

For UNIX:

j2mesdkmgr.sh –registerwsdl http://www.oracle.com/technology/tech/Webservices/htdocs/live/hello.wsdl samples

Class Registration Script Option (registerclass)

j2mesdkmgr –registerclass registers a Web service using a Java class.

Usage:

j2mesdkmgr -registerclass <URL of the Class Library> <Name of the class> [<namespace>]

The first parameter must be a URL. It may point to either a directory containing the class or to a JAR file.

The second parameter must be a fully qualified class name. For example, to register a service called TestWebService (which is included in the WDK), execute:

For Windows:

j2mesdkmgr.bat -registerclass file:C:\ora9ias\j2ee\OC4J_Wireless\applications\wdk\wdk-Web\Webservice\lib\testservices.jar oracle.wireless.me.server.TestWebService

For UNIX:

j2mesdkmgr.sh -registerclass file:/ias/j2ee/OC4J_Wireless/applications/wdk/wdk-Web/Webservice/lib/testservices.jar oracle.wireless.me.server.TestWebService


Note:

For this example, the WDK home directory is /iaswv904/wireless (UNIX) and C:\iaswv904\wireless (Windows).

To register the service inside a namespace, use the namespace as the fourth parameter to the script. For example, to register the TestWebService class in the samples namespace, execute:

For Windows:

j2mesdkmgr.bat -registerclass file:C:\ora9ias\j2ee\OC4J_Wireless\applications\wdk\wdk-Web\Webservice\lib\testservices.jar oracle.wireless.me.server.TestWebService samples

For UNIX:

j2mesdkmgr.sh -registerclass file:/ias/j2ee/OC4J_Wilreless/applications/wdk/wdk-Web/Webservice/lib/testservices.jar oracle.wireless.me.server.TestWebService samples

12.1.3.2 Step 2: Generate J2ME Client Stub Class for the Registered Web Service

The simplest way to call a Web service that you have registered with the J2ME Proxy Server from your MIDlet is to generate a J2ME stub for the service and to call the methods of the generated stub from your MIDlet.

Stub Generation Script Option (-generatestub)

j2mesdkmgr -generatestub generates a J2ME client stub class for a registered Web service.

Usage:

j2mesdkmgr -generatestub [<namespace>.]<service name> [<Output directory> [<stub name>]]

For example, to generate a J2ME stub class for the Hello World service available from the Oracle Technology Network (IOTNHelloWorld):

j2mesdkmgr -generatestub IOTNHelloWorld

If the service is inside a namespace, you must prefix the service name with the namespace and a period (.). For example, if the Hello World service (IOTNHelloWorld) is registered inside the samples namespace, generate the stub with:

j2mesdkmgr -generatestub samples.IOTNHelloWorld

You can specify a directory in which to place the generated stub as a third parameter to the script.

If you do not specify a stub name, then the generated J2ME client stub class will be called:

IOTNHelloWorldJ2MEStub.Java

To specify a different name for the generated stub, specify an output directory as the third parameter (tmp in the following examples) and the desired stub class name (HelloWord in the following examples) as the fourth parameter. For example:

For Windows:

j2mesdkmgr.bat -generatestub samples.IOTNHelloWorld c:\tmp HelloWorld

For UNIX:

j2mesdkmgr.sh -generatestub samples.IOTNHelloWorld /tmp HelloWorld

The generated J2ME client stub class contains one method for each operation of the Web service.

12.1.3.3 Step 3: Calling the Methods in the J2ME Stub Class from the MIDlet

Each of the public methods in the generated J2ME stub class represents an operation of a registered service. The first two parameters of each method have special meaning to J2ME Client Library: the first parameter is the number of minutes to cache the response; the second parameter is a boolean, which should be set to true to bypass any cached responses (that is, force the J2ME Client Library to make a network call to the Web service), and set to false to use a cached response if available and valid. For more information about these parameters, see Section 12.1.4.1, "Response Caching".

All of the other parameters of the methods in the generated stub correspond to the parameters of the service operation that the method represents. Calling these methods from your MIDlet invokes these operations on the Web service.

To test your MIDlet with Sun's J2ME Wireless Toolkit (http://java.sun.com/products/j2mewtoolkit/download.html):

  1. Create a project for your MIDlet. Put the J2ME Client Library JAR file j2me_sdk.jar in the lib directory of your project. Put the generated J2ME stub class in the src directory of your project.

  2. In the source code of your J2ME MIDlet, enter an import statement for the generated J2ME stub class, create an instance of the stub class, and make calls to the methods in the stub class. The first parameter of each stub method is the number of minutes to cache the result. Set 0 for no caching, or -1 to cache forever. The second parameter of each stub method is true to ignore cached results (that is, always make a network call), or false to use valid cached results if available. The remaining parameters of the stub methods correspond to the parameters of the Web service operations represented by the methods.

  3. Build and run your J2ME MIDlet.

12.1.3.3.1 Hello World Example

The J2ME Client Library contains several sample MIDlets. One of these calls the IOTNHelloWorld service using a generated stub. The sample MIDlet is:

ORACLE_HOME\wireless\j2me\j2mesdk\sample\HelloWorld.Java


Note:

The directory also contains other MIDlets that have examples of calling Web services through the J2ME Proxy Server using either generated stubs or the J2ME Client Library API.

12.1.3.3.2 Other Management Command Line Utilities

The listservices option lists all of the registered services. The removeservice option removes registered services.

The Listing Services Option (-listservices)

The option j2mesdkmgr –listservices lists all the registered services. This script takes no parameters.

This script lists all registered services, but does not list the methods available in the services or the parameters that the methods take. You can view this information with a Web browser, using the URL to the J2ME Proxy Server in the WDK:

http://<host name>:9010/wdk/proxy

For example:

http://www.example.com:9010/wdk/proxy

The Removing Services Option (-removeservice)

The option j2mesdkmgr –removeservice removes registered services.

Usage:

j2mesdkmgr –removeservice [<namespace>.]<service name>

For example, to remove the registered service Hello World (IOTNHelloWord):

j2mesdkmgr –removeservice IOTNHelloWorld.

If the service is inside a namespace, you must prefix the service name with the namespace and a period (.). For example, to remove the Hello World service (IOTNHelloWorld), which is registered inside the samples namespace:

j2mesdkmgr –removeservice samples.IOTNHelloWorld

12.1.3.4 Using TestStubMidlet to Access Simple Services

The J2ME Client Library provides a sample J2ME MIDlet, called TestStubMidlet, which enables you to quickly test the generated stub files for the Web services that you register with the J2ME Proxy Server.

To use the sample TestStubMidlet:

  1. Download and install Sun's J2ME Wireless Toolkit at http://java.sun.com/products/j2mewtoolkit/download.html

  2. Make the following modifications to the sample MIDlet file TestStubMidlet.Java, which is located in:

    ORACLE_HOME/wireless/j2me/j2mesdk/sample/

    1. Add an import statement for the generated Java stub class.

    2. Modify the callStub()method to instantiate the stub class, call the operation, and assign the result to the instance variable sCallResultString, used to display the result.

  3. Create a Project in Sun's J2ME Wireless Toolkit. (You must first locate the OracleJ2ME Web Service Client Library, j2me_sdk.jar, which is located in ORACLE_HOME/wireless/wdk/j2me/lib/)

    Place this library inside the lib directory of the project. Place the stub class in the src directory of the project, and place the modified TestStubMidlet class in an oracle/wireless/me/sample1/ subdirectory inside the src directory of the project (TestStubMidlet is in the package oracle.wireless.me.sample1)

  4. Build and run the project. When the J2ME device emulator appears, launch the test MIDlet and execute Call Stub. The test result then appears.

    Example:

    This example uses TestStubMidlet to call the XMethods Delayed Stock Quote Web service to display a stock quote for Oracle Corporation:

    1. Register the XMethods Delayed Stock Quote Web service (xmethods-delayed-quotes.wsdl):

      j2mesdkmgr -registerwsdl http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl

    2. Generate the stub:

      j2mesdkmgr -generatestub NetXmethodsServicesStockquoteStockQuoteService

    3. Modify TestStubMidlet.Java as in Example 12-1.

      Example 12-1 Modifying TestStubMidlet.java

      ...
      import NetXmethodsServicesStockquoteStockQuoteServiceJ2MEStub;
      ...
      /**
      * Call Stub. Edit this method to test the stub.
      * Remember to import the stub class
      */
      private void callStub()
      {
        try {
          // Add your code to test the stub.
          // For example:
          // Use the stub to call the XMethods delayed stock quote service to get
          // Oracle's stock price and cache the result for 1 minute.
          // Instantiate the Stub class:
          NetXmethodsServicesStockquoteStockQuoteServiceJ2MEStub stub =
             new NetXmethodsServicesStockquoteStockQuoteServiceJ2MEStub();
       
          // Call GetQuote Operation to get Oracle's stock price and
          // cache the result for 1 minute
          sCallResultString = new String("Stock price for ORCL :" +
               stub.getQuote(1, false, "ORCL"));
        }
      ...
      
    4. Build and run. The delayed stock quote for Oracle appears on the test result screen. If you invoke the stub a second time within one minute, the result appears quickly, since it is reading from the local cache without making a round trip to the network.

12.1.3.4.1 Using TestStubMIDlet for Other Web Services

You can register and test the following Web services with TestStubMidlet:

http://www.oracle.com/technology/tech/Webservices/htdocs/live/hello.wsdl

12.1.3.4.2 TestWebService and TestWebService2 Sample Services

The J2ME Proxy Server in OracleAS Wireless includes a JAR file with two simple sample Web services in the Java classes. Some of the sample MIDlets distributed with the J2ME Client Library use these sample services. To register them, execute the scripts:

For Windows:

<ORALCE_HOME>\wireless\bin\installj2mesamples.bat

For UNIX:

<ORALCE_HOME>/wireless/bin/installj2mesamples.sh

The script registers two Java classes as Web services – TestWebService and TestWebService2.

The TestWebService class contains several simple methods for testing different parameter types. It has a public constructor with no arguments.

The TestWebService2 class contains one simple test method and a getInstance() method with no arguments that returns an instance of TestWebService2. Its constructor is private.

The source code for these test services can be found at:

ORACLE_HOME/j2ee/OC4J_Wireless/applications/wdk/wdk-Web/Webservice/src

The JAR file that contains the compiled services is:

ORACLE_HOME/j2ee/OC4J_Wireless/applications/wdk/wdk-Web/Webservice/lib/testservices.jar

12.1.4 Advanced Features

This section describes the usage instructions for the key features provided by the J2ME Client Library and J2ME Proxy Server.

12.1.4.1 Response Caching

The first two parameters of every public method in a generated stub are int timetokeep and boolean refresh. These parameters are used to control response caching. The J2ME Client Library is able to cache the response of a Web service operation in persistent memory on the wireless device. For future invocations of the same operation, the response is retrieved from the local cache instead of from the Web service.

int timetokeep

This is the time in minutes to keep the response in the cache. Further invocations of the same operation within the specified number of minutes will retrieve the response from the local cache instead of making a network round-trip to the Web service. After the specified number of minutes has elapsed, the response in the cache becomes invalid, and the next invocation of this operation will again make a network round-trip to the Web service. Set this parameter to 0 to disable caching, or to –1 to cache forever (the response never becomes invalid).

boolean refresh

This parameter indicates whether to bypass the cache when invoking this operation. Setting this parameter to true forces a network round-trip, even if a valid response is available in the local cache. If this parameter is false, the response if retrieved from the local cache if an available cached response is valid.

12.1.4.2 HTTP Authentication

The J2ME Proxy Server and Client Library support accessing Web services that use the HTTP basic authentication scheme. To set the username and password for authentication, update the Web services' generated stub, setting the instance variables userName and password to the appropriate values. This username and password will be passed to the Web service's HTTP server by the proxy server for authentication.

12.1.4.3 Session Support

Session support is activated by default. To disable session support, update the Web services' generated stub, setting the enableSession instance variable to false. The J2ME Proxy Server uses a Java class to invoke operations on the Web service whether you use WSDL Registration or Class Registration to register a Web service with the J2ME Proxy Server, Session support means that successive invocations of operations of a Web service coming from the same J2ME device use the same instance object of this Java class. The instance of the class is saved in the J2ME Proxy Server's servlet HttpSession object, so it is available as long as the HTTP session is valid.

12.1.4.4 Request and Response Packetization

The J2ME Client Library sends requests to the J2ME Proxy Server using HTTP, the only protocol that is guaranteed to support all MIDP implementations. Some wireless carriers are unable to correctly send an HTTP request if it exceeds a certain size. To work around this problem, the J2ME Client Library enables you to specify a maximum size in bytes for the request and response. In the J2ME stub generated for a Web service, edit the maxRequestSize instance variable to set the maximum HTTP request and response size in bytes.

12.1.4.5 Client Library API

In most cases, you can use the server-generated client stub to invoke services registered with the J2ME Proxy Server. If you want to use an advanced feature such as call queuing, however, you must use the Client Library API directly, either from your own MIDlet, or by modifying the generated stub.

The API documentation for the J2ME Client Library is located at:

ORACLE_HOME\wireless\j2me\Javadoc\index.html

12.1.4.5.1 Web Service Calls

Use the ServiceFactory class to create Service objects, which represent services registered with the J2ME Proxy Server. For convenient access, store the URL of the J2ME Proxy Server as a property of your MIDlet suite. For example, to create a Service object for the TestWebService class in the default namespace (assuming that the J2ME Proxy Server URL is stored in a MIDlet suite property called j2me_proxy_url), see Example 12-2.

Example 12-2 Creating service objects

// Get the URL of the J2ME proxy server.
String servURL = getAppProperty("j2me_proxy_url");
if (servURL == null) {
servURL = "http://localhost:9010/wdk/proxy";
System.out.println("Unable to get j2me_proxy app property, using
default: " + servURL);
}
ServiceFactory serviceFactory = ServiceFactory.getInstance();
Service service = serviceFactory.createService(servURL,Service.DEFAULT_NAMESPACE,"TestWebService");

In Example 12-2, the first parameter to createService is the URL of the J2ME Proxy Server, servURL the second is the namespace that contains the service (Service.DEFAULT_NAMESPACE), and the third is the name of the registered service ("TestWebService").

Once you have an object of class Service, you can create Call objects. Each Call object represents an operation of the remote Web service. For example, to create a Call object for an operation called hello:

// Set cache timeout to 1 hour.
Call call = service.createCall("hello", 60);

The first parameter to createCall is the name of the operation of the Web service ("hello"). The second parameter is the number of minutes to cache the response in the wireless device (60). Enter 0 to disable response caching, and –1 to cache forever. For more information, see Section 12.1.4.1, "Response Caching".

Once you have a Call object, you can invoke the Web service operation that it represents. Build a Java Vector to hold the parameters, and then call the Call object's invoke method. Assuming the hello operation takes a single String parameter, invoke hello is as follows:

// Put the parameters in a Vector.
Vector params = new Vector();
params.addElement( new String("World") );
Response response = call.invoke(params, false);

The first parameter to the Call object's invoke method is the Vector of parameters for the Web service operation. The second parameter may be set to true if you want to bypass the local cache. In other words, true ignores any valid cached response and forces a network call to the remote Web service. For more information, see Section 12.1.4.1, "Response Caching".

The invoke method returns a Response object. Always check the Response object's return code. If it is 0, then the call succeeded and you can use the Response object's methods to access the information returned from the remote operation. If the return code is not 0, use the Response object's getErrorMsg method to get the error message. Assuming that the operation, hello, returns a String, perform the following, in Example 12-3.

Example 12-3 Response object

// Check if the response is valid (0 = OK).
int retCode = response.getReturnCode();
String retVal;
if (retCode == 0) {
  retVal = response.getString();
}
else { // return code not 0
  retVal = "Call unsuccessful: " + response.getErrorMsg();
}
12.1.4.5.2 Setting Properties

Use the Service.setProperty method to set the following properties of the Service object, which represents a Web service registered with the J2ME Proxy Server:

Service.USERNAME and Service.PASSWORD – Set these properties to access Web services that require basic HTTP authentication.

Service.SESSION_MAINTAIN – Set this property to enable or disable session support. For more information, see Section 12.1.1.6, "Session Support".

Service.MAX_REQUEST_SIZE – Set the maximum HTTP request and response size. For more information, see Section 12.1.4.4, "Request and Response Packetization".

12.1.4.5.3 Call Queuing

Calls to Web services from wireless devices sometimes fail due to network connectivity problems. The J2ME Client Library enables MIDlets to queue Web service calls for later invocation. Once queued, the J2ME Client Library automatically retries the call periodically until it succeeds. You would queue a call following a network error using the ServiceManager.queueCall method, as in Example 12-4.

Example 12-4 Call queuing

try {
   Response response = call.invoke(params, false);
...
catch (ServiceException se) {
   if (se.getErrorCode() == ServiceException.CONNECTION_FAILED) {
      int queuedId = ServiceManager.getInstance().queueCall(call);
   }
   ...
}
...

Use the getQueuedCalls method of the ServiceManager class to retrieve queued calls. Set the boolean parameter of getQueuedCalls to true to retrieve the IDs of queued calls that have already been invoked, and false to retrieve the IDs of queued calls that have not yet been invoked. Then, use the ServiceManager.getQueuedCall method to get a Call object from an ID, and use Call.getResponse to retrieve the response to the call.

To find the queued Web service calls that have been invoked, use the code in Example 12-5 .

Example 12-5 Finding queued Web service calls that have been invoked

int[] queuedIds = ServiceManager.getInstance().getQueuedCalls( true );
for (int i = 0; i < queuedIds.length; i++){
  //Retrieve Call object
  Call invokedCall =
     ServiceManager.getInstance().getQueuedCall(queuedIds[i]);
  Response response = invokedCall.getResponse();
  ...
}

To find the queued calls that have not been invoked, use the code in Example 12-6.

Example 12-6 Finding queued Web service calls that have not been invoked

...
int[] queuedIds = ServiceManager.getInstance().getQueuedCalls( false );
...
12.1.4.5.4 Required MIDlet Cleanup

You should always call the close() method of the ServiceManager class when your MIDlet exits. This closes the RMS RecordStore used for Response Caching and Call Queuing. In a J2SE environment, this is performed in the ServiceManager's finalize() method. However, J2ME does not support the finalize() method. As a result, your code is responsible for closing the RMS RecordStore used by the J2ME Client Library.

You must collect all the cleanup code for your MIDlet into one method, which you call from the MIDlet's destroyApp method and from any other code that would cause the MIDlet to terminate (such as an Exit command). In Example 12-7, which is taken from one of the sample MIDlets included in the J2ME Client Library, the cleanup code is collected in the exitMIDlet method.

Example 12-7 Cleanup code in the exitMIDlet method

  private void exitMIDlet()
  {
    try {
      ServiceManager.getInstance().close();
    }
    catch (Exception e) {
    }
 
    notifyDestroyed();
  }
    
 
  protected void destroyApp(boolean unconditional)
     throws MIDletStateChangeException
  {
     exitMIDlet();
  }
 
 
  public void commandAction(Command c, Displayable d)
  {
     if (c == exitCommand) {
  exitMIDlet();
 }
             . . . 
 }
12.1.4.5.5 Supported Data Types

Currently, the J2ME Web Services Client Library and Proxy Server support the following data types for Web service operation parameters and return values:

  • String

  • Integer

  • Boolean

  • Date

  • int

  • boolean

  • Vector

  • Hashtable

  • Arrays of String, Integer, Boolean, and Date

For every registered Web service, only those operations that use these data types can be registered with the J2ME Proxy Server and invoked using the J2ME Client Library.


Note:

J2ME does not support the data types: float or double. As a workaround, the J2ME Proxy Server converts float and double to String. This workaround applies only to the data type of the return value of Web service operations, not to operation parameters. This enables you to call Web service operations that return prices, temperatures, and other decimal values.

The mapping of WSDL simple data types (which are XML Schema data types) to Java data types are listed in Table 12-1.

Table 12-1 WSDL Data Types Mapping

WSDL data type Java data type

boolean

Java.lang.Boolean

integer

Java.lang.Integer

string

Java.lang.String

dateTime

Java.util.Date


12.1.4.6 Deploying MIDLets to OracleAS Wireless

When you have finished developing and testing your Web service-enabled J2ME MIDlets using the Wireless Development Kit, you can deploy them on a real OracleAS Wireless installation. You can do this by either one of the following two methods.

12.1.4.6.1 Deploying through Re-registration

You may migrate your work by re-registering your Web services with the OracleAS Wireless J2ME Proxy Server. The Service Manager, one of the OracleAS Wireless tools, enables you to register Web services and generate J2ME stubs for them.

To deploy a service through re-registration:

  1. Register every Web service that your MIDlets access.

  2. Generate new J2ME stubs for the Web services that your MIDlets call.

  3. Recompile your MIDlets with the new J2ME stubs.

If you made any manual modifications to the generated stubs, then you must manually modify the J2ME stubs that you already have as an alternative to Step 2. To do this, you must change the value of the _proxyUrl instance variable. Update this URL with the correct hostname of the OracleAS Wireless server, the correct port number for OracleAS Wireless (typically 7777), and the correct path (typically: /mcs/wsproxy/proxy). For example:

private String _proxyUrl= "http://example.com:7777/mcs/wsproxy/proxy"; 

12.1.4.7 Deploying through scripts

You can avoid reregistering every Web service that your MIDlets access by using the migration scripts. The process consists of downloading, or exporting, all information on the registered Web services to an XML file, and then uploading, or importing, this information from the XML file to a OracleAS Wireless installation.

  1. Export the Web services registered with the WDK J2ME Proxy Server to an XML file using the following script:

    migrateStandalone

    This script is used to extract Web services registered with the WDK J2ME Proxy Server into an XML file. This script is located with the other WDK J2ME Proxy Server scripts for registration and management of Web services, at ORACLE_HOME/wireless/wdk/bin.

    Usage:

    j2mesdkmgr -export <xml file name>

    Examples:

    For Windows:

    j2mesdkmgr -export C:\temp\registered_services.xml

    For UNIX:

    j2mesdkmgr.sh -export /usr/tmp/registered_services.xml

  2. Import the XML file to a OracleAS Wireless installation, using the following script:

    uploadJ2MEProxy

    This script takes a single parameter: the name or full path to an XML file produced by the j2mesdkmgr -export script. All of the Web services described in this XML file are inserted into the database of this OracleAS Wireless and become registered with the J2ME Proxy Server of this OracleAS Wireless installation. This script is located in the directory ORACLE_HOME/wireless/bin/.

    Usage:

    uploadJ2MEProxy <xml file name>

    Examples:

    For Windows:

    uploadJ2MEProxy.bat c:\temp\registered_services.xml

    For UNIX:

    uploadJ2MEProxy.sh /usr/tmp/registered_services.xml

  3. Generate new J2ME stubs for the Web services that your MIDlets call.

    You can skip this step by manually modifying the J2ME stubs that you already have (Do this if you made any manual modifications to the generated stubs.). You must change the value of the _proxyUrl instance variable to the correct hostname of the OracleAS Wireless server, the correct port number (typically 7777), and the correct path: /mcs/wsproxy/proxy. For example:

    private String _proxyUrl= "http://example.com:7777/mcs/wsproxy/proxy"; 
    
    
  4. Recompile your MIDlets with the new or corrected J2ME stubs.

12.1.4.8 Migration from One OracleAS Wireless Installation to Another

At some point, you may want to migrate all of the information on Web services registered with the J2ME Proxy Server from one OracleAS Wireless installation to another. The process consists of downloading, or exporting, all information on the registered Web services of the source OracleAS Wireless to an XML file, and then uploading, or importing, this information from the XML file to the destination OracleAS Wireless. The scripts to do this are found in the following directory:

ORACLE_HOME/wireless/bin/

To migrate the information on Web services registered with the J2ME Proxy Server from on OracleAS Wireless installation to another:

  1. Export the Web services registered with the source OracleAS Wireless J2ME Proxy Server to an XML file, using the following script:

    downloadJ2MEProxy

    This script takes a single parameter: the name or full path to an XML file. All Web services registered with the J2ME Proxy Server on the OracleAS Wireless where this script is run are extracted from the OracleAS Wireless database and placed into this XML file.

    Usage:

    downloadJ2MEProxy <xml file name>
    
    

    Examples:

    For Windows:

    downloadJ2MEProxy.bat c:\temp\registered_services.xml

    For UNIX:

    downloadJ2MEProxy.sh /usr/tmp/registered_services.xml

  2. Import the XML file to the destination OracleAS Wireless J2ME Proxy Server, using the following script:

    uploadJ2MEProxy

    This script takes a single parameter: the name or full path to an XML file produced by the downloadJ2MEProxy script. All of the Web services described in this XML file are inserted into the database of the OracleAS Wireless where this script is run and become registered with the J2ME Proxy Server of this OracleAS Wireless installation.

    Usage:

    uploadJ2MEProxy <xml file name>

    Examples:

    For Windows:

    uploadJ2MEProxy.bat c:\temp\registered_services.xml

    For UNIX:

    uploadJ2MEProxy.sh /usr/tmp/registered_services.xml

  3. Generate new J2ME stubs for the Web services that your MIDlets call.

    You can skip this step by manually modifying the J2ME stubs that you already have (Do this if you made any manual modifications to the generated stubs.). Change the value of the _proxyUrl instance variable. Update this URL with the correct hostname of the OracleAS Wireless server, the correct port number (typically 7777), and the correct path (/mcs/wsproxy/proxy). For example: private String _proxyUrl= "http://example.com:7777/mcs/wsproxy/proxy";

  4. Recompile your MIDlets with the new (or corrected) J2ME stubs.

12.2 Digital Rights Management Support

Digital Rights Management (DRM) enables the Content Manager to define the content usage policy after the content has been downloaded to the device. The usage policy defines the allowed permission associated with the content to the end user with additional temporal and monetary constraints if necessary. The common types of permission include:

There are many standards on expressing the digital rights. The one proposed by Open Mobile Alliance (OMA) for mobile content is a simplified version of the Open Digital Rights Language (ODRL) which means that digital rights should be expressed in an XML document following the syntax defined as ODRL Mobile Profile.

12.2.1 OracleAS Wireless Built-in DRM Polices

OracleAS Wireless includes two types of DRM policies that can be used to package J2ME applications: Count DRM Policy and Interval DRM Policy.

  • Count DRM Policy: restricts the downloaded J2ME application to be run on the device up to x times, where x is the count specified by the Foundation Developer specifies while creating the policy.

  • Interval DRM Policy: restricts the downloaded J2ME application to be run on the device for a specified period after it has been downloaded. The duration is specified in years, months, days, hours or minutes (or all of these). A standard conversion is used to handle years (365 days) and months (30 days).

The policy creation and the association of the policy with content is similar in both cases. The actual packaging of the policy with the content occurs at download time. The policy is enforced on the downloaded content after the user launches the downloaded application on the device. The Foundation Manager, one OracleAS Wireless Tools enables you to create built-in DRM policies Another Tool, the Content Manager, enables you to associate those policies with the J2ME application. See Oracle Application Server Wireless Administrator's Guide for more information on the Content Manager.

12.2.2 Custom-Built Digital Rights Policy and Content Enhancement

OracleAS Wireless provides a platform to facilitate customized Digital Rights Policy and Content Enhancement for J2ME devices (OracleAS Wireless supports MIDP 1.0 complaint devices). Although Customized Digital Rights Policy and Content Enhancement are two completely different features, they are implemented using one framework in OracleAS Wireless.

The custom implementation of Digital Rights Policy or Content Enhancement is a two-step development process.

  1. Implementation of Custom Digital Rights for MIDP platform by extending oracle.wireless.me.drm.DRMAgent class for MIDP platform. This implementation is also referred to as a Digital Rights Object.

  2. Implementation of oracle.wireless.me.server.tools.drm.DRMPackager interface, which implements the packaging logic of content with the Rights object developed in Step 1.

12.2.2.1 Use Case Study

The following sections describe an example of PoweredByPolicy, where a splash screen is packaged with the associated applications.

Example 12-8 PoweredByPolicy.Java for Target Mobile Information Devices

package devguide;
 
import Java.io.IOException;
import Javax.microedition.midlet.*;
import Javax.microedition.lcdui.*;
import oracle.wireless.me.drm.DRMAgent;
 
/**
* <code>PoweredByPolicy</code> displays a "Powered By" splash 
* screen for a packaged content. The product copyright string may 
* be set using a property parameter using OracleAS Wireless Server.
*/ 
public class PoweredByPolicy extends DRMAgent implements CommandListener {
 
/**
* value of copyright
*/
private String copyright;
 
public PoweredByPolicy(MIDlet ctx) {
super(ctx);
copyright = getProperty("copyright");
}
 
/**
* Displays a splash screen when the application starts up.
*/
public void onStartApp() {
showSplash();
}
 
/**
* Creates a splash screen and sets it be the current display
*/
private void showSplash() {
Form form = new Form("Powered By:");
try {
form.append(Image.createImage("/devguide/9i.png"));
}
catch(IOException ioe){
form.append("Oracle AS Wireless");
}
form.append(copyright);
form.addCommand( new Command("OK", Command.SCREEN, 1));
form.setCommandListener(this);
Display.getDisplay(context).setCurrent(form);
}
 
/**
* Resume the normal application logic when user 
* attends to the splash screen
*/
public void commandAction(Command c, Displayable d) {
resumeStartApp();
}
} // end of class PoweredByPolicy 

The PoweredByPolicy class defines an implementation of oracle.wireless.me.drm.DRMAgent (referred to as DRMAgent hereafter). It defines a constructor with a single argument of type Javax.microedition.midlet.MIDlet to satisfy the general contract of DRMAgent, The implementation of onStartApp() method displays a splash screen by calling the showSplash() method that houses the business logic of the policy. Finally, the event handler of splash screen calls resumeStartApp() for the packaged application to resume normally.

You can use the Sun J2ME Wireless Toolkit to compile and pre-verify the PoweredByPolicy class. The required lib containing DRMAgent class can be obtained from <IASW_HOME>/wireless/lib/j2medrm_demo.jar. The compiled and pre-verified class file or JAR file (which must also be pre-verified) containing the class file can be packaged by defining a packager as explained in Section 12.2.2.1.1.

12.2.2.1.1 Packaging Custom-built Digital Rights Policy

oracle.wireless.me.server.tools.drm.DRMPackager interface (referred to hereafter as DRMPackager) defines API for packaging a MIDlet suite content with Digital Rights Policy or Content Enhancement developed in Section 12.2.2.1. The DRMPackager.getInitPropertiesDef() method defines a contract to return a set of Properties used by tools such as user interfaces and publishing frameworks for discovering the parameter definitions of the Digital Rights Object. In turn, the OracleAS Wireless Runtime calls the init(Properties prop) method with the value of the parameters. DRMPackager defines the following API contract, which is invoked by OracleAS Wireless Runtime for packaging MIDlet Suite content with the Digital Rights object.

public byte[] packageDRMContent(byte[] content, Properties policyProperties, Document odrlXml,UserDevice device)

To simplify the implementation of DRMPackager, oracle.wireless.me.server.tools.drm.J2MEDRMPackager (referred to hereafter as J2MEDRMPackager) defines the default implementation to specify the Digital Rights object and contain the JAR file using the setDRMAgentInfo(String agentClassName, String implJarFileName) method. The implJarFileName can be the absolute path of the file containing the Rights Objects. If not, the J2MEDRMPackager performs a search for the specified JAR file in the CLASSPATH.

No customization is required for Rights object specified using ODRL.

The following class (Example 12-9) describes the packaging logic of the Rights object. The implementation assumes that JAR file containing the Rights object is archived in the C:\temp\poweredby.jar file. You do not have to restart the OracleAS Wireless server for changes made to the file containing the Digital Rights Object (C:\temp\poweredby.jar).

Example 12-9 Packaging logic of the Rights object

package devguide;
 
import oracle.wireless.me.server.tools.drm.J2MEDRMPackager;
import oracle.wireless.me.server.tools.drm.DRMPackager;
import Java.util.Properties;
 
/**
 * Powered By Rights Packager
 */
public final class PoweredByPolicyPackager extends J2MEDRMPackager {
  private static Properties defaultInitProperties = null;
 
  static {
    defaultInitProperties = new Properties();
    // initializes the copyright property with a default value
    defaultInitProperties.setProperty("copyright", "Copyright 2003 Oracle Corporation. All Rights Reserved.");
  }
 
  private Properties initProperties = null;
 
  private static PoweredByPolicyPackager instance = new PoweredByPolicyPackager();
 
  /**
   * Static factory that returns the instance of DRMPackager
   */
  public static DRMPackager getInstance() {
    return instance;
  }
 
  private PoweredByPolicyPackager() {
    initProperties = defaultInitProperties;
    setDRMAgentInfo("devguide.PoweredByPolicy", "C:\\temp\\poweredby.jar");
  }
 
  public Properties getInitPropertiesDef() {
    return defaultInitProperties;
  }
}// end of the class

Note:

This class implements the general contract of DRMPackager by implementing the following method.

  public static DRMPackager getInstance() {
    return instance;
  }

12.2.3 Deployment of Custom-Built Digital Rights Policies

Before you deploy the custom-built Digital Rights Policy, you must create a new Digital Rights Policy using the Foundation Developer, one of the OracleAS Wireless Tools. For more information on Foundation Developer, see Oracle Application Server Wireless Administrator's Guide .


Note:

To use the Foundation Developer, you must be granted the Foundation Manager role or the Super User role.

To create a new Digital Rights Policy:

  1. From the browsing page (Figure 12-1), click Create. The Select Digital Rights Policy Type screen appears (Figure 12-2).

    Figure 12-1 The Browsing Page for DRM Policies

    Description of Figure 12-1  follows
    Description of "Figure 12-1 The Browsing Page for DRM Policies"

  2. Select the Customized Package option.

  3. Enter the name of the package. You can also define the initialization (init) parameters and the ODRL document if the policy is supported by DRMPackager implementation. See Figure 12-3, "Creating a New Digital Rights Policy".

    Figure 12-2 Create a New Digital Rights Policy

    Description of Figure 12-2  follows
    Description of "Figure 12-2 Create a New Digital Rights Policy"

  4. Click Create. The New Digital Rights Policy screen appears (Figure 12-3).

  5. Enter the Name of the policy.

  6. Click Create.

Figure 12-3 Creating a New Digital Rights Policy

Description of Figure 12-3  follows
Description of "Figure 12-3 Creating a New Digital Rights Policy"

Once the Digital Rights Object is created, you can associate it with an application link of a MIDlet application. You use the Service Manager to create a J2ME MIDlet application and then the Content Manager to create an application link to that MIDlet, which is a means to customize a application and publish it to a user group. For more information on creating a MIDlet application, see Section 4.3.6, "Creating a J2ME Application". For more information on creating an application link, see Oracle Application Server Wireless Administrator’s Guide.

Figure 12-4 Associating a Digital Rights Policy with a J2ME Application

Description of Figure 12-4  follows
Description of "Figure 12-4 Associating a Digital Rights Policy with a J2ME Application"

12.3 The J2ME Provisioning Server

Using OracleAS Wireless J2ME Provisioning Server, Service Developers can upload, organize, and download J2ME applications. The uploaded J2ME application can then be published as an application using the Content Manager to users groups for downloading. The published service is available in the wireless user's application tree along with the other applications distributed to that user.

12.3.1 The Application Model

The OracleAS Wireless J2ME Provisioning Framework's Repository consists of the Content Repository and the framework which provide a means to create an association between the uploaded Digital Rights Management Policies (DRM) and the content. The association of the content with a DRM policy is done at the service creation time. All Content download transactions are recorded in an audit table.

The content repository stores the deliverable contents information for any uploaded content. The information is accessible through public APIs. Table 12-2 describes this information.

Table 12-2 Deliverable Content

Information Description

Name

The name of the content.

Version

The version of the content.

Display Name

The display name of the content

Description

A description of the content.

Verify time

The time when content was pre-verified using the Api-Scan feature.

Status

Indicates if the content is valid.

Owner

The owner of the content.


The Deliverable Content contains the meta-information of the actual content, which is available as a DeliverableContentItem object (described in Table 12-3).

Table 12-3 DeliverableContentItem

Information Description

MIME Type

The MIME Type of the content (JAR or JAD MIME content).

Content Binary

The actual content stored in binary format.

Content Size

The size of the content.

Audit Information

The audit information (such as creation time, update time, and user information).


The provisioning transactions are logged in an audit table, the PROVISIONING_TRANSACTION_LOG (described in Table 12-4). These transactions are exposed as runtime metrics in the System Manager.

Table 12-4 PROVISIONING_TRANSACTION_LOG

Column Name Column Type Description

INSTANCE_NAME

VARCHAR2 (256) (NOT NULL)

The Instance name of the Provisioning server which served this content

HOST_NAME

VARCHAR2 (256)

The host name of the server

USER_DOWNLOAD_ID

NUMBER

Internal unique id of this download transaction

USER_NAME

VARCHAR2(2000)

The name of the user who was provisioned with this content

SERVICE_NAME

VARCHAR2 (256)

The service used to access the content

APPLICATION_NAME

VARCHAR2 (256) (NOT NULL)

The application encapsulating this content

APPLICATION_TYPE

VARCHAR2 (256)

The application type. For example: J2ME

CONTENT_NAME

VARCHAR2 (256) (NOT NULL)

The name of the content. The content name and version uniquely identifies content.

CONTENT_VERSION

VARCHAR2 (100) (NOT NULL)

The version of the content. The content name and version uniquely identifies content.

MIME_TYPE

VARCHAR2 (256) (NOT NULL)

The MIME type of the content.

DRM_POLICY_NAME

VARCHAR2 (256)

The DRM policy (if any) associated with this service used to download the content.

NUMBER_OF_DOWNLOADS

NUMBER

The total number of downloads of this content by the user

DEVICE_ID

NUMBER

The downloading device information

DOWNLOAD_TIME_STAMP

DATE

The time stamp of the download operation

DOWNLOAD_INTERNAL_STATUS

VARCHAR2 (256)

The internal status code to indicate if the download was successful or if it failed.

DOWNLOAD_DISPLAY_STATUS

VARCHAR2 (256)

The descriptive status code to indicate if the download was successful or if it failed.


12.3.2 Uploading Hooks

The framework enables the download operation to be tracked and controlled by allowing the implementer to plug in hooks at different stages. A custom implementation of the hooks can be plugged using the System Manager. The hooks need to be singleton classes and must contain the getInstance() method to return their object reference.

  • Pre download Hook: This is invoked at the time of application invocation before the actual download happens. The hook interface is supplied to the user download status object containing the user information and content information. The hook can return a true or false status to allow the user to proceed with the download or abort the operation respectively.

    The ProvisioningPreDownloadHook interface is defined in the public package oracle.panama.rt.hook as follows:

public interface ProvisioningPreDownloadHook {
    /** Delegate additional processing of this download
     * @param UserDownloadStatus The download status object encapsulates the current download transaction i.e. user, application, content, version, mime type etc.
     * @return boolean to indicate successful hook processing
     * @see oracle.panama.model.UserDownloadStatus
     */
     public boolean processRequest (
              UserDownloadStatus uds
              );


}

  • Post download Hook: This hook is invoked at two stages during the post download cycle: after a successful download and after a device notification of a successful download.

    The hook supplies the user download status object, which contains the user information and the content information. The hook implementation can decide to bill or audit the download operation at either of the stages.

    The ProvisioningPostDownloadHook interface is defined in the public package oracle.panama.rt.hook (see ).

    Example 12-10 ProvisioningPostDownloadHook interface

    public interface ProvisioningPostDownloadHook {
        public static final int POST_DOWNLOAD = 1;
        public static final int POST_NOTIFY = 2;
             public boolean processRequest (
                   UserDownloadStatus uds, 
                   HttpServletRequest request,
                   int hookType /* determines if it is a post notify or a    post download hook */
                  );
    }
    

12.3.3 Uploading J2ME Applications

You use the Service Manager to create a J2ME application. To access this tool, you must be granted either the Service Manager or Super User roles.

To create a J2ME MIDlet application:

  1. From the browsing screen, click Create Application.

  2. From the application type selection screen, select J2ME Midlet as the application type.

  3. Enter a name for the MIDlet application. For example, enter Morphing (as depicted in Figure 12-5).

    The URL parameter points to the Download Service manager JSP that is included. You can also enter a custom JSP that provides the similar functionality.

    Figure 12-5 Entering the Basic Information for the MIDlet Application

    Description of Figure 12-5  follows
    Description of "Figure 12-5 Entering the Basic Information for the MIDlet Application"

  4. Click Next to enter the details of the J2ME Content (Figure 12-6).

    Figure 12-6 Entering the Content Details

    Description of Figure 12-6  follows
    Description of "Figure 12-6 Entering the Content Details"

  5. Enter the version number, display name, and description for the application.

  6. Upload the JAD and JAR file for the J2ME MIDlet application.

  7. Click Next. The Device Requirement page appears (Figure 12-7).

    Figure 12-7 Selecting the Devices that Support the J2ME Application

    Description of Figure 12-7  follows
    Description of "Figure 12-7 Selecting the Devices that Support the J2ME Application"

  8. If needed, exclude the devices which cannot support the application.

  9. Optionally, set the heap size requirement for the device.

  10. Click Next. The Additional Information screen appears (Figure 12-8).

  11. Select the Valid option.

  12. Provide any additional information for the application, such as the file location for a display menu icon.

  13. Click Finish to complete the J2ME MIDlet application.

Figure 12-8 Entering Additional Information for the J2ME Application

Description of Figure 12-8  follows
Description of "Figure 12-8 Entering Additional Information for the J2ME Application"

12.3.4 Publishing J2ME Applications

The Content Manager enables you to publish the J2ME application to user groups. The application created using the Service Manager is published as an application link, which you create using the Content Manager. The Service Designer-created application, or master application, forms the core of the application link. Using the application link, you can customize the application. For example, you can customize the application to a user group or to a location. For more information, see Oracle Application Server Wireless Administrator's Guide.

To publish the J2ME application:

  1. From the browsing screen of the Content Manager, click Add Application Link.

  2. Select the application targeted for publishing. For example, select Morphing Application.

  3. Click Next.

  4. Enter a name for the application link.

  5. If needed, select a DRM policy. By default, the user is allowed unrestricted usage of the downloaded application. For more information, see Section 12.2.2, "Custom-Built Digital Rights Policy and Content Enhancement".

  6. You can click Finish to complete the application link by accepting the defaults. If needed, enter information in the Additional Information screen, such as a a non-zero value for cost information for billing purposes. Select the Visible option and any other information as appropriate.

12.3.5 Downloading J2ME Applications

For the J2ME to be accessed (that is used) you must assign the application to a user group. Only users belonging to group to which you assign the J2ME application can use the application. In addition, group members must have at least one device address.

To access the application, users must log in to the Wireless and Voice portal using a URL similar to the following:

http://yourwirelessserver:7777/ptg/rm

Figure 12-9 Morphing Service Example

Description of Figure 12-9  follows
Description of "Figure 12-9 Morphing Service Example"

When you choose the Morphing application (as depicted in Figure 12-9), the JSP displays a list all the J2ME contents uploaded for that application. Download the selected content to the device by clicking Download.

In the Customization Portal, you can view the download history log in to by clicking Applications and then View Download History.