Hi, thanks for the reply, the thing I was asking was how to send the data as stream...i.e I have this JSON string and I need to send it to a web service in the form of a stream...I already tried using the above method and was fine with that..but the requirement is to send as a serialized stream....
Any idea bout that.... Hope to hear from you soon!!! On Aug 25, 11:12 pm, "Megha Joshi" <[EMAIL PROTECTED]> wrote: > This might help... > > JSONObject mLocationJSON = createLocationJSON(mLatitude, mLongitude, > mDateTime); > postLocationJSON(SERVER_URL, mLocationJSON); > > /** > * @param mUrl The URL of location tracking server. > * @param mLocationJSON The location data with time in JSON format. > */ > public void postLocationJSON(String mUrl, JSONObject mLocationJSON) { > HttpClient httpClient = new DefaultHttpClient(); > HttpPost postMethod = new HttpPost(mUrl); > try { > // prepare parameters > HttpParams params = new BasicHttpParams(); > params.setParameter("locationJSON", mLocationJSON.toString()); > postMethod.setParams(params); > httpClient.execute(postMethod); > Log.i(TAG, "Post request, data: " + mLocationJSON.toString()); > } catch (Exception e) { > Log.e("Exception", e.getMessage()); > } finally { > postMethod.abort(); > } > } > > /** > * @param mLatitude The latitude data received from location update sent > by > * LocationManager Service. > * @param mLongitude The longitude received from location update sent by > * LocationManager Service. > * @param mDateTime The DateTime at which location update was sent. > * @return JSONObject The JSONObject holding latitude,longitude reported > by > * the LocationManager Service and DateTime in RFC3339 format. > */ > public JSONObject createLocationJSON(double mLatitude, double > mLongitude, > String mDateTime) { > JSONObject mLocationJSON = new JSONObject(); > try { > mLocationJSON.put("latitude", mLatitude); > mLocationJSON.put("longitude", mLongitude); > mLocationJSON.put("date", mDateTime); > } catch (JSONException ex) { > Log.e(TAG, "Error in creating Location JSON object."); > } > return mLocationJSON; > } > > 2008/8/25 Baran <[EMAIL PROTECTED]> > > > > > Hello Jeffrey, > > > I was wondering if you could provide me something about how you > > appended your JSON string to the web service request. I am trying to > > communicate with this rest web service via POST method. But I am > > unable to identify how to append the JSON string as the parameters. > > Object.setParameter is not working in this scenario... > > > Hope to hear from you soon!! > > > On Aug 21, 10:12 am, Jeffrey Sharkey <[EMAIL PROTECTED]> > > wrote: > > > Just a heads up that I've been using "simpleJSON" with Android, and > > > it's working pretty well. It's somewhat nicer than the defaultJSON > > > included in the SDK because it's iterator-able, making for slick code: > > > > for(JSONValue value : (JSONArray)JSONValue.parse(string)) { > > > JSONObject obj = (JSONObject)value; > > > ... > > > > } > > > >http://www.json.org/java/simple.txt > > > > j > > > > On Aug 20, 11:00 pm, Baran <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > > > Thanks for the reply, actually I was confused with how we can use > > > >JSON. I suppose this is for manipulating the response we get after a > > > > successfulwebservicerequest. Please correct me if I am wrong. Still > > > > new to this thing. > > > > > On Aug 20, 7:00 pm, Mark Murphy <[EMAIL PROTECTED]> wrote: > > > > > > Baran wrote: > > > > > > Hi, > > > > > > > I need to access a .NetwebserviceinRestformat usingJSON. I m > > > > > > pretty new to this concept and very much confused about how this > > > > > > works.... > > > > > > > Any one who can give an overview of the two. I need the steps that > > I > > > > > > need to follow to useJSON. Right now my doubt is how to useJSONto > > > > > > grab to output. Lets say we create a httpclientand it get the > > > > > > respone ....now what? > > > > > > > How can we use theJSONobject to manipulate the response... > > > > > > There is aJSONparser built into Android: > > >http://code.google.com/android/reference/org/json/package-summary.html > > > > > > And there is an HTTPclientbuilt into Android: > > >http://code.google.com/android/reference/org/apache/http/package-summ... > > > > > > though you may wish to view the HttpClient documentation here: > > > > > >http://hc.apache.org/ > > > > > > Both of these are open source projects with their own documentation, > > on > > > > > top of what is in Android. Both are usable in other Java projects > > > > > outside of Android. > > > > > > If you have specific questions regarding the use of one or the other, > > > > > particular as it pertains to Android, write back with the details! > > > > > > -- > > > > > Mark Murphy (a Commons Guy)http://commonsware.com > > > > > Warescription: All titles, revisions, & ebook formats, just $35/year --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] Announcing the new Android 0.9 SDK beta! http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---