Dear Professionals,
Im using ksoap2 classes for invoking asp.net Web service methods in an android application guided by examples from this site. I am getting a java.net socket timed out exception.
Kindly help me figure out mistake in the code.
What I have tried :
I have added <uses-permission android:name="android.permission.INTERNET" xmlns:android="#unknown"> in the manifest and also added the library ref in the Build path etc.,
I have ensured the ASP.net webservice works well from other .net apps and from the explorer.
I have googled for several solutions online. But didn't find one to solve my issue or may be not to my understanding.
Please Note : I have worked on SOAP with android using ksoap2 in earlier projects and was through. This time I'm missing something. Please help.
Thanks in advance.
package com.Test.testtvgrm;
import java.io.IOException;
import org.apache.http.client.HttpResponseException;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;
public class TestWS
{
public String SoapAction = "http://192.168.5.28/GetFolio";
public String WSDLTargetNameSpace = "http://192.168.5.28/";
public String SoapAddress = "http://192.168.5.28/grmserver/service.asmx";
public TestWS()
{
}
public String CallFunc(int mfunc,String mpara)
{
Object response = null;
SoapObject sorequest = new SoapObject(WSDLTargetNameSpace, "GetFolio");
String[] mparavalues = mpara.split("%");
if (mfunc == 1)
{
sorequest.addProperty("mpath", mparavalues[1]);
sorequest.addProperty("mroomno",mparavalues[2]);
}
SoapSerializationEnvelope soenvelope = new SoapSerializationEnvelope
(SoapEnvelope.VER11);
soenvelope.dotNet = true;
soenvelope.setOutputSoapObject(sorequest);
HttpTransportSE httpTransport = new HttpTransportSE(SoapAddress);
httpTransport.debug=true;
try
{
httpTransport.call(SoapAction, soenvelope);
response = soenvelope.getResponse();
}
catch (HttpResponseException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
catch (XmlPullParserException e)
{
e.printStackTrace();
}
return response.toString();
}
}
I'm calling the 'CallFunc' method from another class which invokes a background method to do the task. That code is as below :
Task_GetFolio = new GetFolio();
Task_GetFolio.execute((Void) null);
The background task is in this class :
public class GetFolio extends AsyncTask<Void, Void, Boolean>
{
@Override
protected Boolean doInBackground(Void... params)
{
try
{
TestWS mobj = new TestWS();
String mret = mobj.CallFunc(1, "%c:\\%1%");
FolioFetched=true;
}
catch (Exception e1)
{
FolioFetched=false;
}
return FolioFetched;
}
@Override
protected void onPostExecute(final Boolean success)
{
Task_GetFolio=null;
finish();
}
@Override
protected void onCancelled()
{
Task_GetFolio=null;
finish();
}
}