Click here to Skip to main content
16,019,149 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Guys I Have A problem

I Have [WebMethod] That Returns String[] Array

What Is The Best Way To Get It In Android ? Using Ksoap.Jar

Please Help

Here Is The Result Of WebMethod
<ArrayOfString>
<string>ALI</string>
<string>Mohamed Ahmed</string>
<string>Shis</string>
</ArrayOfString>



And My Android Code Is Like That
<pre lang="text">
public void getcontacts(){
		
		try {
	 	 	SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME1);  
	 	 	request.addProperty("Email",App.GetEmail().toString());
	 	 	SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	 	 	envelope.setOutputSoapObject(request);
	 	 	envelope.dotNet = true;
	 		HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	 		
	 		androidHttpTransport.call(SOAP_ACTION1, envelope);
	 		
	     	SoapObject result = (SoapObject)envelope.bodyIn;
	     	if (result != null) {
	     	
	     		Toast.makeText(getApplicationContext(), envelope.getResponse().toString(), Toast.LENGTH_LONG).show();
	     		Object[] Cont =(String[]) result.getProperty(0);
	    	   
	    		String[] Contacts = Arrays.copyOf(Cont,Cont.length,String[].class);
	     	    Listview1 = (ListView)findViewById(R.id.listView1); 
	     		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice, Contacts);
	     		Listview1.setAdapter(adapter);	
			}
	     	else
			{
		
			}

	 	} catch (Exception e) {
	 		Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
	 	}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900