Click here to Skip to main content
15,868,034 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have made a WCF svc service function which returns an Object List. I am trying to get it in Android using KSoap. But i am getting null pointer exception.

Here is the code
Interface: IRegisterLocation
C#
[OperationContract]
List<LocationData> GetAllLocations();
RegisterLocation.svc
public List<LocationData> GetAllLocations()
        {
            return list_location_data; 

        }


C#
public  class LocationData 
    {

        public String lg { set; get; }
        public String lat { set; get; }
        public String userid { set; get; }
        public DateTime datetime { set; get; }


    }

Android Code
Java
try {
            SoapObject request = new SoapObject(NAMESPACE, "GetAllLocations");        
             SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
             envelope.setOutputSoapObject(request);
    //URL = http://MyIPAddress/fnf/RegisterLocation.svc
             HttpTransportSE ht = new HttpTransportSE(URL);

//LOAD_ACTION = "http://tempuri.org/IRegisterLocation/LoadAllLocations"
             ht.call(LOAD_ACTION, envelope);
             final  SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
             final String str = response.toString();
         } catch (Exception e) {
                sb.append("Error:\n" + e.getMessage() + "\n");
                }


I get null pointer exception when executing ht.call(LOAD_ACTION, envelope);

Note: KSoap library is working for other svc function calls and this wcf service is working correctly when we consume it using asp.net.
Posted
Comments
Kornfeld Eliyahu Peter 8-Mar-15 7:10am    
That means, that ht is null! Maybe HttpTransportSE can't create a SOAP layer from the URL? Do some debug!
Atif Agha 8-Mar-15 7:37am    
You are right, but what can be the issue?
Kornfeld Eliyahu Peter 8-Mar-15 7:51am    
Wrong URL?
Atif Agha 8-Mar-15 8:36am    
The url is correct.
Kornfeld Eliyahu Peter 8-Mar-15 8:40am    
Maybe the server is busy and you get a timeout? Try add more time to HttpTransportSE...

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



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