|
Function
Many developers want to access Web services from their MIDP client applications that
run on mobile phones. The current MIDP specification does not contain facilities for
using SOAP, although JSR 172 promises to provide this functionality soon.
Until then, the kSOAP
open source product has been a popular way to bridge the gap. In this sample, developers
learn how to integrate kSOAP with the J2ME Wireless Toolkit and run a sample application
that will prompt for a stock symbol and display the stock price.
Topics Covered
In this example, a MIDlet queries the user for a stock symbol and calls a Web service
to get that symbol's stock price. This sample shows the developer how to:
Requirements
This sample requires the following product:
Source Files
Instructions for downloading all the source code for the StockQuoteDemo appear below in the Instructions section.
The following code excerpt illustrates the logic that actually makes the SOAP call:
//Create a SoapObject by specifying the //URN and the method name of the SOAP //RPC web service. SoapObject rpc = new SoapObject (&urn:xmethods-delayed-quotes&, &getQuote&); //The addProperty method allows you to specify // parameters to for the method used. rpc.addProperty (&symbol&, symbol); //The HttpTransport class can be used to // make the actual call. It's constructor // accepts the Web service end point as // well as the method to be called. resultItem.setText (&&+new HttpTransport (&http://services.xmethods.net/soap&, &urn:xmethods-delayed-quotes#getQuote&).call (rpc)); Instructions
Follow these steps to run the StockQuoteDemo application:
See Also
Wireless Developer
(http://wireless.java.sun.com) J2ME Archives
(http://www.billday.com/j2me/) kSOAP Project
(http://kSOAP.org) | |||||||||
Oracle is reviewing the Sun product roadmap and will provide guidance to customers in accordance with Oracle's standard product communication policies. Any resulting features and timing of release of such features as determined by Oracle's review of roadmaps, are at the sole discretion of Oracle. All product roadmap information, whether communicated by Sun Microsystems or by Oracle, does not represent a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. It is intended for information purposes only, and may not be incorporated into any contract.
Oracle is reviewing the Sun product roadmap and will provide guidance to customers in accordance with Oracle's standard product communication policies. Any resulting features and timing of release of such features as determined by Oracle's review of roadmaps, are at the sole discretion of Oracle. All product roadmap information, whether communicated by Sun Microsystems or by Oracle, does not represent a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. It is intended for information purposes only, and may not be incorporated into any contract.
|
| ||||||||||||