WSO2 BPS - Management API

[ Documentation Index ]

WSO2 Business Process Server (BPS) Management API

Introduction

WSO2 BPS has a complete management API to check which processes are deployed, running and completed instances, variables values and more. The available methods can be found at ProcessManagement, InstanceManagement and PackageManagement WSDLs.

Those three services can be invoked through any web service client.

Sample Client

NOTE: It is mandatory to authenticate the user before invoking management services.

The following is the source for sample management client which uses default username (admin), password (admin) to login to the BPS server and retrieves the process list. You can find the sample pom file to create a jar here

packageorg.wso2.bps.samples.client;importorg.wso2.bps.samples.client.types.Login;importorg.wso2.bps.samples.client.types.LoginResponse;importorg.wso2.bps.samples.client.types.GetSystemPermissionOfUser;importorg.wso2.bps.samples.client.types.GetSystemPermissionOfUserResponse;importorg.wso2.bps.samples.client.mgt.types.ProcessInfoListPaginated;importorg.wso2.bps.samples.client.mgt.types.ProcessInfoType;importorg.wso2.bps.samples.client.mgt.ProcessManagementServiceStub;importorg.apache.axis2.client.Options;importorg.apache.axis2.client.ServiceClient;importorg.apache.axis2.transport.http.HTTPConstants;importjava.rmi.RemoteException;publicclass BPSManagementClient {finalString backendServerURL ="https://localhost:9443/services/";finalString AUTHENTICATION_ADMIN_SERVICE ="AuthenticationAdminService";finalString trustStore ="/home/waruna/Desktop/BPS/new/wso2bps-1.1.0/repository/resources/security";String userName ="admin";String password ="admin";String clientIPAddr ="localhost";String cookie =null;publicstaticvoid main (String[]args){boolean isLogged =false;
        BPSManagementClient client =new BPSManagementClient();try{
            isLogged = client.authenticate();}catch(AuthenticationExceptionException e){
            e.printStackTrace();//To change body of catch statement use File | Settings | File Templates.}catch(RemoteException e){
            e.printStackTrace();//To change body of catch statement use File | Settings | File Templates.}

        ProcessInfoListPaginated processList =null;if(isLogged){try{System.out.println("User: "+ client.userName+" loggin successful");
                processList = client.listProcessesPaginated("name}}* namespace=*", "deployed name", 0);}catch(RemoteException e){
                e.printStackTrace();//To change body of catch statement use File | Settings | File Templates.}

            ProcessInfoType[] processes = processList.getProcessInfo();if(processes !=null){System.out.println("---------------------------PROCESS LIST---------------------------");System.out.println("\t\tNAME\t\t|\t\tSTATUS\t\t|\t\tVERSION\t\t|\t\tPACKAGE\t\t|\t\tDEPLOYED ON");for(ProcessInfoType process : processes){System.out.println(process.getPid()+"\t|\t"+ process.getStatus().getValue()+"\t|\t"+
                            process.getVersion()+"\t|\t"+ process.getDeploymentInfo().getPackageName()+"\t|\t"+
                            process.getDeploymentInfo().getDeployDate().getTime().toString());}}else{System.out.println("NULL process list");}}else{System.out.println("User: "+ client.userName+" loggin FAILED!");}}publicboolean authenticate()throws AuthenticationExceptionException, RemoteException{String serviceURL = backendServerURL + AUTHENTICATION_ADMIN_SERVICE;
        AuthenticationAdminServiceStub stub =new AuthenticationAdminServiceStub(null, serviceURL);
        Login loginRequest =new Login();
        loginRequest.setUsername(userName);
        loginRequest.setPassword(password);
        loginRequest.setRemoteAddress(clientIPAddr);System.setProperty("javax.net.ssl.trustStore", trustStore +"/client-truststore.jks");System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");

        Options option = stub._getServiceClient().getOptions();
        option.setManageSession(true);
        LoginResponse loginResponse = stub.login(loginRequest);boolean isLogged = loginResponse.get_return();if(isLogged){
            cookie =(String) stub._getServiceClient().getServiceContext().getProperty(HTTPConstants.COOKIE_STRING);}return isLogged;}public ProcessInfoListPaginated listProcessesPaginated(String filter, String orderBy, int pageNumber)throwsRemoteException{String serviceURL = backendServerURL +"ProcessManagementService";
        ProcessManagementServiceStub stub =new ProcessManagementServiceStub(null, serviceURL);
        ServiceClient client = stub._getServiceClient();
        Options option = client.getOptions();
        option.setManageSession(true);
        option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);return stub.listProcessesPaginated(filter, orderBy, pageNumber);}}