650U 0 Newbie Poster

Hello people,

I am working on my android project, which happens to be the third project on Android for me. I find these errors in all the files of my project. Hope you can help me solving it. I am attaching the code of one of my file. also the error following the code.
package com.cn.dbox;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.restlet.Client;
import org.restlet.Request;
import org.restlet.Response;
import org.restlet.data.ChallengeRequest;
import org.restlet.data.ChallengeResponse;
import org.restlet.data.ChallengeScheme;
import org.restlet.data.MediaType;
import org.restlet.data.Method;
import org.restlet.data.Protocol;
import org.restlet.data.Status;
import org.restlet.resource.ClientResource;
import org.restlet.resource.ResourceException;
import org.apache.http.HttpResponse;

import android.R.string;
import android.util.Log;

public class callwebService {

   public static String callWebServiceGET(String host, String port, String username, String path){
       BufferedReader in = null;
       OutputStream output = null;
       try {
           HttpClient client = new DefaultHttpClient();
           HttpGet request = new HttpGet();
           try {
               request.setURI(new URI("http://" + host + ":" + port + "/" + username + path));
           } catch (URISyntaxException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
           }
           HttpResponse response =null;
           try {
               response = client.execute(request);
           } catch (ClientProtocolException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
           } catch (IOException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
           }
           
             output = new OutputStream()
               {
                   private StringBuilder string = new StringBuilder();
                   @Override
                   public void write(int b) throws IOException {
                       this.string.append((char) b );
                   }

                   
                   public String toString(){
                       return this.string.toString();
                   }
               };
               try {
                   response.getEntity().writeTo(output);
               } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
               }
               System.out.println(output.toString());

           } finally {

       }
           return output.toString();
    } // end callWebService()
   
   public static HashMap callWebServicePUT(String host, String port, String username, String path, String XMLData){
	   HashMap reply = new HashMap();
       try {
           HttpClient client = new DefaultHttpClient();
           HttpPut request = new HttpPut();
           try {
               request.setURI(new URI("http://" + host + ":" + port + "/" + username + path));
               request.setEntity(new StringEntity(XMLData));
           } catch (URISyntaxException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
           } catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
           HttpResponse response =null;
           try {
               response = client.execute(request);
           } catch (ClientProtocolException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
           } catch (IOException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
           }
           
              
                   reply.put("response", response.getStatusLine().getStatusCode());
               
               reply.put("statusline", response.getStatusLine().getReasonPhrase());

           } finally {

       }
           return reply;
    } // end callWebService()
   
   public static HashMap callWebServiceDELETE(String host, String port, String username, String path){
	   HashMap reply = new HashMap();
       OutputStream output = null;
       try {
           HttpClient client = new DefaultHttpClient();
           HttpDelete request = new HttpDelete();
           try {
               request.setURI(new URI("http://" + host + ":" + port + "/" + username + path));
           } catch (URISyntaxException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
           }
           HttpResponse response =null;
           try {
               response = client.execute(request);
           } catch (ClientProtocolException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
           } catch (IOException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
           }
           
             output = new OutputStream()
               {
                   private StringBuilder string = new StringBuilder();
                   @Override
                   public void write(int b) throws IOException {
                       this.string.append((char) b );
                   }

                   
                   public String toString(){
                       return this.string.toString();
                   }
               };
               reply.put("response", response.getStatusLine().getStatusCode());
			   
			   reply.put("statusline", response.getStatusLine().getReasonPhrase());
               System.out.println(output.toString());

           } finally {

       }
           return reply;
    } // end callWebService()
   
   public static String authenticateAndGET(String username, String password, String path) {
        ClientResource resource = new ClientResource("http://10.0.2.2:8001/" + username + path);
         
         resource.setChallengeResponse(ChallengeScheme.HTTP_DIGEST, username,
                 password);
         // Send the first request with insufficient authentication.
         try {
             //resource.get();
         } catch (ResourceException re) {
         }
        
         // Should be 401, since the client needs some data sent by the server in
         // order to complete the ChallengeResponse.
         System.out.println(resource.getStatus());

         // Complete the challengeResponse object according to the server's data
         // 1- Loop over the challengeRequest objects sent by the server.
         ChallengeRequest c1 = null;
         for (ChallengeRequest challengeRequest : resource
                 .getChallengeRequests()) {
             if (ChallengeScheme.HTTP_DIGEST
                     .equals(challengeRequest.getScheme())) {
                 c1 = challengeRequest;
                 break;
             }
         }

         // 2- Create the Challenge response used by the client to authenticate
         // its requests.
         ChallengeResponse challengeResponse = new ChallengeResponse(c1,
                 resource.getResponse(), username,
                 password.toCharArray());
         resource.setChallengeResponse(challengeResponse);

         // Try authenticated request
         resource.get();
         // Should be 200.
        System.out.println(resource.getStatus());
        return "";
     }
   
   public static void authenticateAndPUT(String username, String password, String path, String fileMetaData) {

         ClientResource resource = new ClientResource("http://localhost:8001/" + username + "/" + path + "/");
         
         resource.setChallengeResponse(ChallengeScheme.HTTP_DIGEST, username,
                 password);
         // Send the first request with insufficient authentication.
         try {
             resource.get().getDigest();
         } catch (ResourceException re) {
         }
        
         // Should be 401, since the client needs some data sent by the server in
         // order to complete the ChallengeResponse.
         System.out.println(resource.getStatus());

         // Complete the challengeResponse object according to the server's data
         // 1- Loop over the challengeRequest objects sent by the server.
         ChallengeRequest c1 = null;
         for (ChallengeRequest challengeRequest : resource
                 .getChallengeRequests()) {
             if (ChallengeScheme.HTTP_DIGEST
                     .equals(challengeRequest.getScheme())) {
                 c1 = challengeRequest;
                 break;
             }
         }

         // 2- Create the Challenge response used by the client to authenticate
         // its requests.
         ChallengeResponse challengeResponse = new ChallengeResponse(c1,
                 resource.getResponse(), username,
                 password.toCharArray());
         resource.setChallengeResponse(challengeResponse);

         // Try authenticated request
         resource.get();
         // Should be 200.
        System.out.println(resource.getStatus());
     }

   public static void authenticateAndDELETE(String username, String password, String path, String location) {

         ClientResource resource = new ClientResource("http://localhost:8001/" + username + "/" + path + "/");
         
         resource.setChallengeResponse(ChallengeScheme.HTTP_DIGEST, username,
                 password);
         // Send the first request with insufficient authentication.
         try {
             resource.get();
         } catch (ResourceException re) {
         }
        
         // Should be 401, since the client needs some data sent by the server in
         // order to complete the ChallengeResponse.
         System.out.println(resource.getStatus());

         // Complete the challengeResponse object according to the server's data
         // 1- Loop over the challengeRequest objects sent by the server.
         ChallengeRequest c1 = null;
         for (ChallengeRequest challengeRequest : resource
                 .getChallengeRequests()) {
             if (ChallengeScheme.HTTP_DIGEST
                     .equals(challengeRequest.getScheme())) {
                 c1 = challengeRequest;
                 break;
             }
         }

         // 2- Create the Challenge response used by the client to authenticate
         // its requests.
         ChallengeResponse challengeResponse = new ChallengeResponse(c1,
                 resource.getResponse(), username,
                 password.toCharArray());
         resource.setChallengeResponse(challengeResponse);

         // Try authenticated request
         resource.get();
         // Should be 200.
        System.out.println(resource.getStatus());
     }

}

************************************************************************
Errors:
1. ChallengeRequest cannot be resolved as a type
2. ClientResourse cannot be resolved as a type
3. ResourceException cannot be resolved as a type
***********************************************
In another file I get org.restlet.data cannot be resolved to a type
************************************************************************

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.