I have used this code mod from some url here :
HttpConnection httpConnection = (HttpConnection) Connector.open(webservice_address,Connector.READ_WRITE);
httpConnection.setRequestMethod(HttpConnection.POST);
httpConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
URLEncodedPostData encPostData = new URLEncodedPostData("UTF-8", false);
encPostData.append("category", String.valueOf(category));
byte[] postData = encPostData.toString().getBytes("UTF-8");
httpConnection.setRequestProperty("Content-Length", String.valueOf(postData.length));
OutputStream os = httpConnection.openOutputStream();
os.write(postData);
os.flush();
os.close();
return httpConnection.getResponseMessage();
But response is always the same, i obtain a "null all times , when i was expected to have a JSON object response , any idea?
P.S: I'm sure server sends data
P.S: I have tried with Connector.READ_WRITE with the same result.
P.S: I'm doing it in the blackberry 9930 simulator
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…