The XML (DataSet) is passed as an argument in Android KSOAP2

Source: Internet
Author: User
Tags dotnet

I need to send WebService in my Android app, so I used KSOP2 to send it, not very well during the testing process, not working 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>


I use KSOAP2 in the Android code 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);


KSOP2 after processing the request, it becomes this

[HTML]View Plaincopy
  1. <V:envelopeXmlns: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><< Span class= "Tag-name" >colour>red</Colour><  
  2. &
  3. <Comments >red</Comments ><<Condition >red</ Condition ><</vehicleobject></updatevehicleviaobj ></v:body></v:envelope>


Distress:

Processing methods

Check out 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 Marshable interface and add additional properties to the class


Original address: http://www.itmmd.com/201412/296.html
This article by Meng Meng's IT person to organize the release, reprint must indicate the source.

The XML (DataSet) is passed as an argument in Android KSOAP2

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.