In android ksoap2, XML (DataSet) is passed as a parameter. androidksoap2
My android app needs to send webservice, so I use ksop2 for sending. It is not smooth during the test and cannot work properly.
My web service request format is as follows:
[Html]View plaincopy
- <Envelope xmlns = "http://schemas.xmlsoap.org/soap/envelope/">
- <Body>
- <UpdateVehicleViaObj xmlns = "http://tempuri.org/">
- <UserHash> [string?] </UserHash>
- <VehicleObject>
- <Colour xmlns = "http://schemas.datacontract.org/2004/07/StockService"> [string?] </Colour>
- <Comments xmlns = "http://schemas.datacontract.org/2004/07/StockService"> [string?] </Comments>
- <Condition xmlns = "http://schemas.datacontract.org/2004/07/StockService"> [string?] </Condition>
- </VehicleObject>
- </UpdateVehicleViaObj>
- </Body>
- </Envelope>
In android code, I use ksoap2 as follows:
[Java]View plaincopy
- SoapObject request = new SoapObject ("Namespace", "methodname ");
- Request. addProperty (properyObject );
- SoapSerializationEnvelope envelope = new SoapSerializationEnvelope (SoapEnvelope. VER11 );
- // SOAP is implemented in dotNet true/false.
- Envelope. dotNet = true;
- MarshalDouble md = new MarshalDouble ();
- // Envelope. implicitTypes = true;
- Envelope. implicitTypes = true;
- Md. register (envelope );
- // Set request data into envelope and send request using HttpTransport
- Envelope. setOutputSoapObject (request );
- HttpTransportSE androidHttpTransport = new HttpTransportSE (mInObj. getUrl (), networkTimeOut );
- AndroidHttpTransport. debug = true;
- AndroidHttpTransport. call (SoapAction, envelope, headerPropertyArrayList );
After ksop2 processes the request, it becomes like this
[Html]View plaincopy
- <V: Envelope xmlns: I = "http://www.w3.org/2001/XMLSchema-instance" xmlns: d = "http://www.w3.org/2001/XMLSchema" xmlns: c = "http://schemas.xmlsoap.org/soap/encoding/" xmlns: v = "http://schemas.xmlsoap.org/soap/envelope/"> <v: header/> <v: Body> <UpdateVehicleViaObj xmlns = "http://tempuri.org/" id = "o0" c: root = "1"> <userHash> B5B2FDF87E848946 </userHash> <vehicleObject> <Colour> red </Colour> <
- &
- <Comments> red </Comments> <Condition> red </Condition> </vehicleObject> </UpdateVehicleViaObj> </v: Body> </v: Envelope>
For help:
Solution
Take a look at the official ksoap2 documentation
Https://code.google.com/p/ksoap2-android/wiki/CodingTipsAndTricks#sending/receiving_array_of_complex_types_or_primitives
You can create a class that implements the retriable interface and add other attributes to the class.
Address: http://www.itmmd.com/201412/296.html
This article is organized and published by Meng IT personnel. The reprinted article must indicate the source.