我正在尝试将数据发布到 asp.net Web 服务,但似乎我不知道该怎么做。所以我需要发布这样的数据
之后我得到这样的 JSON 响应
{"VALID":"success"}
现在我正在使用这个功能,但似乎它不适用于这个目的。/
/ Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://yoors.somee.com/Default.aspx?type=EmailInsert");
// http://yoors.somee.com/Default.aspx?type=Email
// Insert&username=ben&password=pass&name=alv
//&email=ben@yahoo.com&emailenabled=false
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("username",userName));
nameValuePairs.add(new BasicNameValuePair("name", name));
nameValuePairs.add(new BasicNameValuePair("password", password));
nameValuePairs.add(new BasicNameValuePair("email", email));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
Toast.makeText(Signup.this, response.getAllHeaders().toString(), Toast.LENGTH_LONG).show();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
那么任何人都可以指导我如何将数据发布到这个网络服务