Ways to access the WebService interface in Android _android

Source: Internet
Author: User
Need to introduce Ksoap2-android-assembly-2.5.2-jar-with-dependencies.jar
Copy Code code as follows:

The WebService namespace
Static final String namespace = "http://impl.service.suncreate.com";
URL for server Publishing
Static final String url = http://10.100.3.41/axis2/services/UploadService;
Final String methodname = "Upload"; The name of the function
final int sessionID = "111111"; SessionID
Creates a Httptransportse object that allows you to specify the URL of the webservice through the Httptransportse class's construction method
Httptransportse transport = new Httptransportse (URL);
Transport.debug = true;
Specifies the namespace and function name of the WebService
Soapobject soapobject = new Soapobject (namespace, methodname);
Set the value of the calling method parameter
Soapobject.addproperty ("SessionID", SessionID); SessionID
Soapobject.addproperty ("Data", CDs); CDs are objects that need to be passed
Soapserializationenvelope envelope = new Soapserializationenvelope (SOAPENVELOPE.VER10);
Envelope.bodyout = transport;
Envelope.setoutputsoapobject (Soapobject);
Calling the WebService method using the Call method
Transport.call (null, envelope);
Soapobject sb = (soapobject) Envelope.bodyin;
String xmlmessage = sb.tostring (); Gets the XML string returned from the server side
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.