am trying to connect to a web service in order to retrieve some data with an android device with ksoap2. i assume that i have make the configuration correct and the result that i get back from the web service is anyType{} the code that i use is the below
private static final String NAMESPACE = "http://tempuri.org/" ;
private static final String URL = "http://IP/CardiacPortalWS/VitalInfoWS.asmx";
private static final String HelloWorld_SOAP_ACTION = "http://tempuri.org/getPatient";
private static final String METHOD_NAME1 = "getPatient";
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1);
request.addProperty("patientID",8);
SoapSerializationEnvelope envelope =new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
androidHttpTransport.debug=true;
SoapObject receivedString=null;
try
{
androidHttpTransport.call(HelloWorld_SOAP_ACTION, envelope);
receivedString = (SoapObject)envelope.getResponse();
Log.v("Server", "server data1 "+receivedString.getPropertyCount());
Log.i("Server", "server data2 "+receivedString.getProperty(0));
}
catch(Exception e)
{ }
The SOAP file is
SOAPAction: "http://tempuri.org/getPatient"
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getPatient xmlns="http://tempuri.org/">
<patientID>int</patientID>
<name>string</name>
<SID>string</SID>
<sex>boolean</sex>
<birthday>dateTime</birthday>
<nationality>string</nationality>
<telephone>string</telephone>
<telephone1>string</telephone1>
<email>string</email>
<maritalStatusName>string</maritalStatusName>
<educationName>string</educationName>
<ejectionFraction>int</ejectionFraction>
<profession>string</profession>
<deathDateTime>dateTime</deathDateTime>
<deathReason>string</deathReason>
<isDead>boolean</isDead>
</getPatient>
</soap:Body>
</soap:Envelope>
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getPatientResponse xmlns="http://tempuri.org/">
<getPatientResult>
<message>string</message>
<code>int</code>
</getPatientResult>
<name>string</name>
<SID>string</SID>
<sex>boolean</sex>
<birthday>dateTime</birthday>
<nationality>string</nationality>
<telephone>string</telephone>
<telephone1>string</telephone1>
<email>string</email>
<maritalStatusName>string</maritalStatusName>
<educationName>string</educationName>
<ejectionFraction>int</ejectionFraction>
<profession>string</profession>
<deathDateTime>dateTime</deathDateTime>
<deathReason>string</deathReason>
<isDead>boolean</isDead>
</getPatientResponse>
</soap:Body>
</soap:Envelope>
i assume that the problem is in this line request.addProperty("patientID",8); but am not sure. data on the server exist because am able to see them. i would appreciate some help, an idea or a more detail tutorial
Correct code
private static final String NAMESPACE = "http://tempuri.org/" ;
private static final String URL = " http://IP/CardiacPortalWS/VitalInfoWS.asmx";
private static final String SOAP_ACTION = "http://tempuri.org/userLogin";
private static final String METHOD_NAME = "userLogin";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("PatientID", "10");
request.addProperty("Weight", "72");
String currentDateTimeString = new SimpleDateFormat("yyyy-MM-dd").
format(new Date());
request.addProperty("DateTimeStamp",currentDateTimeString);//"2012-01-13");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
Log.i("Server", "server data2 "+((Object)envelope.getResponse()));
} catch(Exception e) {
Log.e("Server", "Error on server "+e.getMessage());
}
}