Here is my web service code我如何調用從Android應用
用Python編寫的Web服務,我可以使用http://sheltered-taiga-3258.herokuapp.com/toi/<input parameters>
我從用戶的Android設備上收集輸入參數我的瀏覽器調用它。顯然,Web服務返回一個JSON數據,我需要在android應用程序的客戶端顯示。我經歷了許多關於android和web服務的帖子和教程,但是並沒有成功,因爲許多人都有PHP中的POST請求和服務的web服務示例。我想爲GET做這件事,服務在燒瓶中。
請幫忙謝謝。
編輯:
我使用HTTPGET對象調用Web服務,我通過我的URL作爲參數傳遞給它。
HttpGet httpget = new HttpGet(myURL);
,我構建myURL作爲
EditText inputString = (EditText) findViewById(R.id.serverText);
String appendString =URLEncoder.encode(inputString.getText().toString(), "UTF-8") ;
private final HttpClient Client = new DefaultHttpClient();
String myURL = "http://sheltered-taiga-3258.herokuapp.com/toi/" + appendString;
在這裏我得到myURL作爲 http://sheltered-taiga-3258.herokuapp.com/toi/hc+stays+toll+collection但我想它以這種方式
http://sheltered-taiga-3258.herokuapp.com/toi/HC%20stays%20toll%20collection%20in%20kolhapur%20city
我知道有一些網址編碼問題BU不知道它的方式。
檢查在[1](HTTP給出的答案的真實的方式://或者[2](http://stackoverflow.com/a/3487413/1833437)或[3](http://stackoverflow.com/a/3286128/1833437)。 –
@ABDC感謝那個似乎在工作的人......會很快嘗試並在此發佈。 –