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
- <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>
I use KSOAP2 in the Android code 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);
KSOP2 after processing the request, it becomes this
[HTML]View Plaincopy
- <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><
- &
- <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