Parse JSON result via j2me - web-services

I am creating a mobile application using j2me, which interacts with a webservice. The webservice responds with JSON data.
How do I parse it and get the individual values?

Sun has a technical article - Using JavaScript Object Notation (JSON) in Java ME for Data Interchange - which will be helpful for you.

Related

How to call REST API and parse XML Structure?

I am new to Android Programming.
I want to use a RESTful Webservice for my android app where I will be calling a REST API and in response I want to parse the XML Structure, consume the XML tag values and show it in UI.
Can anybody guide me with the required steps and some sample code.
Thanks in advance!
You should glance at Retrofit.
Retrofit helps you to hook up with a server in a very elegant way.
By default, Retrofit expects JSON data but you can set it up to use XML, via the Simple library.

How do i create a google places like API in Nodejs using express

I am trying to create a RESTful service in Node.js using express like the Google places API which should be in the following format.
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=%1,%2&radius=%3&name=%4&key=AIzaSyAh4t-qlMYrxnk0XF0Yiu9ZXVFDNfPTCFs
Its very unlike the standard way of passing params to an express app which expects in the following format /google/nearbysearch/place/:location=%1,%2/radius/:radius=%3 and etc..
The challenge here is how to use express and decrypt the response to easily parsing the params to a call. I did extensive research but could not find any links on google or stackOverflow. Thanks for the help.
I hear and have checked out restify (http://mcavage.me/node-restify/) where it allows to pass regex strings to the request url. How do they achieve such in Node.js (solutions without using express will also be helpful).
Thanks
Anurag
You can use Connect.js and Express.js middlware to parse the incoming query string and body conveniently. You can go to the official website http://expressjs.com or look at my examples http://expressjsguide.com and http://webapplog.com.
It's possible to parse without them, but you'll have to write more code (look at the core modules at http://nodejs.org/api).

Django gwt and rpc call

I'm using django, but I like to use it with gwt, well I've try using json with piston and works well, but I prefer using RPC call.
So I know that there's some rpc lib for django, but I'm confused about xml-rpc json-rpc gwt-rpc...
So the questions are:
1) where find a tutorial if exists...
2) or how can I do a simple rpc call in gwt and use django to server side
thanks, I'm asking here because I've find nothing in google thanks
Any particular reason you want to use RPC to Django instead of a web service from GWT application? I think using JSON communication between Django and GWT is much easier than RPC.
The main challenge in using RPC is that your Django and GWT client should communicate via a common protocol. On Django side you need a module that translates the GWT RPC calls to something Django understands and then convert the Django results into something GWT client application understands. In a nutshell RPC calls are serialized text stream sent over http via post method. On the server side you should be able to translate that into the right data structure by deserializing it. So you need a library that will do this serialization and deserialization for Django based on GWT-RPC protocol.
Useful links:
About GWT RPC:
Google documentation : RPC
GWT RPC in a nutshell
GWT + Django:
How to use Django with GWT?
Using GWT with Django using xml
Google Web Toolkit like application in Django
Pyjs
You can also look at http://pyjs.org/ which is a python to JS compiler and use it with Django. The great thing about pyjs is that you are still in Python world :)
http://www.derekschaefer.net/2011/02/08/pyjamas-django-pure-win/
http://gdwarner.blogspot.no/2008/10/brief-pyjamas-django-tutorial.html

Spring webservices how to pass file bytes

I am trying to write a spring webservices which will be used to pass a file as byte[] value. Is this possible using webservice? Can anybody show an example in any website? I have searched a lot and i could not find one. PLease help.
You have several options:
mtom specification, supported e.g. in jaxb, looks like in spring-ws as well: Stream MTOM Web Services in Spring Web Services Framework
there are special data types in xml-schema to handle with binary data, see: JAXB (un)marshalling of xsd types: xsd:base64Binary and xsd:hexBinary
finally you can serialize this data yourself to text format (e.g. using base64) and pass as part of the request using simple xsd:string type

Fetching remote database info from a client application

What would be the preferred method of pulling content from a remote database?
I don't think that I would want to pull directly from the database for a number of reasons.
(Such as easily being able to change where it is fetching the info from and a current lack of access from outside the server.)
I've been thinking of using HTTP as a proxy to the database basically just using some PHP to display raw text from the database and then grabbing the page and dumping it to a string for displaying.
I'm not exactly sure how I would go about doing that though. (Sockets?)
Right now I am building it around a blog/news type system. Though the content would expand in the future.
I've got a similar problem at the moment, and the approach I'm taking is to communicate from the client app with a database via a SOAP web service.
The beauty of this approach is that on the client side the networking involved consists of a standard HTTP request. Most platforms these days include an API to perform basic HTTP client functions. You'll then also need an XML or JSON parser to parse the returned SOAP data, but they're also readily available.
As a concrete example, a little about my particular project: It's an iPhone app communicating with an Oracle database. I use a web service to read data from the database and send the data to the app formatted in XML using SOAP. The app can use Apple's NSURLConnection API to perform the necessary HTTP request. The XML is then parsed using the NSXMLParser API.
While the above are pretty iPhone-specific (and are Objective-C based) I think the general message still applies - there's tools out there that will do most of the work for you. I can't think of an example of an HTTP API offhand, but for the XML parsing part of the equation there's Xerces, TinyXML, Expat...
HTH!
You might look at using AJAX (I recommend JSON instead of XML though). This is the technology underlying Google Maps.