Project and Portfolio Management Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

PPM Proposal Workflow transition via Web service

Highlighted
ArunKr
Super Collector

PPM Proposal Workflow transition via Web service

Hi,

I'm trying to transition a workflow step of a Proposal request type via web service but the function is not working.

Calling the executeWFTransitions function from main()

 

    	final String trans = "Propose";
    	final String reqId = "58813";
        executeWFTransitions(ppmURL, reqId, trans);	

 

 

 private void executeWFTransitions(final String serviceURL, final String requestId, final String transition)
            throws Exception
    {

        // construct the Identifiers
        final Identifier receiverId = Identifier.Factory.newInstance();
        receiverId.setId(requestId);

        // get Webservice handle
        final DemandServiceStub stub = new DemandServiceStub(this.ctx, serviceURL);

        // Construct message to send
        final ExecuteWFTransitionsDocument inDoc = ExecuteWFTransitionsDocument.Factory.newInstance();
        final ExecuteWFTransitionsDocument.ExecuteWFTransitions exec = inDoc.addNewExecuteWFTransitions();
        exec.setReceiver(receiverId);
        exec.setTransition(transition);

        // Invoke web service
        final ExecuteWFTransitionsResponseDocument outDoc = stub.executeWFTransitions(inDoc);
        
        // Process the return request
        final String returnCode = outDoc.getExecuteWFTransitionsResponse().getReturn();
        System.out.println("Workflow transition was successful. Return code: " + returnCode);

    }

 

It gives the following error when I try with Demand Module example:

Exception in thread "main" org.apache.axis2.AxisFault: Internal error has occurred while calling PPM Web Service. Contact PPM Center support with the detailed information if the problem persists. (KNTA-11186) Details: null; nested exception is:
java.lang.NullPointerException
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:271)
at org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:202)
at com.mercury.itg.ws.dm.client.DemandServiceStub.executeWFTransitions(DemandServiceStub.java:1432)
at examples.dm.DMProposalExcel.executeWFTransitions(DMProposalExcel.java:380)
at examples.dm.DMProposalExcel.setWFTrans(DMProposalExcel.java:105)
at examples.dm.DMProposalExcel.main(DMProposalExcel.java:96)

 

If I comment last 3 lines of code: (ExecuteWFTransitionsResponseDocument) and do not get return result of the workflow transition, it doenst show any error but the workflow doesnt move to desired step. there is not workflow action taken by web service.

 private void executeWFTransitions(final String serviceURL, final String requestId, final String transition)
            throws Exception
    {

        // construct the Identifiers
        final Identifier receiverId = Identifier.Factory.newInstance();
        receiverId.setId(requestId);

        // get Webservice handle
        final DemandServiceStub stub = new DemandServiceStub(this.ctx, serviceURL);

        // Construct message to send
        final ExecuteWFTransitionsDocument inDoc = ExecuteWFTransitionsDocument.Factory.newInstance();
        final ExecuteWFTransitionsDocument.ExecuteWFTransitions exec = inDoc.addNewExecuteWFTransitions();
        exec.setReceiver(receiverId);
        exec.setTransition(transition);

        System.out.println("Workflow transition was successful.");

    }

I get following error if I try Project example:

Starting Project Service tests...
log4j:WARN No appenders could be found for logger (org.apache.axiom.om.util.StAXUtils).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Test workflow transition ...
Exception in thread "main" org.apache.axis2.AxisFault: The project corresponding to project name Proposal WS Test 4 does not exist.
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:271)
at org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:202)
at com.mercury.itg.ws.pm.client.ProjectServiceStub.executeWorkflowTransition(ProjectServiceStub.java:2731)
at examples.pm.PMCreateCoreProject.executeWorkflowTransition(PMCreateCoreProject.java:200)
at examples.pm.PMCreateCoreProject.main(PMCreateProject.java:127)

Both DM/PM example given in the toolkit is not working for Proposal request

Could someone help me how to resolve this error? Is there any logs which I can refer to find the root cause? Appreciate your help. thanks.

 

2 REPLIES
TorstenNeumann
Super Collector

Re: PPM Workflow transition via Web service

I think what might be missing in the code is the WS-Security with the username and password - you need to check your Axis2 configuration context. My Axis2 client context has this configuration for the outflow security:

    <parameter name="OutflowSecurity">
      <action>
        <items>UsernameToken Timestamp Encrypt</items>
        <user>admin</user>
        <passwordCallbackClass>de.tncon.ppmutil.core.security.PasswordCallbackHandler</passwordCallbackClass>
        <passwordType>PasswordText</passwordType>
        <encryptionParts>{Element}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}UsernameToken</encryptionParts>
        <encryptionUser>ppmservice</encryptionUser>
        <encryptionPropFile>client.properties</encryptionPropFile>
      </action>
    </parameter>

After creating the stub, add this code:

			WSSecurityUtil.setWSSecurityUsername(ctx.getAxisConfiguration(), stub, username, password);

Where the WSSecurityUtil class contains these methods:

	public static void setWSSecurityUsername(AxisConfiguration ctx, Stub stub, String username) {
		AxisConfiguration axisConfig = ctx.getAxisConfiguration();		
        Parameter param =  
        axisConfig.getParameter(WSSHandlerConstants.OUTFLOW_SECURITY);
        if (param != null) {
            OMElement action = param.getParameterElement();
            Iterator children = action.getChildElements();

            if (children == null) return;

            Object o = children.next();					
            children = ((OMElement) o).getChildElements();
            while (children.hasNext()) {
                OMElement child = (OMElement) children.next();					
                if (WSHandlerConstants.USER.equals(child.getLocalName())) {
                    child.setText(username);
                }	
            }
        }
	}

	public static void setWSSecurityUsername(AxisConfiguration ctx, Stub stub, String username, String password) {
		PasswordStore.getInstance().addPassword(username, password);
		setWSSecurityUsername(ctx, stub, username);
	}

Now the only missing part is the PasswordCallbackHandler that the Axis2 framework calls to get the password for the given user; for testing, you could just hard code the password for the user you use to connect to HP PPM (no need for the PasswordStore class).

public class PasswordCallbackHandler implements CallbackHandler {

	private static final Logger logger = LogManager.getLogger(PasswordCallbackHandler.class);

	public void handle(Callback[] callbacks) throws IOException,
            UnsupportedCallbackException {

        for (int i = 0; i < callbacks.length; i++) {
            WSPasswordCallback callback = (WSPasswordCallback)callbacks[i];
                               
            // obtain password from password store.
            String username = callback.getIdentifier();
            String password = PasswordStore.getInstance().getPassword(username);
      
            // set the obtained password (or hard-code for testing here)
            callback.setPassword(password);
            
            logger.debug("Returning password '" + password + "' for username '" + username + "'");
        }
    }

}

Let me know if this helps.

ArunKr
Super Collector

Re: PPM Workflow transition via Web service

Thanks for your assistance..

I have already updated my username in client-axis2.xml and password in PasswordCallbackHandler.java

Other functionalities like create request, update request fields delete request are working good but only workflow transition is not working. 

Does both functionalities looks for the Is user/password at different places?

I do not have below code in WSSecurityUtil.java and I get error in PasswordStore as no class file found.

 

 public static void setWSSecurityUsername(AxisConfiguration ctx, Stub stub, String username, String password) {
		PasswordStore.getInstance().addPassword(username, password);
		setWSSecurityUsername(ctx, stub, username);
	}

 

Am I missing anything else here? Again thanks for your reply.

 

//Add this to "OnDomLoad" event