Difference between Mobile client To Web Application and J2ME Web Services Client

Difference between these two clients is simple - the JSR 172.



The picture shows how the client communicates with webservice. When you have a device with Webservices API (JSR172) support then it's easy. When the device is without the Webservices API then you have to solve it in different way. You can create a middle tear that you'll communicate with a binary protocol. The middle tear can then connect to the webservice.

There are wizard for both cases in NetBeans Mobility Pack. You can find then in New File dialog in MIDP category.
The J2ME Web Services Client wizard generates the client stubs from provided WSDL file. The Mobile client To Web Application wizard generates both parts necessary for communication - client and server part. You can generate client comunnicating either with a class/servlet or with webservice client on the server. Both wizards generate Sample midlet for you. So you can easily understand and check how to work with the technology. Sometimes it's enought to accomodate the Sample midlet for your purposes.

Comments:

What an excellent demo, Lukas! It would have been very tedious to show all of this functionality while only using text, so I appreciate the effort that went into this.

Posted by Michel on June 16, 2006 at 04:11 PM CEST #

Thanks for this demo!

Posted by Yogev Triki on June 22, 2006 at 02:34 AM CEST #

hi brothers and sisters my name is benjamin dumenyo i will fill good if you dutch me something

Posted by benjamin dumenyo on July 01, 2006 at 02:27 PM CEST #

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head> <body> hi Lucas, I got some proble by using j2me client invoke a web service. few days ago, I used WTK2.2 to implemented my j2me web service client and generated the stub code by using bundled stub generator. when I tried the application I got the following exception: javax.xml.rpc.JAXRPCException: java.rmi.MarshalException: (1)Missing end tag for Body or Envelope at com.sun.j2mews.xml.rpc.SOAPDecoder.decode(SOAPDecoder.java:175) at com.sun.j2mews.xml.rpc.OperationImpl.invoke(OperationImpl.java:243) I traced the problem, the exception was thrown here: public int add(int int_1, int int_2) throws java.rmi.RemoteException { // Copy the incoming values into an Object array if needed. Object[] inputObject = new Object[2]; inputObject[0] = new java.lang.Integer(int_1); inputObject[1] = new java.lang.Integer(int_2); Operation op = Operation.newInstance(_qname_add, _type_add, _type_addResponse); _prepOperation(op); op.setProperty(Operation.SOAPACTION_URI_PROPERTY, ""); Object resultObj; try { //exception was thorwn here resultObj = op.invoke(inputObject); } catch (JAXRPCException e) { e.printStackTrace(); Throwable cause = e.getLinkedCause(); if (cause instanceof java.rmi.RemoteException) { cause.printStackTrace(); throw (java.rmi.RemoteException) cause; } throw e; } int result; // Convert the result into the right Java type. // Unwrapped return value Object resultObj2 = ((Object[])resultObj)[0]; result = ((java.lang.Integer)resultObj2).intValue(); return result; } it seems the client can't decode the received soap package which was like this (I used the network monitor to get it): <env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'> <env:Header/> <env:Body> <ns1:addResponse xmlns:ns1='http://server.reg.src/jaws' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> <ns1:result>10</ns1:result> </ns1:addResponse> </env:Body> </env:Envelope> the request package is like this: <?xml version="1.0" encoding="utf-8"?>. <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"..xmlns:xsd="http://www.w3.org/2001/XMLSchema"..xmlns :soap="http://schemas.xmlsoap.org/soap/envelope/"..xmlns:tns="http://server.reg.src/jaws">. <soap:Body>. <tns:add>. <tns:int_1>4</tns:int_1>. <tns:int_2>6</tns:int_2>. </tns:add>. </soap:Body>. </soap:Envelope>. (by the way, my webservice is a ejb3 endpoint (jsr181)depoyed in jboss server) being stuck here for a few days, I happend to see your blog, I then I tried the netbean mobility pack, followed your instruction in the movie, but finally I got exactly the same problem. now I am wondering if there is somthing wrong with my web service, which could be invoked by j2se client. is a j2me client have some special requirment for the web service? I am desperate now... I do appreciate any suggestion.. Jason </body> </html>

Posted by Jason on August 08, 2006 at 09:41 AM CEST #

Jason, the webservice has to be WS-I compliant. But it isn't the problem in your case. I know this exception. It happend to me for a few webservices too. I reported bug to Wireless Toolkit team in February. Unfortunatelly, it's all I can do. It's up to stubs generator to handle it properly. I pasted your comment to the bug report(it's only internal). I'm sorry that I cannot help you. Maybe there is a workaround but I don't know about it now.

Posted by Lukas on August 08, 2006 at 10:15 AM CEST #

Hi lucas, I don't know why the message can't be well organized.. sorry about this.. Jason

Posted by Jason on August 08, 2006 at 10:36 AM CEST #

