[TIP] Sample MIDlet for Mobile Client to WS

NetBeans Mobility Pack provides you a wizard for creating of stubs to connect to a webservice from mobile client. The stubs are generated according the J2ME Web Services Specification - JSR 172. Therefore the client will run only on devices with support for JSR172.



In previous versions of the IDE - 5.0, 5.5, 5.5.1 - the wizard generated even a sample MIDlet that provided a basic usage of the stub. It just took the parameters and showed the return values from the web service. There was lot of restrictions and problems with the sample MIDlet. Therefore the development team decided to drop the feature in NetBeans Mobility 6.0.

The usage of the generated stubs is really easy. IMO, the sample MIDlet might be nice for demo purposes however for the real work it's easier to create the MIDlet from scratch. I'll try to briefly show how to use the generated stubs in visual MIDlet. The sample mobile application is attach. I attached also the web project with the web service.

When you want to use the Java ME Web Service Client wizard you need to have the NetBeans Mobility IDE installed. The wizard isn't part of the standard mobility distribution however you can get it from update center. Look at my post "Where is the End2End functionality of Mobility Pack".
The Java ME Web Service Client wizard generates the stubs for you. You just have to point it to the WSDL file of the web service. You can either provide URL or browse for a wsdl on your hard drive. The wizrd parses and validates the WSDL file. When the web service is WS-I compliant and follows up the JSR 172 restrictions you are able to generate the stubs into a mobile project in the IDE.

When you have the stubs then you just use then in your application. It's very easy. In my case there is only one method public String sayHello(final String name) provided by the web service class HelloWS. The generated stubs class HelloWSService_Stub provides method public String sayHello(String name). Therefore the usage in your mobile application could be
HelloWSService stub = new HelloWSService_Stub(); //create the stub
String result = stub.sayHello("Lukas"); //call the WS method
Look at the attached mobile project how to build up visual MIDlet with Mobile Visual Designer of Mobility Pack. It show the usage of the WaitScreen, Task, and other components provided by the NetBeans Mobility IDE 6.0.
Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

This is the main channel to share news, tips and other stuff related to my work. Sometimes you can find even personal stuff. Enjoy your reading...

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
news
Blogroll

No bookmarks in folder

OldNews
MyTrash
NavBar
NetBeans
LinksToBeExpanded