Project and Portfolio Management Practitioners Forum
cancel

Consume external web service using PPM command or execute any java utility using PPM commands

Highlighted
Utkarsh_Mishra
Acclaimed Contributor.

Consume external web service using PPM command or execute any java utility using PPM commands

As this has been asked in several thread, so put it together in single post.

 

In order to consume external web services or deploy your own java utility and consume it via execution step, then you can follow these steps.

 

Also instead of execution step, you can also call it via PPM report commands and can schedule it as a Job.

 

----------------------------------------------------------------------------------------------------------

 

First Create a Jar file of your solution, you can use any Java IDE and build it.

 

Once Jar file is build copy the the file and libraies in /web-inf directory or create a new direcotry in <PPM_ROOT>

 

Now create a Command Execution step in the workflow. And the do as follow.

 

  1. First Identify the JAVA_HOME path as it will be needed in the command
  2. Location where your jar file is store
  3. Finally make sure that the environment used in the command is working fine i.e check transfer and connection protocol

 

ksc_connect_dest_server DEST_ENV="KINTANA_SERVER"
echo Running..
C:/Java/jdk1.6.0_16/bin/java -jar "C:\itg\webservices\my_project\PPM-CUSTOM.jar"
ksc_exit

 ------------------------------------------------------------------------------------------------------------

 

Another way ( below example is for Windows system, you can modify it for Unix)

 

  1. Create your project jar and then copy it in <PPM_ROOT>; say for example

     c:/itg/custom_java

    Also make sure to copy the lib folder (used by your jars)

  2. Now within custom_java folder create .bat file (name = run.abt) and put the contnent as
    Note: MY_PATH is your Java_home

    SET MY_PATH="C:\Program Files (x86)\Java\jre1.6.0_03\bin"
    
    cd %MY_PATH%
    
    %dir%
    
    %MY_PATH%\java -jar "D:\PPM_CUSTOM\ppm_http\PPM_HTTP.jar"

     

  3. Now call this .bat file in ppm command execution step


ksc_connect_dest_server DEST_ENV="KINTANA_SERVER"
echo Running..
cd c:/itg/custom_java
run.bat ksc_exit

 

Cheers..
Utkarsh Mishra

-- Remember to give Kudos to answers! (click the KUDOS star)
5 REPLIES
parabkir
Valued Contributor.

Re: Consume external web service using PPM command or execute any java utility using PPM commands

Hi Utkarsh,

 

Thank you so much for such a detailed explaination.

 

My PPM instance is UNIX box.

 

I have couple of questions:

 

1) I understand that we can create a JAR file on external server and copy it to some directory on PPM app server.

I am not too familiar with JAVA. So I am confused here. Do we need to keep the JAR file on the outside serevr and connecting to it first and then executing JAR file? Or we can just copy it on PPM server and execute it?

 

2) While consuming the external web service, I want to pass a parameter to it (Request ID). Is it possible to do it if we call a command in an execution step? This execution step will in turn call the Shell script or JAR file.

 

Any other caution to be taken while doing this on a UNIX box?

 

Appreciate your guidance.

 

Thanks,

Kiran 

Thanks,
Kiran Parab
Utkarsh_Mishra
Acclaimed Contributor.

Re: Consume external web service using PPM command or execute any java utility using PPM commands

There is not much difference When u are on Unix, you just need to make sure that your JRE/JDK path is correct.


Secondly you might need to conver .bat file to shell script.

 

Regarding your questions.

 

  1. As long as you are specifying the JAVA path in your command or in your script then you can keep your file any where in PPM server.

    Example
    C:/Java/jdk1.6.0_16/bin/java -jar "C:\itg\webservices\my_project\PPM-CUSTOM.jar"
    here we are specifically specifying the java path.  Same is the case when we call it via batch or shell script

  2. You can pass parameter like (for passing token I would recommend to direclty call service in command, rather than calling it from shell/batch script)

    Using Script, if there are mulitple parameters the you can use "*"

    SET MY_PATH="C:\Program Files (x86)\Java\jre1.6.0_03\bin"
    
    cd %MY_PATH%
    
    %dir%
    
    %MY_PATH%\java -jar "D:\PPM_CUSTOM\ppm_http\PPM_HTTP.jar" "<YOUR_PARAMETER1>" "<YOUR_PARAMETER2>"... (so on)

     Using Command

    ksc_connect_dest_server DEST_ENV="KINTANA_SERVER"
    echo Running..
    C:/Java/jdk1.6.0_16/bin/java -jar "C:\itg\webservices\my_project\PPM-CUSTOM.jar" "[REQ.REQUEST_ID]" "[REQD.P.TOKEN]"
    ksc_exit

     

Cheers..
Utkarsh Mishra

-- Remember to give Kudos to answers! (click the KUDOS star)
parabkir
Valued Contributor.

Re: Consume external web service using PPM command or execute any java utility using PPM commands

Thanks Utkarsh! I am going to try this today.

 

Meanwhile, I have an additional requirement of capturing result of the web service.

It will be in terms of 'Success' or 'Failure'. If the web service was successfully run then the command should return

'Success' otherwise 'Failure'.

 

Any hints for this?

 

Thanks,

Kiran

Thanks,
Kiran Parab
AlfredoMonasi
Honored Contributor.

Re: Consume external web service using PPM command or execute any java utility using PPM commands

I would go the safest way, create a field, depending the result of your WS update that field with PPM Web Services with the result you need. After that run the cache manager and evaluate the field.

Utkarsh_Mishra
Acclaimed Contributor.

Re: Consume external web service using PPM command or execute any java utility using PPM commands

As suggested by Alfredo you can use DB to store result, else

 

if you are using ksc_connect_dest_server command, it is capable to return success or faliure. In event of any exception or the web service face any issue it will return FAILURE, so you can trigger a notification in workflow.

 

Also what ever you print in system console in Java it will be captured in Command logs, so you can use it for debugging.

 

 

Apart from this, just in case if you want to have more debugging capabilitites, you can use log4j api and configure smtp logging. So you can maintain seperate logs for your integration (for additional monitoring) and can use logger.error to send notification in case of any exceptions.

Cheers..
Utkarsh Mishra

-- Remember to give Kudos to answers! (click the KUDOS star)