SolutionsTools & SDKSupport  



Quick Links
 
May 2002
 
 
Jack's Hack for the month of May, 2002:

Migrating WAP Push Applications to Use the SimplePush Class

The recently released version of the Openwave Wap Push Library contains a new class for pushing content called SimplePush. This month we will look at how to migrate applications built on the plPop* classes to the SimplePush class.

Back in February 2002, we took a look at how to use the beta version of the Openave WAP Push Libarary to devlier push messages to subscribers from a database. If you have not previously viewed this note, please take a moment to view it and download the code from here.

Now that the Openwave WAP Push Library has been finally released the methods to deliver a push have changed. The pl* methods from the beta version have all been depricated, and replaced with a SimplePush class. All of the other code from the "Sample Servlet Application" can be used going forward unchanged, except for the plSubmitMsg() method. The plSumbitMsg() method can be simplified to become the following:

 public void plSubmitMsg()throws WapPushException, IOException, MalformedURLException {
   
    //declare ppg url, recipient address, push message ID and SI url
    ppgAddress = "http://" + host + ":9002/pap";
    address = subno + "/TYPE=USER@ppg.openwave.com";
    pushID = Integer.toString((int) (Math.random()* 1000000000));
    ppgURL = new URL (ppgAddress);
    siURI = new URL (SvcIndURI);
    String alertText = title+ "Alert"; //this is the text string sent to the device
    
    //instantiate the push message object. The "SampleApp" argument is the name of our
    //application 
    SimplePush sp = new SimplePush(ppgURL, "SampleApp", pushID);
    
    // Set the Quality of Service to high and confirm always
    sp.setQualityOfService(DeliveryPriority.high, DeliveryMethod.confirmed, null, false, null, false)

    //send the push message to the PPG
    PushResponse pushResponse = sp.pushServiceIndication(new String [] {address},
                            alertTitle, siURI.toString(), ServiceIndicationAction.signalHigh);
    
   //read some information from the Response
    System.out.println("reply_Time = "+pushResponse.getReplyTime());
    System.out.println("response-result-code =" + pushResponse.getResultCode());
    System.out.println("response-result-desc ="+ pushResponse.getResultDescription());
}

In addition to changing the method to as describe above, we also need to modify the import statement to reflect the new library name. Change from com.openwave.wappushlib.* to
com.openwave.wappush.*

Also, in the declarations at the begining of the sendPush class, the declaration of
plServiceIndicationAction signalHigh;
can be removed

If we take a closer look at what these modification mean, we can see the following:

  • The execption we are thowing has changed from plPopException to WapPushException
  • The PPG object does not need to be instantiated on its own, instead it becomes an argument to the instantiation of the SimplePush object
  • The ServiceIndication object is not instantiated on its own, but is instead called as a method of the SimplePush class
  • A QuailtyOfService object does not need to be created, instead the setQualityOfService method is called on the SimplePush object, directly with the arguments to set the Quality of Service
  • To send the push, a call is made directly to the sendServiceIndication method of the SimplePush class, with an array of addresses, a title, a URI (formatted as a string), and a priority.
Be sure to download the latest version of the WapPushLibrary from here so you can develop WAP Push applications with the current version of the library.

 
Copyright © 2000-2008 Openwave Systems Inc.    Openwave  |  Terms & Conditions  |  Privacy Policy