Monday, 4 April 2016

Calling BPD using External Implementation (JAVA) REST API

1. Log in REST API Test Client in below URL:
http://host_name:port_number/bpmrest-ui

 Note:Go to Overview.Check Exposed to Start as All Users
2. Run the REST API call "Exposed Processes" to get the parameters of your BPD to start.
 
3.Create the Snapshot and activate the Snapshot.
 
 3. Run the REST API call "start process" with the parameters above. You will get a URL like shown below.

With the URL, you can start the BPD via Java Program. Below is a sample of Java program.Copy that url into uriString.

 public static void main(String[] args) {
      
        HttpURLConnection connection = null;
        try {
        String uriString = "https://miracle:9443/rest/bpm/wle/v1/process?action=start&bpdId=25.a738c980-3785-4d67-b6a5-c94555d6b937&snapshotId=2064.782f9510-b7ac-43c1-8e5f-84da7c70690c&branchId=2063.a4f5e2d3-0ba9-4135-8d3f-c4e2883e3225&processAppId=2066.6523cebd-cc73-4638-b1ff-841d3c5fccd7&x-method-override=POST&parts=all";
        URL url = new URL(uriString);
        connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");

        BASE64Encoder encoder = new BASE64Encoder();
        String username = "admin";
        String password = "admin";
        String encodedCredential = encoder.encode((username + ":" + password).getBytes());
        connection.setRequestProperty("Authorization", "Basic "+encodedCredential);

        connection.connect();
        BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
        int responseCode = connection.getResponseCode();
        if (responseCode == HttpURLConnection.HTTP_OK)
        {
        StringBuffer stringBuffer = new StringBuffer();
        String line = "";
        while ((line = reader.readLine()) != null) {
        stringBuffer.append(line);
        }
        String content = stringBuffer.toString();
        System.out.println(content);
        }
        } catch (Exception e) {
        e.printStackTrace();
        } finally {
        if (connection != null) {
        connection.disconnect();
        }
        }
    }

4.Create JAR file add it to Integration Service and run.You will see BPD running.


5 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. http://www.java2s.com/Code/Jar/s/DownloadsunmiscBASE64Decoderjar.htm

    ReplyDelete
  3. hi murli,
    give me contact number.
    call me this number : 8884785068

    ReplyDelete
  4. iam also working ibm bpm ...

    ReplyDelete
  5. Ashok, I am currently not working on the IBM BPM.

    ReplyDelete