Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Jsonrpc help needed
Message
Information générale
Forum:
Android
Catégorie:
Autre
Divers
Thread ID:
01629311
Message ID:
01629390
Vues:
23
Looks OK to me :-}

Looking at your previous post it seems to me that the client generated JSon is what I'd expect (except for a closing curly ? ) and the server expectation is non-standard.

>Hi Viv, I've managed to get a basic working program together by plagiarising some code from one of the links you posted - it ain't pretty yet and I'm sure there's a better way of doing it but it works, I build the request string manually and call the method below which gives me raw json in return - this will do for now but as always I'm open to suggestions - thanks for your help
>
>
> private JSONObject doJSONRequest(JSONObject jsonRequest,String Server)
>    {
>        HttpClient httpClient = new DefaultHttpClient();
>        HttpPost request = new HttpPost(Server);
>        JSONObject jsonResponse = null;
>
>        HttpResponse response = null;
>        String responseString = null;
>        JSONEntity entity = null;
>
>        try
>        {
>            entity = new JSONEntity(jsonRequest);
>        }
>        catch (UnsupportedEncodingException e)
>        {
>            e.printStackTrace();
>        }
>
>
>        request.setEntity(entity);
>
>
>        try
>        {
>            response = httpClient.execute(request);
>            responseString = EntityUtils.toString(response.getEntity()).trim();
>            jsonResponse = new JSONObject(responseString);
>        }
>        catch (Exception ex)
>        {
>            ex.printStackTrace();
>        }
>        return jsonResponse;
>    }
>
>
>
>Helper class
>
>
>class JSONEntity extends StringEntity
>    {
>        public JSONEntity(JSONObject jsonObject) throws UnsupportedEncodingException
>        {
>            super(jsonObject.toString());
>        }
>
>        public Header getContentType()
>        {
>            return new BasicHeader("Content-Type", "application/json");
>        }
>    }
>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform