I did not want to hijack another thread if this is due to my own stupidity.

I use wget to call my service while I am debugging it in Eclipse and get the 
415 Unsupported Media Type error.  Calling command and code below.  Any help 
would be appreciated.

$ wget 
--post-data'StatusId=3&EndTime=%222011-01-28%2015%3A34%3A00%22&StartTime=%222011-01-28%2015%3A33%3A00%22&RunLength=00%3A01%3A00&Status=%22Made%20it%22&TestCaseId=1'
 http://10.8.8.91:8182/

Code:

import org.apache.log4j.Logger;
import org.apache.log4j.BasicConfigurator;
import org.restlet.Server;
import org.restlet.data.Protocol;
import org.restlet.resource.Get;
import org.restlet.resource.Post;
import org.restlet.resource.Put;
import org.restlet.resource.ServerResource;

import java.util.Calendar;
import java.sql.*;

public class webService extends ServerResource {
   private static final Logger log = Logger.getLogger(webService.class);
   Calendar calendar = Calendar.getInstance();

   public static void main(String[] args) throws Exception {  
      // Create the HTTP server and listen on port 8182  
      //new Server(Protocol.HTTP, 8182, webService.class).start();
           new Server(Protocol.HTTP, 8182, webService.class).start();
           BasicConfigurator.configure();
   }

   @Get  
   public String toString() {
          Timestamp currentTimestamp = new 
java.sql.Timestamp(calendar.getTime().getTime());
          System.out.println("Entered the Get area " + currentTimestamp); 
      return "Meow!";
      //TODO: Wire up to results
   }
   
   @Post
   public int insertTestResults(int TestCaseId, String StartTime, String 
EndTime, String RunLength, String Status, int StatusId, int ScheduledRun)
   {
           int testRunID = 0;
           Timestamp currentTimestamp = new 
java.sql.Timestamp(calendar.getTime().getTime());
           log.debug("Entered into insertTestResults web method " + 
currentTimestamp);
           System.out.println("Entered the Post area");
           //if (DrillDown == null){
           //   DrillDown = "Not provided";
           //}
           mySQLDatabaseConnection SQLConnect = new mySQLDatabaseConnection();
           testRunID = SQLConnect.insertTestResults(TestCaseId, StartTime, 
EndTime, RunLength, StatusId, Status,  1);
           if (testRunID == 0){
                   testRunID = -1;// error condition if no Test Run Id is 
returned
                   log.error("No testRunID returned for insertTestResults");
           }
           log.info("Test Run Id: " + testRunID);
           log.debug("Leaving insertTestResults web method");
           return testRunID;
   }
   
   @Put
   public void updateTestResults(int TestRunId, String UpdateTime, String 
RunLength, String Status, int StatusId)
   {
           //Update will require TestCaseId, Start Time, UpdateTime, Status and 
StatusId, optional Drill Down Data
           //if (DrillDown == null){
           //      DrillDown = "Not provided";
           //}
           int successMarker = 0;
           log.debug("Entered into updateTestResults web method");
           if (UpdateTime == null){
                   UpdateTime = "01/01/1900 00:00";
           }
           mySQLDatabaseConnection SQLConnect = new mySQLDatabaseConnection();
           successMarker = SQLConnect.updateTestResults(TestRunId, UpdateTime, 
RunLength, StatusId, Status);
           if (successMarker == 0){
                   successMarker = -1;// error condition if no Test Run Id is 
returned
                   log.error("Test Run Update Not Successful");
           }
           log.debug("Leaving updateTestResults web method");
   }
}

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2701985

Reply via email to