How can I parse JSON in android using SOAP?

How can I parse JSON in android using SOAP?  #angularjs #reactjs

  • public void CodeFinished(String methodName, Object Data) { // String str = Data.toString(); // if (str !
  • I am trying to parse JSON data from web service using SOAP in android.
  • its Data not data I must have put that by mistake !
  • I am using SOAP because in my WebService JSON data is in XML tags.
  • It is in the method Codefinished & using as an object – Mirza Hamza 1 hour ago

I am trying to parse JSON data from web service using SOAP in android. My data is showing in debugger but not in the application. I am using SOAP because in my WebService JSON data is in XML tags. When I call JSONOBJECT in my MainActivity it throws an exception & do not enter in the for loop. It usually give me error that the string can not be converted into JSONOBJECT or integer can not be converted into JSONOBJECT. I want to show ll the data inside a list for which I am using another class TableAdapter and I am also using a Model named Table in which getter & setter functions are called.Tell me what to do.

@ng_real_ninja: How can I parse JSON in android using SOAP? #angularjs #reactjs

I am trying to parse JSON data from web service using SOAP in android. My data is showing in debugger but not in the application. I am using SOAP because in my WebService JSON data is in XML tags. When I call JSONOBJECT in my MainActivity it throws an exception & do not enter in the for loop. It usually give me error that the string can not be converted into JSONOBJECT or integer can not be converted into JSONOBJECT. I want to show ll the data inside a list for which I am using another class TableAdapter and I am also using a Model named Table in which getter & setter functions are called.Tell me what to do.

public class MainActivity extends AppCompatActivity implements MyInterface { ListView List; TableAdapter adapter; ArrayList

tableArrayList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); List = (ListView) findViewById(R.id.list); tableArrayList = new ArrayList
(); String SOAP_ACTION = “http://tempuri.org/xxxx”; String OPERATION_NAME = “xxxx”; WebServiceHandler webServiceHandler = new WebServiceHandler(MainActivity.this); webServiceHandler.setValues(SOAP_ACTION, OPERATION_NAME); try { webServiceHandler.executeProcedure(); } catch (Exception e) { Toast.makeText(this, “cant connect”, Toast.LENGTH_SHORT).show(); } } @Override public void StartedRequest() { } @Override public void CodeFinished(String methodName, Object Data) { // String str = Data.toString(); // if (str != null) { try { JSONObject jsonObject = new JSONObject(String.valueOf(data)); JSONArray jsonArray = jsonObject.getJSONArray(“Table”); for( int i=0; i < jsonArray.length(); i++ ) { Table table = new Table(); JSONObject jsonObject1 = jsonArray.getJSONObject(i); table.setRequestID(jsonObject1.getInt("Request_ID")); table.setOwnerID(jsonObject1.getInt("Owner_ID")); table.setCustomerID(jsonObject1.getInt("Customer_ID")); table.setAssetName(jsonObject1.getString("AssetName")); table.setAddress(jsonObject1.getString("Address")); table.setDateTime(jsonObject1.getString("DateTime")); table.setOwnerName(jsonObject1.getString("OwnerName")); table.setCustomerName(jsonObject1.getString("CustomerName")); tableArrayList.add(table); } } catch (JSONException e) { e.printStackTrace(); } TableAdapter adapter = new TableAdapter(getApplicationContext(), R.layout.row, tableArrayList); List.setAdapter(adapter); } } @Override public void CodeFinishedWithException(Exception ex, String exp) { } @Override public void CodeEndedRequest() { } } in which I am facing problem. Debugger do not enter in this for loop. @Override public void CodeFinished(String methodName, Object Data) { // String str = Data.toString(); // if (str != null) { try { JSONObject jsonObject = new JSONObject(String.valueOf(data)); JSONArray jsonArray = jsonObject.getJSONArray(“Table”); for( int i=0; i < jsonArray.length(); i++ ) { Table table = new Table(); JSONObject jsonObject1 = jsonArray.getJSONObject(i); table.setRequestID(jsonObject1.getInt("Request_ID")); table.setOwnerID(jsonObject1.getInt("Owner_ID")); table.setCustomerID(jsonObject1.getInt("Customer_ID")); table.setAssetName(jsonObject1.getString("AssetName")); table.setAddress(jsonObject1.getString("Address")); table.setDateTime(jsonObject1.getString("DateTime")); table.setOwnerName(jsonObject1.getString("OwnerName")); table.setCustomerName(jsonObject1.getString("CustomerName")); tableArrayList.add(table); } } catch (JSONException e) { e.printStackTrace(); } TableAdapter adapter = new TableAdapter(getApplicationContext(), R.layout.row, tableArrayList); List.setAdapter(adapter); } { “Table”: [ { “Request_ID”: 2112, “Owner_ID”: 1668, “Customer_ID”: 1476, “AssetName”: “Two Bed Room House”, “Address”: “xyz”, “DateTime”: “12/24/2016 1:18:44 PM”, “OwnerName”: “IAmAOwner”, “OwnerNumber”: “+923363636013”, “CustomerName”: “arham” }, { “Request_ID”: 2113, “Owner_ID”: 1668, “Customer_ID”: 1476, “AssetName”: “Two Bed Room House”, “Address”: “xyz”, “DateTime”: “12/24/2016 1:45:00 PM”, “OwnerName”: “IAmAOwner”, “OwnerNumber”: “+923363636013”, “CustomerName”: “arham” }, { “Request_ID”: 2121, “Owner_ID”: 1668, “Customer_ID”: 1476, “AssetName”: “Two Bed Room House”, “Address”: “xyz”, “DateTime”: “12/26/2016 3:57:45 PM”, “OwnerName”: “IAmAOwner”, “OwnerNumber”: “+923363636013”, “CustomerName”: “arham” }, { “Request_ID”: 2124, “Owner_ID”: 1668, “Customer_ID”: 1476, “AssetName”: “Two Bed Room House”, “Address”: “xyz”, “DateTime”: “12/26/2016 4:43:19 PM”, “OwnerName”: “IAmAOwner”, “OwnerNumber”: “+923363636013”, “CustomerName”: “arham” }, { “Request_ID”: 2125, “Owner_ID”: 1668, “Customer_ID”: 1476, “AssetName”: “Two Bed Room House”, “Address”: “xyz”, “DateTime”: “12/26/2016 4:50:39 PM”, “OwnerName”: “IAmAOwner”, “OwnerNumber”: “+923363636013”, “CustomerName”: “arham” }, { “Request_ID”: 2126, “Owner_ID”: 1668, “Customer_ID”: 1476, “AssetName”: “Two Bed Room House”, “Address”: “xyz”, “DateTime”: “12/27/2016 1:19:32 PM”, “OwnerName”: “IAmAOwner”, “OwnerNumber”: “+923363636013”, “CustomerName”: “arham” }, { “Request_ID”: 2127, “Owner_ID”: 1668, “Customer_ID”: 1476, “AssetName”: “Two Bed Room House”, “Address”: “xyz”, “DateTime”: “12/27/2016 1:27:36 PM”, “OwnerName”: “IAmAOwner”, “OwnerNumber”: “+923363636013”, “CustomerName”: “arham” }, { “Request_ID”: 2128, “Owner_ID”: 1668, “Customer_ID”: 1476, “AssetName”: “Two Bed Room House”, “Address”: “xyz”, “DateTime”: “12/27/2016 1:35:38 PM”, “OwnerName”: “IAmAOwner”, “OwnerNumber”: “+923363636013”, “CustomerName”: “arham” }, { “Request_ID”: 2129, “Owner_ID”: 1668, “Customer_ID”: 1476, “AssetName”: “Two Bed Room House”, “Address”: “xyz”, “DateTime”: “12/27/2016 1:38:08 PM”, “OwnerName”: “IAmAOwner”, “OwnerNumber”: “+923363636013”, “CustomerName”: “arham” } ] }

How can I parse JSON in android using SOAP?