Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6244647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:21:44+00:00 2026-05-24T12:21:44+00:00

I found tutorial to use kSOAP api to use SOAP webservice. Can anyone provide

  • 0

I found tutorial to use kSOAP api to use SOAP webservice. Can anyone provide me sample programs (tutorial) on getting REST webservice and SOAP webservice in android. I have googled lot but didn’t find such type of tutorial.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T12:21:44+00:00Added an answer on May 24, 2026 at 12:21 pm

    SOAP

    Pros:

    • Langauge, platform, and transport agnostic
    • Designed to handle distributed computing environments
    • Is the prevailing standard for web services, and hence has better support from other standards (WSDL, WS-*) and tooling from vendors
    • Built-in error handling (faults)
    • Extensibility

    Cons:

    • Conceptually more difficult, more “heavy-weight” than REST
    • More verbose
    • Harder to develop, requires tools

    REST

    Pros:

    • Language and platform agnostic
    • Much simpler to develop than SOAP
    • Small learning curve, less reliance on tools
    • Concise, no need for additional messaging layer
    • Closer in design and philosophy to the Web

    Cons:

    • Assumes a point-to-point communication model–not usable for distributed computing environment where message may go through one or
      more intermediaries
    • Lack of standards support for security, policy, reliable messaging, etc., so services that have more sophisticated requirements are harder
      to develop (“roll your own”)
    • Tied to the HTTP transport model

    Example of REST

    Use apache http jar

    public void callRestWebService(){  
              System.out.println(".....REST..........");
                 HttpClient httpclient = new DefaultHttpClient();  
                 HttpGet request = new HttpGet(wsdlURL);  
                 request.addHeader("company name", "abc");  
    
                 request.addHeader("getAccessNumbers","http://service.xyz.com/");
                 ResponseHandler<String> handler = new BasicResponseHandler();  
                 try {  
                     result = httpclient.execute(request, handler); 
                     System.out.println("..result..."+result);
                 } catch (ClientProtocolException e) {  
                     e.printStackTrace();  
                 } catch (IOException e) {  
                     e.printStackTrace();  
                 }  
                 httpclient.getConnectionManager().shutdown();  
    
             } // end callWebService()  
         } 
    

    Example of SOAP

    You can use either ksoap or create soap xml by yourself and send to url

    private boolean callSOAPWebService() {
            OutputStream out = null;
            int respCode = -1;
            boolean isSuccess = false;
            URL url = null;
            HttpsURLConnection httpURLConnection = null;
    
            try {
    
                url = new URL(wsdlURL);
    
    
                httpURLConnection = (HttpsURLConnection) url.openConnection();
    
                do {
                    // httpURLConnection.setHostnameVerifier(DO_NOT_VERIFY);
                    httpURLConnection.setRequestMethod("POST");
                    httpURLConnection
                            .setRequestProperty("Connection", "keep-alive");
                    httpURLConnection
                            .setRequestProperty("Content-Type", "text/xml");
                    httpURLConnection.setRequestProperty("SendChunked", "True");
                    httpURLConnection.setRequestProperty("UseCookieContainer",
                            "True");
                    HttpURLConnection.setFollowRedirects(false);
                    httpURLConnection.setDoOutput(true);
                    httpURLConnection.setDoInput(true);
                    httpURLConnection.setUseCaches(true);
                    httpURLConnection.setRequestProperty("Content-length",
                            getReqData().length + "");
                    httpURLConnection.setReadTimeout(10 * 1000);
                    // httpURLConnection.setConnectTimeout(10 * 1000);
                    httpURLConnection.connect();
    
                    out = httpURLConnection.getOutputStream();
    
                    if (out != null) {
                        out.write(getReqData());
                        out.flush();
                    }
    
                    if (httpURLConnection != null) {
                        respCode = httpURLConnection.getResponseCode();
                        Log.e("respCode", ":" + respCode);
    
                    }
                } while (respCode == -1);
    
                // If it works fine
                if (respCode == 200) {
                    try {
                        InputStream responce = httpURLConnection.getInputStream();
                        String str = convertStreamToString(responce);
                        System.out.println(".....data....." + new String(str));
    
                        // String str
                        // =Environment.getExternalStorageDirectory().getAbsolutePath()+"/sunilwebservice.txt";
                        // File f = new File(str);
                        //
                        // try{
                        // f.createNewFile();
                        // FileOutputStream fo = new FileOutputStream(f);
                        // fo.write(b);
                        // fo.close();
                        // }catch(Exception ex){
                        // ex.printStackTrace();
                        // }
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }
                } else {
                    isSuccess = false;
                }
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                if (out != null) {
                    out = null;
                }
                if (httpURLConnection != null) {
                    httpURLConnection.disconnect();
                    httpURLConnection = null;
                }
            }
            return isSuccess;
        }
    
        public static String createSoapHeader() {
            String soapHeader = null;
    
            soapHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
                    + "<soap:Envelope "
                    + "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\""
                    + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
                    + " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" + ">";
            return soapHeader;
        }
    
        public static byte[] getReqData() {
            StringBuilder requestData = new StringBuilder();
    
            requestData.append(createSoapHeader());
            requestData
                    .append("<soap:Body>"
                            + "<getAccessNumbers"
                            + " xmlns=\"http://service.xyz.com.com/\""
    
                            + "</getAccessNumbers> </soap:Body> </soap:Envelope>");
    
            return requestData.toString().trim().getBytes();
        }
    
        private static String convertStreamToString(InputStream is)
                throws UnsupportedEncodingException {
            BufferedReader reader = new BufferedReader(new InputStreamReader(is,
                    "UTF-8"));
            StringBuilder sb = new StringBuilder();
            String line = null;
            try {
                while ((line = reader.readLine()) != null) {
                    sb.append(line + "\n");
                }
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                try {
                    is.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return sb.toString();
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've found several jQuery syntaxes for nullifying the enter on a form. First one:
I have found this example on StackOverflow: var people = new List<Person> { new
I'm trying to build a C++ extension for python using swig. I've followed the
I have a new web app that is packaged as a WAR as part
I am playing with TFS 2010, and am trying to setup a build process
I have several USB mass storage flash drives connected to a Ubuntu Linux computer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.