2012-03-30 3 views
1

나는 안드로이드를 처음 사용하고 있습니다. 안드로이드에서 webservice에 연결해야합니다. webservice 메서드는 10MB보다 큰 문자열 값을 반환합니다. 나는 KSOAP을 사용하려고 생각했다. 누군가가 안드로이드에서 KSOAP를 사용하여 SOAP 웹 서비스에 연결하는 간단한 예를들 수 있습니까?KSoap을 사용하여 안드로이드에서 웹 서비스에 연결

+0

에 대한 비동기 방식을 사용합니까? 이미 많은 예제가 있습니다. –

+0

나는 이것을 위해'Json'을 사용할 것을 추천합니다. 그 가볍고, 쉽고 빠릅니다. – waqaslam

+0

10MB 이상의 파일을 읽고 그 파일을 재생하는 간단한 응용 프로그램이 필요합니다. 그것은 가능한가? (그것의 메모리에 파일을로드, 그것으로 재생하고 그것을 반환) – user1222905

답변

1

는 KSOAP jar 파일을 추가하고 웹 서비스는 다음 무엇을 구글 않았다 ahaaaa

public class Connection extends AsyncTask<Void,Void,Void> { 
    @Override 
    protected Void doInBackground(Void... params) { 
String SOAP_ACTION = "http://www.example.com/Get/GetCount"; 
String METHOD_NAME = "GetCount"; 
String NAMESPACE = "http://www.example.com"; 
String URL = "http://www.example.com/Get.php?wsdl"; 
String Result; 
SoapObject request1 = new SoapObject(NAMESPACE, METHOD_NAME); 
request1.addProperty("AppId", 1); 
SoapSerializationEnvelope envelope = new soapSerializationEnvelope(SoapEnvelope.VER11); 
envelope.dotNet = true; envelope.setOutputSoapObject(request1); 

HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 
androidHttpTransport.debug = true; try { 
//this is the actual part that will call the webservice 
androidHttpTransport.call(soapaction, envelope);       
} 
catch (IOException e) { 
    e.printStackTrace(); } 
catch (XmlPullParserException e) 
{ e.printStackTrace(); } 
    // Get the SoapResult from the envelope body. 
    SoapObject result = (SoapObject)envelope.bodyIn; 
    Result = result.getProperty(0).toString();  
    JSONObject jArray = new JSONObject(Result);  
    JSONArray Count = jArray.getJSONArray("Details"); 

ArrayList<HashMap<String, String>> myList = new ArrayList<HashMap<String, String>>(); 
for(int i=0;i < Count .length();i++){      

HashMap<String, String> map = new HashMap<String, String>(); 
JSONObject e = Count .getJSONObject(i);    
    map.put("id", e.getString("ID")); 
    myList.add(map); 
} 

}

관련 문제