Jason, could you try to switch WTK to "trusted" mode? You can do it in Java Platform Manager | Tools & Extensions tab | Open Preferencies | Security tab | Security Domain = trusted

then it should work. I'll write a post explaining it in more details soon.

Posted by Lukas on August 11, 2006 at 09:14 AM CEST #

hi lucas, yes, I did try that (trust mode). while the problem is still there. actually I think the trust mode is for the air time billing issue as when I turn to trust mode there will be no warning of "the application wants to send and receive data using the network, this will use air time and may result in charge" when the webservice is invoked. Jason

Posted by jason on August 12, 2006 at 04:12 PM CEST #

I got good new for you, Jason. There was another bug in the WTK. The main reason why you received the exception was that there was "user-agent" property two times in the POST message.
They fixed in latest WTK2.5 builds. I don't know when they'll be available for public...

Posted by Lukas on August 17, 2006 at 09:39 AM CEST #

thanks a lot, I try it as soon as the official 2.5 build is available.. regards

Posted by Jason on August 24, 2006 at 04:59 AM CEST #

Hi Lucas, wonderful demo. I saw the problem with JEE5 so I made my web project JEE4, but I still can´t select the Web Service Client when make 3-Teer-Architecture. Netbeans tells me "Web Project must be build before genereting web service client" when I want to select the right Web Service Client. My Projekt is build and the web service is J5EE on Application Server 9 .I tried tousend times with NB50+MB50 , NB55+MB55 still the same result. What kind of web projekt do I need to get Mobile Client without JSR172? Sorry for the stupid Question, but I didn´t find anything useless on the web.

Posted by ilk on September 07, 2006 at 04:50 AM CEST #

Hi Ilk, that should work in the way that you described. It doesn't matter what kind of webservice (j2ee 5, j2ee 1.4) are you using. The webclient has to be jax-rpc (1.4) in j2ee 1.4 project.

Feel free to mail me directly with more details.

Posted by Lukas on September 09, 2006 at 01:35 PM CEST #

Hi Lukas. I am also trying to use the Mobile Client to Web Application for WS functionality but i always getting "Web project must be built before using Mobile Client to Web application for web services" when i try to specify the web service client of the web application. Any suggestions? Thanx in advance

Posted by kostis on December 09, 2006 at 05:48 PM CET #

Good day! We'd like to commend you for your wonderful flash demo. It helped us a lot to understand j2me web services. In fact, we are currently doing a thesis project that implements the same technology as what was shown in your demo. Could we ask for the sample project that was shown in your demo? It would really help us understand j2me web services. Hoping for your immediate response. Thank you. Celene Navarro, Dennis Paguio, Toni Trino

Posted by mobile telemed group on February 26, 2007 at 02:01 AM CET #

Sample projects.

For more details look at http://blogs.sun.com/lukas/entry/java_me_to_java_ee

Posted by Lukas on February 27, 2007 at 08:55 AM CET #

Good Day! we tried running the mobile client generated from the WSDL but it seems that the server does not work. We'd just like to make sure the server is up so we could proceed in studying your project. The alert "Communication Failed" kept on popping up the screen. Thanks so much!

Posted by mobile telemed group on March 05, 2007 at 12:58 AM CET #

There should be an exception in output when the communication fails. Can you see it?

