Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
0 down vote favorite


I am new in android development.Now I am working in one existing android project . This application is working in android 2.3 but when I update android sdk to 4.4 it is not working properly. Here is one webservice GetCurrentConnectionString() for getting connection string through webservice from asp code . For that they use

httpTransport.call(SOAP_ACTION, envelope)

but it gives an exception .I don't know what exactly happened. I updated all the Android SDKs please help me. I put all the code below for that function.

Java
 public String GetCurrentConnectionString(){
     public final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";
        final String OPERATION_NAME = "GetCurrentConnectionString";             
        final String SOAP_ACTION = WSDL_TARGET_NAMESPACE + OPERATION_NAME;

        SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME);
        SoapSerializationEnvelope envelope = new      SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;     
            envelope.setOutputSoapObject(request);
        HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
        Object response=null;
        try
        {  
            httpTransport.call(SOAP_ACTION, envelope);
            response = envelope.getResponse().toString();    
        }
         catch (Exception e) { 

             response="Exception"; 
         }
        return response.toString(); 
}
Posted
Comments
Pheonyx 14-Feb-14 5:25am    
Lets start with what exception occurs? Have you debugged your code and examined the details the "e" in the catch?
Prashant S Mane 14-Feb-14 5:33am    
ye it gives android.os.NetworkOnMainThreadException exception and ssugest to use AsyncTask . Because network access is not possible in main thread but still i didnt get how to call AsyncTask and implement my method in that

1 solution

I put that error message into google as I am not an Android developer and have no idea about the solution. This is the first link:
Googles first result[^]
In it there is an example of converting a method to be an AsyncTask along with a note that you must remember to add something to the manifest file.

I suggest you have a read as I believe it should solve your problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900