나는 [android-eclipse]에 순수한 초보자이며, 여기에서 "http://122.248.240.105:93"URL에서 웹 서비스를 소비해야합니다. android eclipse를 통해 가능한 경우 웹 서비스를 사용합니다. 데모를 해당 URL 또는 다른 예제에서 하나의 웹 서비스로 보냅니다.안드로이드 이클립스에서 웹 서비스를 소모
고마워요.
나는 [android-eclipse]에 순수한 초보자이며, 여기에서 "http://122.248.240.105:93"URL에서 웹 서비스를 소비해야합니다. android eclipse를 통해 가능한 경우 웹 서비스를 사용합니다. 데모를 해당 URL 또는 다른 예제에서 하나의 웹 서비스로 보냅니다.안드로이드 이클립스에서 웹 서비스를 소모
고마워요.
매우 편안한 서비스를 이용할 수 있습니다. 이고 데이터 교환의 경우 XML보다는 json을 선호합니다. 안드로이드 클라이언트에서 JSON으로 편안한 서비스 호출 샘플을 첨부하려고합니다.
public class LoginService {
loginurl="http:/yourhostname.com/Service.svc/Service/ValidateMobileUser";
/**
* This method is used to validate client name from wcf
*
* @param 1: username
* @param 2: password *
* @return true or false as string value
*/
public String authenticate(String userName, String passWord
) throws JSONException, IllegalStateException,
IOException,NullPointerException {
Log.d("input authenticate method", userName + passWord);
HttpPost request = new HttpPost(loginurl);
request.setHeader("Accept", "application/json");
request.setHeader("Content-type", "application/json");
JSONObject json = new JSONObject();
json.put("UserName", userName);
json.put("Password", passWord);
json.toString();
JSONStringer str = new JSONStringer().object().key("clientEntity")
.value(json).endObject();
StringEntity entity = new StringEntity(str.toString());
request.setEntity(entity);
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpResponse response = httpClient.execute(request);
Log.e("Status code ", "status code is " + response.getStatusLine());
HttpEntity responseEntity = response.getEntity();
char[] buffer = new char[(int) responseEntity.getContentLength()];
InputStream stream = responseEntity.getContent();
InputStreamReader reader = new InputStreamReader(stream);
reader.read(buffer);
stream.close();
String response_str = new String(buffer);
int i = response.getStatusLine().getStatusCode();
if (i == 200) {
Log.d("output authenticate method", response_str);
return response_str;
} else {
response_str = Integer.toString(i);
return response_str;
}
}
}
저는 편안한 WCF를 사용하고 Json을 코드에 사용했습니다. 이것을 json으로 편안한 서비스를위한 템플릿으로 사용할 수 있습니다. 편안한 서비스를 위해
내가 JSON과 편안한 선호하지만 ksoap 튜토리얼에 대해 읽으려면 내가 읽고하는 것이 좋습니다 : http://www.devx.com/wireless/Article/39810/1954 How to call a WCF service using ksoap2 on android?
웹 서비스 : http://sochinda.wordpress.com/2011/05/27/connecting-to-net-web-service-from-android/ http://android.vexedlogic.com/2011/04/17/android-lists-iv-accessing-and-consuming-a-soap-web-service-i/
SAXParser를 :
http://www.anddev.org/parsing_xml_from_the_net_-_using_the_saxparser-t353.html을
kshop : http://seesharpgears.blogspot.com/2010/11/returning-array-of-primitive-types-with.html
http://seesharpgears.blogspot.com/2010/11/basic-ksoap-android-tutorial.html
드로어 블 Drawable 사진 : 당신을 위해 도움이되는 경우 http://androiddrawableexplorer.appspot.com/
답변을 받아 주시기 바랍니다. 덕분에
서비스를 원하십니까? –
SOAP 또는 RESTful 웹 서비스? –