Are you behind a proxy/firewall? If yes then you have to set up proxy of the Wireless toolkit (http://blogs.sun.com/lukas/entry/setting_proxy_server_for_wtk).

Posted by Lukas on March 05, 2007 at 02:58 AM CET #

we'd like to thank you again for answering the previous posts. because of this, we were able to solve the problems we've encountered by reading the posts by other people. Best Regards!

Posted by telemedicine group on March 05, 2007 at 08:31 AM CET #

We'd just like to ask about the settings needed for the defaultgrayphone configuration. When we change from the defaultconfiguration the recommented parts in the ifelse block do not automatically change according to the configuration as shown in the demo. Why is this so?

Posted by mobile telemedicine group on March 05, 2007 at 08:33 AM CET #

ok, I changed the other configuration to not include the JSR172 - J2ME Web Services API. I also removed JSR172 ability from list of the abilities of the configuration. In this way you can modify your platform and settings of a configuration.
The list of abilities is generated automatically from emulator platform settings when you are adding new platform to IDE. E.g. when you add a Siemens CX65 emulatotor (SDK) then the JSR172 will be missing. I'm using the default emulators of WTK therefore I had to configure the emulator platform by myself in project properties.

Posted by Lukas on March 05, 2007 at 09:19 AM CET #

I was wondering if the problem was ever resolved reported by benjamin July 1, 2006. I came across this one last month and reported it to sun but have not gotten a reply. I just tried the latest 2.5 and the problem still occurs. It is related to auto-generated code from wsdl and the error occurs on this line where an array of objects is being cast to an array of strings. This code works fine in 2.2 result = (java.lang.String[]) _returnObj;

Posted by Scooter Willis on May 29, 2007 at 11:31 AM CEST #

Hello Lukas, I am using NB 6 M9, and when trying to follow the DailyDilbert example from the NB homepage, I run into the problem that after creating the WS client, I can't invoke the Mobile Client to Web Application wizard. There is no file type for Mobile Client to Web Application under the MIDP category. Do you have any idea what might be wrong? Kind regards, Bernhard

Posted by Bernhard on June 05, 2007 at 06:32 AM CEST #

You are right, it's not available in M9. The functionality should be back in M10 (june 25).

There are filled issues to track the problem -
http://www.netbeans.org/issues/show_bug.cgi?id=89831
http://www.netbeans.org/issues/show_bug.cgi?id=92824

Posted by Lukas on June 05, 2007 at 09:58 AM CEST #

Hi Lukas, I'm from Argentina, so sorry for my english :-) I am using NB 5.5 with Mobility pack and Enterprise pack. I did the DailyDilbert example. And work fine on the simulator (WTK). Now I was wondering if there is a simple example of how to use the Mobile Client to Web Application wizard. because I have a motorola V3 (CLDC 1.0 MIDP 2.0) and it doesn't have the (JSR-172 API). is possible if you can send me the exampla that you did on the flash demo? thanks, bye. bruno.

Posted by bruno on June 05, 2007 at 05:19 PM CEST #

@bruno: I'm from Czech Republic, there is no need to be sorry about your English ;)
The DailyDilbert example doesn't use the JSR172. This example is focused on the Mobile Client to Web Application.

The source code used in the flash demo is available here. You can read more detailed description of the scenario in this post.

Posted by Lukas on June 06, 2007 at 01:44 AM CEST #

"Web project must be built before using Mobile Client to Web Application for Web Services"

Posted by guest on September 04, 2007 at 03:46 PM CEST #

Hi Lukas. Great demo. I used to use it non-stop until I installed NetBeans v6.0 beta 1 where the sample MIDlet and Stubs do not get generated (http://wiki.netbeans.info/wiki/view/MobilityNewAndNoteworthy). At the time I have v6.0b1 and v5.5.1 installed. The v6.0b1 installation also affected the MIDlet sample generation wizard in v5.5.1. Since then I have uninstalled both version and re-installed v.5.5.1 from scratch, but with no luck. How do I get this functionality back in v5.5.1. Please help. Thank you.

Posted by Francois on October 17, 2007 at 09:11 AM CEST #

hi Lukas, I'm bruno again, thanks for your response.
Now I have a questions for you. How can I try to use UDDI o something like that with the example?? I mean, I want to use a wsdl ( web service) that it can move or stay in diferent places. is it clear? :-)

Posted by bruno on October 18, 2007 at 03:53 PM CEST #

Hi, Its a great tutorial thanks for it, but please tell me if you have prove this in a real phone, and tell me which,I have a k550 sony ericsson, and it have the api jsr 172, but It does not work with the midlet, can you tell if I need configurate something in the server or the glassfish

Thanks

Posted by Julian on January 11, 2008 at 05:07 PM CET #

You need to be able to access the server site from internet. It means it cannot be at your localhost or behind firewall/proxy. If there is a real IP then it should be acessible from your phone application. HTH, Lukas

Posted by Lukas on January 14, 2008 at 06:20 AM CET #

Hi Lukas,
please I need help, I follow the Dilbert Viewer example for netbeans 6.0 and I found diferent with the dilbert example for netbeans 5.5
I need to known how can I set the URL of the web app in the mobile app in netbeans 6.0 example like in NB5.5 example??!
the dilbervisualMidlet is diferent! and I can´t add customs command to the main menu(list) "displayable item".
I need to build a mobile client which can set the URL of the web app where the web service exist...like dilbert example in 5.5!!
thank you.
bye
bruno.

Posted by bruno on March 18, 2008 at 05:39 PM CET #

Hi Lukas, do you have any link with the same information in spanish ? I'm constructing my personal webpage and I would like to contribute translating this info to spanish. any comments ?

Regards,

Posted by Antonio Valerio on August 28, 2008 at 03:14 PM CEST #

Hi Antonio, I'm sorry but I'm not aware about any similar informations in Spanish. AFAIK, Fabi (http://blogs.sun.com/fabi) blogged about Mobility in Spanish. Please, try to ask her if she knows more about the Spanish community.

Posted by Lukas on August 29, 2008 at 02:17 AM CEST #

Can JSR 280 be used as an XML API?

Posted by guest on May 26, 2009 at 01:01 AM CEST #

I need to know the difference between JSR 172 and JSR 280

Posted by Sarah on May 26, 2009 at 01:03 AM CEST #

HI, I follow the steps to generate stub etc, but there is nothing on the emulator when run the project. Dose anyone know why?

Posted by david feng on October 28, 2009 at 11:07 PM CET #

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