我想從我的Android客戶端使用此的NameValuePair方法的幾個值發送到Web服務器:如何使用NameValuePair發送字節HTTP?
public void postData() {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http:/xxxxxxx");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
String amount = paymentAmount.getText().toString();
String email = inputEmail.getText().toString();
nameValuePairs.add(new BasicNameValuePair("donationAmount", amount));
nameValuePairs.add(new BasicNameValuePair("email", email));
nameValuePairs.add(new BasicNameValuePair("paymentMethod", "5"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
}
不幸的NameValuePair只能夠發送字符串,我需要發送的字節[]值也。任何人都可以幫我解決我的問題嗎?
編碼'的byte []'爲Base64字符串或使用其他'HttpEntity'例如'MultipartEntity'(需要第三方的lib ......它只是谷歌) – Selvin 2012-02-09 13:59:28
我需要發送圖像。 – Selva 2012-02-09 14:02:42
當我發送Base64字符串如何處理webservice.i已使用asmx使用vb.net – Selva 2012-02-09 14:03:58