In android ksoap2, XML (DataSet) is passed as a parameter. androidksoap2

Source: Internet
Author: User

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
  1. <Envelope xmlns = "http://schemas.xmlsoap.org/soap/envelope/">
  2. <Body>
  3. <UpdateVehicleViaObj xmlns = "http://tempuri.org/">
  4. <UserHash> [string?] </UserHash>
  5. <VehicleObject>
  6. <Colour xmlns = "http://schemas.datacontract.org/2004/07/StockService"> [string?] </Colour>
  7. <Comments xmlns = "http://schemas.datacontract.org/2004/07/StockService"> [string?] </Comments>
  8. <Condition xmlns = "http://schemas.datacontract.org/2004/07/StockService"> [string?] </Condition>
  9. </VehicleObject>
  10. </UpdateVehicleViaObj>
  11. </Body>
  12. </Envelope>


 

In android code, I use ksoap2 as follows:

 

 

[Java]View plaincopy
  1. SoapObject request = new SoapObject ("Namespace", "methodname ");
  2. Request. addProperty (properyObject );
  3. SoapSerializationEnvelope envelope = new SoapSerializationEnvelope (SoapEnvelope. VER11 );
  4. // SOAP is implemented in dotNet true/false.
  5. Envelope. dotNet = true;
  6. MarshalDouble md = new MarshalDouble ();
  7. // Envelope. implicitTypes = true;
  8. Envelope. implicitTypes = true;
  9. Md. register (envelope );
  10. // Set request data into envelope and send request using HttpTransport
  11. Envelope. setOutputSoapObject (request );
  12. HttpTransportSE androidHttpTransport = new HttpTransportSE (mInObj. getUrl (), networkTimeOut );
  13. AndroidHttpTransport. debug = true;
  14. AndroidHttpTransport. call (SoapAction, envelope, headerPropertyArrayList );


After ksop2 processes the request, it becomes like this

 

 

 

[Html]View plaincopy
  1. <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> <
  2. &
  3. <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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.