Android uses soap WSDL to communicate With Webservice

Source: Internet
Author: User

 

Six steps are required. For the NAME_SPACE in the code below, you can connect to the server through a software SoapUI.

 

/** Namespace. */private final static String NAME_SPACE = urn: soap;/** method. */private final static String METHOD_NAME = Add;/** URL of the WSDL file. */private final static String WSDL_URL = http: // 192.168.1.112: 80/index. php/service? Wsdl;


 

 

// 1. Specify the WebService namespace and the called method name SoapObject request = new SoapObject (NAME_SPACE, METHOD_NAME );

// 2. this step is optional. If the method does not have any parameters, You can omit this step. addProperty (a, 123); request. addProperty (B, 12 );

// 3. Generate the SOAP request information that calls the WebService method. This information is described by the SoapSerializationEnvelope object SoapSerializationEnvelope envelope = new SoapSerializationEnvelope (SoapEnvelope. VER10); envelope. bodyOut = request;

// 4. Create an HttpTransportSE object. Through the construction method of the HttpTransportSE class, you can specify the URL HttpTransportSE ht = new HttpTransportSE (WSDL_URL) of the WSDL document of WebService; ht. debug = true;

// 5. Use the call method to call the WebService Method
List headerList =ht.call(null, envelope,null);
Note: If you do not need a header file, you only need to pass the first two parameters.

 

 

// 6. use the getResponse method to obtain the returned results of the WebService method SoapObject result = (SoapObject) envelope. bodyIn; Log. I (=========, result. getProperty (Add ). toString ());



 

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.