I want to get the calling service from the stack

Hello,

Could anyone help me I have written a java code in which it gets the calling service from the stack, But I tried to run the service it is giving out put as null object as shown in the screen shot.

Below is the code

String callingServiceName = null;
Stack callStack = InvokeState.getCurrentState().getCallStack();
int size = callStack.size();

	//   Thread t = Thread.currentThread();
	//   com.wm.app.b2b.server.ServerThread st = (com.wm.app.b2b.server.ServerThread)t;
	//   java.util.Stack stack = st.getState().getCallStack();
	   //java.util.Stack stack = InvokeState.getCurrentState().getCallStack();
	
	   // The callstack must have three elements to be able to return a CallingServiceName
	   if (size >= 2) {
	      NSService myService = (NSService) callStack.elementAt(size-2);
	      callingServiceName = myService.getNSName().getFullName();
		   
		   //callingServiceName = stack.elementAt(stack.size()-3).toString();
	      //callingServiceName = stack.elementAt(stack.size()).toString();
	   }
	
	// pipeline
	IDataCursor pipelineCursor = pipeline.getCursor();
	IDataUtil.put( pipelineCursor, "callingServiceName", callingServiceName );

}
Calling.txt (993 Bytes)

If you just run this service you wrote, you will get null, because there is no calling service at all. You need another service to call your service.

The service that you are referring is already part of WmPublic.What is your wM version?