webMethods Java service to get Context ID for services
Jun 03, 2014 15:06 0 Comments Development Pia

Context ID’s are required for accessing most of the services in Monitor API's. Unfortunately there are no public flow services provided by webMethods to know the current context ID's.

However, webMethods Java library provide some API's to extract the context ID. Following is the code for extracting the context ID.
Remember that Java flow service coded here will have a unique context ID and the caller service will have another one. So, caller services should take the parent ID as its context ID.

                public static final void getContextIDs(IData pipeline) throws ServiceException {
              
                                String[] contextStack;
                                String currentContextID = "";
                                String currentParentID = "";
                                String currentRootID = "";
                                try{
                                                contextStack = InvokeState.getCurrentState().getAuditRuntime().getContextStack();
                                                if(contextStack!=null)
                                                                if(contextStack.length >=3){
                                                                                currentRootID = contextStack[0];
                                                                                currentParentID = contextStack[1];
                                                                                currentContextID = contextStack[2];
                                                                }else if (contextStack.length>=2){
                                                                                                currentRootID = contextStack[0];
                                                                                                currentParentID = contextStack[1];
                                                                                                currentContextID = currentParentID;
                                                                }else if (contextStack.length>=1){
                                                                                                currentRootID = contextStack[0];
                                                                                                currentParentID = currentRootID;
                                                                                                currentContextID = currentRootID;
                                                                }
                                }catch(Exception ex){
                                                ServiceException sx = new ServiceException(ex);
                                                throw sx;
                                }
                                // pipeline
                                IDataCursor pipelineCursor_1 = pipeline.getCursor();
                                IDataUtil.put(pipelineCursor_1, "currentContextID", currentParentID); // Assuming that caller is looking for its context ID. currentContextID extracted is the context ID for the java service, not the caller service.
                                pipelineCursor_1.destroy();
                }

 

Prev Next
About the Author
Topic Replies (0)
Leave a Reply
Guest User

You might also like

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.


Let`s Connect