我没有代码。我需要创建一个可以从JSON格式的数据库中获取数据的Web服务。这些数据将在android中使用。我不知道从哪里开始。如果有人能提供帮助,那就太棒了,给我指路。
答案 0 :(得分:1)
如果你精通.net,这样做并不是什么大不了的事。在Android方面,你就是这样做的。
List<NameValuePair> parmeters = new ArrayList<NameValuePair>();
parameters.add(new BasicNameValuePair("username",username));
parameters.add(new BasicNameValuePair("password",password));// These are the namevalue pairs which you may want to send to your php file. Below is the method post used to send these parameters
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url); // You can use get method too here if you use get at the .net side to receive any values.
httpPost.setEntity(new UrlEncodedFormEntity(parameters));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
在.net方面,you extract the data and send back the result by encoding it in json format. While at the android side again, you can get the input stream as shown above. From that input stream, you can get the json data.
有关详细信息,请参阅此thread。如果您仍然需要任何来源,那么我可能会使用某些来源编辑我的答案。希望这会有所帮助。