I am making an android app that can check information returned from ASP Web service (using Ksoap to interact with Web Service). I don't know why I can retrieve values with another Operation on WService but not with this one. This is the value (json format) returned from my service:
<string>
{"Code":"nxbtrebk000001","Title":"VI DU","Description":"VI DU test","Author":"Tac Gia","Publisher":"NXB Tre","Price":99900,"Salt":"1"}
</string>
When I try to get it from my Android app it returns a whole null json array like this:
{"Code":null,"Title":null,"Description":null,"Author":null,"Publisher":null,"Price":0,"Salt":null}
This is the code I'm using to connect and get values from the web service.
public final String SOAP_ACTION2 = "http://tempuri.org/GetBookItemByBarCode";
public final String OPERATION_NAME2 = "GetBookItemByBarCode";
public final String WSDL_PARAMETER_NAME2 = "Barcode";
public final String WSDL_TARGET_NAMESPACE2 = "http://tempuri.org/";
public final String SOAP_ADDRESS2 = "http://192.168.10.211/secudi";
public String CallSOAP_GetBookInfor(String paramBarcodeScannedData)
{
// SOAP works on request response pair.
SoapObject soapObjectRequest2 = new SoapObject(WSDL_TARGET_NAMESPACE2, OPERATION_NAME2);
// Using setValue() method, set the value to the property.
PropertyInfo bookItemBarcodeData2 = new PropertyInfo();
bookItemBarcodeData2.setName(WSDL_PARAMETER_NAME2);
bookItemBarcodeData2.setValue(paramBarcodeScannedData);
bookItemBarcodeData2.setType(String.class);
soapObjectRequest2.addProperty(bookItemBarcodeData2);
// Create a serialized envelope which will be used to carry the parameters for SOAP body
// and call the method through HttpTransportSE method.
SoapSerializationEnvelope soapEnvelop2 = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelop2.dotNet = true;
soapEnvelop2.setOutputSoapObject(soapObjectRequest2);
HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS2);
Object soapResponse2 = null;
try
{
httpTransport.call(SOAP_ACTION2, soapEnvelop2);
soapResponse2 = soapEnvelop2.getResponse();
}
catch (Exception ex)
{
//soapResponse = ex.toString();
ex.printStackTrace();
}
return soapResponse2.toString();
//return (String)soapResponse;
}
This is my Code Snippet which i using in my Activity to show the value in array.
soapResponseBookItem = secuBookSOAPWS.CallSOAP_GetBookInfor(bBarcodeScannedData);
JSONObject bookItemJSON;
bookItemJSON = new JSONObject(soapResponseBookItem);
TextView BookName = (TextView) findViewById(R.id.Book_Title);
BookName.setText("Book Title: " + bookItemJSON.getString("Title"));
Please help me to fix this. I'm already mad about it. I searched google and stackoverflow but I didn't find a method to work with this.