Flow Service - Capturing Context ID

Hello,

I would like to capture the Context ID that is assigned to the instance when the flow service is invoked. I can see this value in the wm portal/ integration monitoring.

How do I capture this value from within the flow service?

Thanks!

Look in the webMethods JavaAPI doc or browse in WmRoot services for available functions for capturing the ContextID.

HTH,
RMG

RMG,

Can you be a little more specific? I’m also looking for a way to capture the Context ID. I looked through the WmPublic and WmRoot services, and I looked throught the public Java API but I couldn’t find anything.

Thanks,
Percio

perhaps you should use the “search” button in wMUsers :wink:

[url]wmusers.com

ArnaudW,

Thanks for the suggestion, but the solution proposed in the thread you provided appears to be incomplete or out-dated.

nerdgirl,

I searched Advantage and I found a KB article that appears to have the solution to what we need. The drawback is that the solution relies on methods which are not publicly documented. Here’s the link: [URL=“https://advantage.webmethods.com/advantage?targChanId=kb_home&oid=1612149252”]https://advantage.webmethods.com/advantage?targChanId=kb_home&oid=1612149252[/URL]

There are also a couple of threads in the Advantage Forum that talk about this topic. Just run a search in Advantage for get context id and they should pop up.

  • Percio

Thanks, Everyone for your responses!

Percio,

I ended up combining the results of the posts that you found and created this “getContextID” java service (code below). It may require some refining, but it gets us what we want.

Here are the steps I took:

  1. create the java service “getContextID” (code below)
  2. call the “getContextID” service from the flow service(s) for which I need to identify the contextID. The “parent” or “root” is the value that I want. The “contextID” is the contextID of the instance of the “getContextID” service.
 String[] contextStack;
String contextID = ""; 
String parentID = ""; 
String rootID = ""; 
try{
contextStack = InvokeState.getCurrentState().getAuditRuntime().getContextStack(); 
if (contextStack.length >= 5){ 
rootID = contextStack[0]; 
parentID = contextStack[2]; 
contextID = contextStack[3]; 
} 
else if (contextStack.length >= 2){ 
contextID = contextStack[0]; 
parentID = contextStack[1]; 
rootID = contextStack[contextStack.length - 1]; } 
else if (contextStack.length == 1) { 
contextID = contextStack[0]; 
} 
}
catch(Exception ex){ 
ServiceException sx = new ServiceException(ex);
throw sx; 
}
// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();
IDataUtil.put(pipelineCursor_1, "contextID", contextID);
IDataUtil.put(pipelineCursor_1, "parentID", parentID);
IDataUtil.put(pipelineCursor_1, "rootID", rootID);
pipelineCursor_1.destroy();