WebService Interface access method in Android

Source: Internet
Author: User

Need to introduce ksoap2-android-assembly-2.5.2-jar-with-dependencies.jar Copy codeThe Code is as follows: // WebService namespace
Static final String namespace = "http://impl.service.suncreate.com ";
// Server publishing url
Static final String url = http: // 10.100.3.41/axis2/services/UploadService;
Final String methodName = "upload"; // function name
Final int sessionID = "111111"; // sessionID
// Create an HttpTransportSE object. You can specify the url of the WebService by using the HTTP transportse class constructor.
HttpTransportSE transport = new HttpTransportSE (url );
Transport. debug = true;
// Specify the WebService namespace and function name
SoapObject soapObject = new SoapObject (namespace, methodName );
// Set the value of the call method parameter
SoapObject. addProperty ("sessionID", sessionID); // sessionID
SoapObject. addProperty ("data", cds); // cds is the object to be passed
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope (SoapEnvelope. VER10 );
Envelope. bodyOut = transport;
Envelope. setOutputSoapObject (soapObject );
// Call the WebService method using the call Method
Transport. call (null, envelope );
SoapObject sb = (SoapObject) envelope. bodyIn;
String xmlMessage = sb. toString (); // retrieves the XML String returned from the server
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.