My question should be quite simple to those who always use ksoap2 library.One of my web method in web service have two attribute so may i know how to use addproperty from eclipse to pass two data to web services.Plz provide an example short code.
Asked
Active
Viewed 667 times
-4
-
what do you mean by two data? – yakhtarali Apr 10 '14 at 04:06
-
google it out .. u will find lot of examples – Code_Life Apr 10 '14 at 04:10
-
public void ProductImageInsertion(String name,Byte imageLink) //something like the example above....i need to input two data to the void function – user3484436 Apr 10 '14 at 05:48
1 Answers
1
public static String Login(Context c, String username, String password,
String fleetId) throws IOException, XmlPullParserException {
String METHOD_NAME = "Login";
String SOAP_ACTION = "http://tempuri.org/xxxxxx/";
SOAP_ACTION = SOAP_ACTION + METHOD_NAME;
SoapObject request = new SoapObject(CommonVariable.NAMESPACE,
METHOD_NAME);
// Use this to add parameters
request.addProperty("username", username);
request.addProperty("password", password);
Log.i("request", "request:" + request);
// Declare the version of the SOAP request
Log.i(WebCalls, "URL " + CommonVariable.URL);
Log.i(WebCalls, "Method Name " + METHOD_NAME);
Log.i(WebCalls, "request Name " + request);
String SoapResult = null;
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
HttpTransportSE androidHttpTransport = new HttpTransportSE(
CommonVariable.URL);
// this is the actual part that will call the webservice
androidHttpTransport.call(SOAP_ACTION, envelope);
// Get the SoapResult from the envelope body.
if (envelope.bodyIn instanceof SoapFault) {
SoapResult = ((SoapFault) envelope.bodyIn).faultstring;
} else {
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
SoapResult = resultsRequestSOAP.getProperty(0).toString();
}
Log.i(WebCalls, "Response " + SoapResult);
return SoapResult;
}
you want to add property in webservice like this:
SoapObject request = new SoapObject(CommonVariable.NAMESPACE,
METHOD_NAME);
// Use this to add parameters
request.addProperty("username", username);
request.addProperty("password", password);
I hope its useful to you.

dipali
- 10,966
- 5
- 25
- 51
-
You should write something about the code, simple code in answer is not valid answer. – Lucifer Apr 10 '14 at 04:21
-
For example:public void ProductImageInsertion(String name,Byte imageLink) //i need to input two data to this void function but i only know how to add property to one function, when i try two my logcat will SoapFault – user3484436 Apr 10 '14 at 05:50