ksoap2-android: How to add array of PropertyInfo to request?

4,381 views
Skip to first unread message

Siarhei Rakitski

unread,
Nov 4, 2012, 2:41:22 PM11/4/12
to ksoap2-...@googlegroups.com
Hi,
I'm writing, because I have a problem with sending a complex property.

The wsdl scheme is: http://www.drebedengi.ru/soap/dd.wsdl

I have an example on PHP:
$client->getRecordList(
			'demo_api',
			'de...@example.com',
			'demo',
			array(
				'is_report'    => false,  // Data not for report, but for export
				'r_how'        => 1,      // Show by detail, not grouped
			)
		)

For android application it looks like:

SoapObject _client = new SoapObject("", "getRecordList");

_client.addProperty("apiId", "demo_api");
_client.addProperty("login", "de...@example.com");
_client.addProperty("pass", "demo");


SoapObject param = new SoapObject();
param.addProperty("is_report",false);
param.addProperty("r_how",1);

_client.addProperty("params",param);

SoapSerializationEnvelope _envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
_envelope.bodyOut = _client;

HttpTransportSE _ht = new HttpTransportSE("http://www.drebedengi.ru/soap/");
_ht.debug = true;

try {
_ht.call("", _envelope);
System.out.println(_envelope.getResponse());
} catch (Exception e) {
System.out.println(_ht.responseDump);
e.printStackTrace();
}

It is doesn't working for me. The output is the following:
An error occurred:<br><br>Object of class stdClass could not be converted to string
java.lang.RuntimeException: Stub!
    at org.xmlpull.v1.XmlPullParserException.<init>(XmlPullParserException.java:6)
    at org.kxml2.io.KXmlParser.exception(KXmlParser.java:242)
    at org.kxml2.io.KXmlParser.nextTag(KXmlParser.java:1373)
    at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:127)
    at org.ksoap2.transport.Transport.parseResponse(Transport.java:116)
    at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:238)
    at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:114)

Could you help me to send two parameters ("is_report" and "r_how") as a complicated property with name "param"?
I tried to use ComplicatedProperty class which is implements KvmSerializable but it is also is not working and the same error is occured.
Note: I used HashMap<String,Object> and Apache Axis instead of ksoap2 and it works fine. But it is not possible to use type HashMap for ksoap.

Thank you.

Siarhei Rakitski

unread,
Nov 18, 2012, 2:48:27 PM11/18/12
to ksoap2-...@googlegroups.com
Hi guys, I found the solution of my problem:
If you need to use an arrays of parameters, you can use HashMap and just register MarshalHashTable object.
MarshalHashTable is needed to use HashTable object as container of parameters:

Hashtable hashtable = new Hashtable();
hashtable.put("is_report", false);
hashtable.put("r_how", 1);
_client.addProperty("params",hashtable);

SoapSerializationEnvelope _envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
 _envelope.bodyOut = _client;
HttpTransportSE _ht = new HttpTransportSE("http://www.drebedengi.ru/soap/");
_ht.debug = true;     
(new MarshalHashtable()).register(_envelope);

Heberth Deza

unread,
Nov 18, 2012, 10:01:05 PM11/18/12
to ksoap2-...@googlegroups.com
Thanks you very much !
Heberth

Manfred Moser

unread,
Nov 19, 2012, 12:40:45 PM11/19/12
to ksoap2-...@googlegroups.com

Qasim Azam

unread,
Mar 28, 2013, 5:16:54 AM3/28/13
to ksoap2-...@googlegroups.com
Siarhei Rakitski i'm just a beginner, and i don't know how can i do this task. can you please send me the code of how i can send ANDROID FORM VALUES 
to ASP.net WCF web service method using ksoap2-android. Please help me. i'll never forget this help. 

Xu Lin

unread,
Oct 6, 2014, 5:36:05 PM10/6/14
to ksoap2-...@googlegroups.com

I am using ksoap2 in my android app to connect to Magento SOAP API.

In the PHP server, I can create customerData by

$customerData = array(
"firstname" => "testFirstname",
"lastname" => "testLastName",
"email" => "test...@mail.com",
"mode" => "guest",
"website_id" => "0"
  );

in my code, I don't know how to implement in the ????? part.

request.addProperty("customerData", ?????);

I have try SoapObject, HashTable, String, it seemed that web server did not receive data.

Can you confirm that this method is still working? I have tried that, but it did not.


在 2012年11月18日星期日UTC-5下午2时48分27秒,Siarhei Rakitski写道:
Reply all
Reply to author
Forward
0 new messages