Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to retrieve array ( list, vector , anything ) of objects as a result from .NET web service in Android?
    primarykey
    data
    text
    <pre><code> public class a extends Activity { public static final String SOAP_ACTION = "http://vladozver.org/GetAllCategories"; public static final String METHOD_NAME = "GetAllCategories"; public static final String NAMESPACE = "http://vladozver.org/"; public static final String URL = "http://192.168.1.3/Services/CategoryServices.asmx"; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TextView tv = (TextView)findViewById(R.id.TextView01); SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(Request); envelope.addMapping(NAMESPACE, "Category",new Category().getClass()); AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL); try { androidHttpTransport.call(SOAP_ACTION, envelope); SoapObject response = (SoapObject)envelope.getResponse(); Object o = (Object)envelope.getResponse(); SoapObject obj = (SoapObject)o; // DOESNT WORK ... Category[] res = new Category[obj.getPropertyCount()]; for (int i = 0; i &lt; res.length; i++) { res[i] = (Category)obj.getProperty(i); } // DOESNT WORK ... Vector&lt;Category&gt; cat = (Vector&lt;Category&gt;)response.getProperty(0); } catch(SoapFault sf) { sf.printStackTrace(); } catch(Exception e) { e.printStackTrace(); } } } public class Category implements KvmSerializable { public int CategoryId; public String Name; public String Description; @Override public Object getProperty(int arg0) { switch(arg0) { case 0: return CategoryId; case 1: return Name; case 2: return Description; } return null; } @Override public int getPropertyCount() { // TODO Auto-generated method stub return 3; } @Override public void getPropertyInfo(int index, Hashtable arg1, PropertyInfo info) { // TODO Auto-generated method stub switch(index) { case 0: info.type = PropertyInfo.INTEGER_CLASS; info.name = "CategoryId"; break; case 1: info.type = PropertyInfo.STRING_CLASS; info.name = "Name"; break; case 2: info.type = PropertyInfo.STRING_CLASS; info.name = "Description"; break; default:break; } } @Override public void setProperty(int index, Object value) { // TODO Auto-generated method stub switch(index) { case 0: CategoryId = Integer.parseInt(value.toString()); break; case 1: Name = value.toString(); break; case 2: Description = value.toString(); break; default: break; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload