×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    12

    LWUIT IO (v1.5) ConnectionRequest's readResponse() Issue - Nokia SDK 2.0

    Hi,

    I have been porting an existing J2ME mobile app, that allows users to view archived news videos, to the latest Nokia SDK 2.0 platform for full-touch devices.

    We are using both the LWUIT and LWUIT4IO technologies for the UI and Network functionalities of the application respectively.

    The app has been formerly tested to work fine on the S40 5th Edition SDK platform. Extending LWUIT for IO's ConnectionRequest class and utilizing LWUIT's XMLParser, the app can successfully send a HTTP request and get the favorable response by a web service that basically returns an XML-formatted type of feed (containing necessary metadata for the video) (Here's the URL of the web service: http://nokiamusic.myxph.com/nokianew...spx?format=3gp

    But for some reason, this is not the case when trying to run the app on the latest Nokia SDK 2.0 platform. It throws a java.lang.NullPointerException upon trying to parse (XMLParser.parse()) the InputStream response of the web service. When I trace the Network Traffic Monitor of the emulator of the corresponding Request sent and Response received - 0 bytes were returned as content despite a successful response status 200. Apparently the XMLParser object has nothing to parse in the first place.

    Hoping that someone can somehow shed light on this issue or share any related resolutions, or help me further refine the problem.

    Thanks in advance

    P.S. Would be posting the code next

  2. #2
    Registered User
    Join Date
    Oct 2011
    Posts
    12

    Re: LWUIT IO (v1.5) ConnectionRequest's readResponse() Issue - Nokia SDK 2.0

    Here's the class that handles the parsing:

    Code:
    package userclasses.service;
    
    import com.sun.lwuit.io.ConnectionRequest;
    import com.sun.lwuit.io.NetworkEvent;
    import com.sun.lwuit.xml.Element;
    import com.sun.lwuit.xml.ParserCallback;
    import com.sun.lwuit.xml.XMLParser;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.util.Vector;
    import userclasses.model.Video;
    
    public class SegmentService extends ConnectionRequest implements ParserCallback {
    
        private Vector segments;
        private Video segment;
    
        public SegmentService(String backend) {
            String slash = backend.endsWith("/") ? "" : "/";
            setPost(false);
            setUrl(backend + slash + "nokianewsfeed.aspx");
            addArgument("format", "3gp");
        }
    
        public void setDateFilter(String date) {
            System.out.println(date);
            addArgument("date", date);
        }
    
        private Video getCurrent() {
            if (segment == null) {
                segment = new Video();
            }
            return segment;
        }
    
        protected void readResponse(InputStream input) throws IOException {
            System.out.println("[Checking if parameter <input> is null]: " + (input == null));
            System.out.println("[Estimate of the number of bytes that can be read]: " + input.available());
    
            InputStreamReader i = new InputStreamReader(input, "UTF-8"); 
            System.out.println("[InputStreamReader string]: " + i.toString() + "|Ready?: " + i.ready());
            
            XMLParser xmlparser = new XMLParser();                
            System.out.println("Parsing the xml...");
            Element element = xmlparser.parse(i);
            System.out.println("Root " + element.getTagName());
    
            int max = element.getNumChildren();
            System.out.println("Number of children: " + max);
    
            segments = new Vector();
    
            for (int c = 0; c < max; c++) {
                Element e = element.getChildAt(c);
                System.out.println("segment " + c);
    
                int len = e.getNumChildren();
                System.out.println("Number of children: " + len);
                
                for (int d=0; d<len; d++) {
                    Element s = e.getChildAt(d);
                    String property = s.getTagName();
                    System.out.println("key: " + property);
                    String value = (s.getNumChildren()>0) ? s.getChildAt(0).getText() : null;
                    System.out.println("value: " + value);
                    
                    if (property.equals("title")) {
                        getCurrent().setTitle(value);
                    } else if (property.equals("description")) {
                        getCurrent().setDescription(value);
                    } else if (property.equals("videourl")) {                 
                        getCurrent().setVideoUrl(value);
                    } else if (property.equals("thumburl")) {
                        getCurrent().setThumbUrl(value);
                    } else if (property.equals("adurl")) {
                        getCurrent().setAdUrl(value);
                    } else if (property.equals("publishdate")) {
                        getCurrent().setPublishDate(value);
                    } else if (property.equals("category")) {
                        getCurrent().setCategory(value);
                    } else if (property.equals("weburl")) {
                        getCurrent().setWebUrl(value);
                    } else if (property.equals("thumburl2")) {
                        getCurrent().setThumb210(value);
                    } else if (property.equals("thumburl4")) {
                        getCurrent().setThumb40(value);
                    }
                }
    
                if (segment != null) {
                    segments.addElement(segment);
                    segment = null;
                }
            }
            fireResponseListener(new NetworkEvent(this, segments));
        }
    
        public boolean parsingError(int errorId, String tag, String attribute, String value, String description) {
            System.out.println(errorId);
            System.out.println(tag);
            System.out.println(value);
            System.out.println(description);
            return true;
        }
    }

  3. #3
    Registered User
    Join Date
    Aug 2011
    Posts
    26

    Re: LWUIT IO (v1.5) ConnectionRequest's readResponse() Issue - Nokia SDK 2.0

    Quote Originally Posted by Interactive-lem1313 View Post
    But for some reason, this is not the case when trying to run the app on the latest Nokia SDK 2.0 platform. It throws a java.lang.NullPointerException upon trying to parse (XMLParser.parse()) the InputStream response of the web service. When I trace the Network Traffic Monitor of the emulator of the corresponding Request sent and Response received - 0 bytes were returned as content despite a successful response status 200. Apparently the XMLParser object has nothing to parse in the first place.
    Sounds like a problem with the web-server to me. It might not recognize the phone's user-agent.
    Maybe this helps: http://www.asp.net/mobile
    (found at http://www.developer.nokia.com/Commu...l=1#post882169)

  4. #4
    Registered User
    Join Date
    Oct 2011
    Posts
    12

    Re: LWUIT IO (v1.5) ConnectionRequest's readResponse() Issue - Nokia SDK 2.0

    Quote Originally Posted by UnPlan2ned View Post
    Sounds like a problem with the web-server to me. It might not recognize the phone's user-agent.
    Maybe this helps: http://www.asp.net/mobile
    (found at http://www.developer.nokia.com/Commu...l=1#post882169)
    Thank you sir Will take a look and will update you.

  5. #5
    Registered User
    Join Date
    Oct 2011
    Posts
    12

    Re: LWUIT IO (v1.5) ConnectionRequest's readResponse() Issue - Nokia SDK 2.0

    Hi Sir, - Checked out the site. But the Mobile Device Browser File is for "mobile-browser-proofing" your asp site, so that it will adapt depending on the mobile device browser you're using. My dilemma is really not on the browser level, but more on consuming a web service as an integral part of a Java mobile application that feeds news video streams. Apparently, the web service is not returning anything (xml response) upon a successful request operation.

    But, thank you still!

Similar Threads

  1. simple LWUIT issue...?
    By kumar1234567 in forum Mobile Java General
    Replies: 2
    Last Post: 2011-04-15, 14:00
  2. LWUIT Issue - refreshTheme gives NullPointerException
    By moltenice in forum Mobile Java General
    Replies: 2
    Last Post: 2011-02-21, 07:53
  3. Can any Resolve this issue, regarding LWUIT forms
    By rajan701v in forum Mobile Java General
    Replies: 1
    Last Post: 2010-12-20, 17:30
  4. Issue with LWUIT TableLayout..
    By lynxgeek in forum Mobile Java General
    Replies: 0
    Last Post: 2010-12-03, 07:05
  5. LWUIT Issue
    By giaviv in forum Mobile Java General
    Replies: 4
    Last Post: 2010-06-04, 16:53

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×