Android_WebServices _ source code analysis and android source code analysis
This blog post is original from zimo. For more information, see the source!Http://blog.csdn.net/zimo2013/article/details/38037989In Android_WebServices _ introduction, briefly introduced the basic knowledge of Web Services, the following main analysis of ksoap2-android-assembly-3.3.0-jar-with-dependencies.jar implementation source code. 1. WebServices call Process
Public void getRemoteInfo (String phoneSec) {String nameSpace = "http://WebXml.com.cn/"; String methodName = "getMobileCodeInfo"; String endPoint = "http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx"; String soapAction = "http://WebXml.com.cn/getMobileCodeInfo "; // 1. initialize the SoapObject object and set parameters for this method, which is equivalent to the body SoapObject request = new SoapObject (nameSpace, methodName); request. addProperty ("mobileCode", phoneSec); request. addProperty ("userId", ""); // 2. instantiate the SoapSerializationEnvelope object, which is equivalent to trusting SoapSerializationEnvelope envelope = new SoapSerializationEnvelope (SoapEnvelope. VER10); envelope. bodyOut = request; envelope. dotNet = true; // compatible. net-Services developed by. Net // 3. instantiate the HttpTransportSE object. You can also specify the access request time HttpTransportSE transport = new HttpTransportSE (endPoint); // HttpTransportSE transport = new HttpTransportSE (endPoint, timeout ); try {// 4. call the core method, in which soapActon is in SoapSerializationEnvelope. VER12 is invalid and is a POST Request transport. call (soapAction, envelope); SoapObject response = (SoapObject) envelope. bodyIn; final String result = response. getProperty (0 ). toString (); // Vectortoast (result);} catch (Exception e) {e. printStackTrace (); toast (e. getMessage ());}}
2. transport. call key source code analysis
/*** Perform a soap call with a given namespace and the given envelope providing * any extra headers that the user requires such as cookies. headers that are * returned by the web service will be returned to the caller in the form of a * <code> List </code> of <code> HeaderProperty </code> instances. ** @ param soapAction * the namespace with which to perform the call in. * @ param envelope * the envel Ope the contains the information for the call. * @ param headers * <code> List </code> of <code> HeaderProperty </code> headers to send with the SOAP request. * @ param outputFile * a file to stream the response into rather than parsing it, streaming happens when file is not null ** @ return Headers returned by the web service as a <code> List </code> of * <code> HeaderProperty </code> instances. ** @ throw S HttpResponseException * an IOException when Http response code is different from 200 */public List call (String soapAction, SoapEnvelope envelope, List headers, File outputFile) throws HttpResponseException, IOException, xmlPullParserException {if (soapAction = null) {soapAction = "\" \ ";} // according to envelope, serialize it into a request byte array byte [] requestData = createRequestData (envelope, "UTF-8"); // debug = true, re The questDump value is the requested data, which facilitates debugging of requestDump = debug? New String (requestData): null; responseDump = null; // connection = new ServiceConnectionSE (proxy, url, timeout); including ServiceConnection connection = getServiceConnection (); connection. setRequestProperty ("User-Agent", USER_AGENT); // SOAPAction is not a valid header for VER12 so do not add // it // @ see "http://code.google.com/p/ksoap2-android/issues/detail? Id = 67 if (envelope. version! = SoapSerializationEnvelope. VER12) {connection. setRequestProperty ("SOAPAction", soapAction);} if (envelope. version = SoapSerializationEnvelope. VER12) {connection. setRequestProperty ("Content-Type", CONTENT_TYPE_SOAP_XML_CHARSET_UTF_8);} else {connection. setRequestProperty ("Content-Type", CONTENT_TYPE_XML_CHARSET_UTF_8);} // this seems to cause issues so we are removing it // connection. setRequ EstProperty ("Connection", "close"); connection. setRequestProperty ("Accept-Encoding", "gzip"); // Pass the headers provided by the user along with the call if (headers! = Null) {for (int I = 0; I
Instance download http://download.csdn.net/detail/strawberry2013/7663399
How can I analyze the source code of android?
If you have a high level, you can start from which module, but if you are still at a general level and not very familiar with the code, I personally suggest you buy a related book so that it is better to take the book with you for analysis!
How to analyze the android source code
To view its structure, you need to look at a structural diagram provided by google. Let's take a look at the analysis and analysis. The project in the source code cannot be imported into Eclipse as an Android project separately. You need to import all the Android source code. For how to use git to download the source code, search for it on the Internet and try it on your own. This is not a question, but it is only a matter of your own!