Amazon Ad

Wednesday 18 April 2012

How To Get Complex Data In Android Using ASP.NET WebService

Hi Folks!,

Today i am posting the code that would get the data from the asp.net webservice. The webservice returns the data as DataSet and passes to android device. The code here explains how to deal with the complex data types like dataset from asp.net webservice into andoroid device. Here is the code

public SoapObject soap(String METHOD_NAME, String SOAP_ACTION,
String NAMESPACE, String URL, String IP, String SERVICEPATH)
throws IOException, XmlPullParserException
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); // set up



SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); // put all required data into a soap
envelope.dotNet = true;
envelope.setOutputSoapObject(request); // prepare request
envelope.bodyOut = request;

HttpsTransportSE aht = new KeepAliveHttpsTransportSE(IP, 443,SERVICEPATH, 5000);
aht.debug = true;
//aht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
aht.call(SOAP_ACTION, envelope);
SoapObject result = (SoapObject) envelope.bodyIn; // get response

SoapObject responseBodyRaw,responseBody,table,tableRow;
responseBodyRaw = (SoapObject)envelope.getResponse();
responseBody = (SoapObject)envelope.getResponse();
// Now, the reponse works as a Vector. On position 0 we have the information of the Reponse while in position 1 we get the info we requested. So we get rid of the information reponse and lets grab the info we requested
responseBody = (SoapObject)responseBody.getProperty(1);
// And now, we have the n tables returned by the asp.net webservice.
table = (SoapObject) responseBody.getProperty(0);

// We can get the row of the table by using the getProperty(rownumber)
tableRow = (SoapObject) table.getProperty(0);

return table;
}

The above method can be called by using this code
SoapObject table=null;

table = soap("Webmethodname","http://tempuri.org/Webmethodname","http://tempuri.org/","http://www.mywebsite.com/service.asmx","www.mywebsite.com", "service.asmx");
//data=table.toString();
titles=new String[table.getPropertyCount()];

for(int i=0;i<table.getPropertyCount();i++)
{
tableRowData = (SoapObject) table.getProperty(i);
                       }

The above code calls the "soap" method and you can get the tableRow Data by using the above code. Hope you guys have understood the concept.

Thnx
ritessh


How to implement Captcha v3 in ASP.NET

 I was facing an issue of dom parsing in my website. I finally resolved it by using Google Captcha V3. Step 1: Get your keys from https:...