AnsweredAssumed Answered

how to invoke a webservice?

Question asked by cuizhiyong on Sep 28, 2011
Is there anyone could guide me on how to invoke a activiti webservice through rest api.
I have tried the below codes

DefaultHttpClient dhc = new DefaultHttpClient();
      dhc.getCredentialsProvider().setCredentials(new AuthScope("localhost", 8080), new UsernamePasswordCredentials("kermit", "kermit"));
      HttpPost hp = new HttpPost("http://localhost:8080/activiti-rest/service/process-instance");
         hp.setEntity(new StringEntity("{\"processDefinitionId\":\"financialReport:2:217\"}"));
//         dhc.
         HttpResponse processResponse = dhc.execute(hp);
      }catch(Exception e){

then I got a error told me Authentication is required.

I try code as below:
DefaultHttpClient client = new DefaultHttpClient();
         client.getCredentialsProvider().setCredentials(new AuthScope("localhost", 8080),
             new UsernamePasswordCredentials("kermit", "kermit"));
         // Create AuthCache instance
         AuthCache authCache = new BasicAuthCache();
         // Generate BASIC scheme object and add it to the local auth cache
         BasicScheme basicAuth = new BasicScheme();
         authCache.put(new HttpHost("localhost", 8080, "http"), basicAuth);

         // Add AuthCache to the execution context
         BasicHttpContext localcontext = new BasicHttpContext();
         localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache);
         HttpPost postMethod = new HttpPost("http://localhost:8080/activiti-rest/service/process-instance");
         try {
            postMethod.setEntity(new StringEntity("{\"processDefinitionId\":\"financialReport:2:217\"}"));
            HttpResponse response = client.execute(postMethod, localcontext);
         } catch (Exception e) {
            // TODO Auto-generated catch block

then it is said Failed to retrieve the process definition parameters.
but a deployed process definition with Id financialReport:2:217 is in database

who can help me?
many thanks.