views:

245

answers:

3

Hello everyone

I'm trying to get ksoap2 working on android. I have spent at least 10 hours now reading forum posts, and documentations. Just querying some methods like getServerTime where I don't have to send any values, works. My goal is to send data, and receive a response. For example: send city name, get city time.

I'm practicing on this site: http://www.nanonull.com/TimeService/TimeService.asmx

this is my code:

  String METHOD_NAME = "getCityTime";
  String SOAP_ACTION = "http://www.Nanonull.com/TimeService/getCityTime";
  String NAMESPACE = "http://www.nanonull.com/TimeService/";
  String URL = "http://www.nanonull.com/TimeService/TimeService.asmx";

  SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

  request.addProperty("city", "Chicago");

  SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
    SoapEnvelope.VER11);

  envelope.setOutputSoapObject(request);

  HttpTransportSE httpTransport = new HttpTransportSE(URL);
  try {
   httpTransport.call(SOAP_ACTION, envelope);
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (XmlPullParserException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } // This sends a soap

  System.out.println(envelope.bodyIn.toString());

this is the error I get(envelope.bodyIn.toString()):

SoapFault - faultcode: 'soap:Server'
faultstring: 'Server was unable to process request. ---> Object reference not set to an
instance of an object.' faultactor: 'null' detail: org.kxml2.kdom.Node@435b9cf8

Help would be greatly appreciated.

+1  A: 

Try

   envelope.dotNet = true;
Soumya Simanta
Tried that... it does not make a difference. Still not working.
Tamas
A: 

I got the answer! The server is faulty, something is wrong on the server side! :(

I tried another service(http://footballpool.dataaccess.eu/data/info.wso?), and it works like a charm.

Tamas
+1  A: 

I made an article about the topic

http://www.helloandroid.com/tutorials/using-ksoap2-android-and-parsing-output-data

Tamas