How can I get the current Name space of the service

I need to know how to do 2 things within a service.
extract the current package name of the current service.
extract the full Namespace of the current service.


Try using Service.getServiceEntry()



An alternative approach is here. This is some code I was playing around with after someone else posted it.
Its examines the calls stack to get the caller service.

IDataHashCursor curs = pipeline.getHashCursor();
String caller = “”;

Thread t = Thread.currentThread(); st = (;
java.util.Stack stack = st.getState().getCallStack();

caller += stack.elementAt(0).toString();

catch (Exception e)
caller = new String("—non-determinable—");
curs.insertAfter(“serviceName”, caller);

Bert, you can use the webMethods API to get this information. I don’t have it in front of me right now, but you can look at the API from the Developer tool.

Go to “Help > webMethods API” and look at the ServiceAPI class. There is a method called getCallingPackage and another method (whose name escapes me right now…) called something like getService. Reading the API, it will be clear what each method does. However, I am assuming that you are comfortable enough with Java to read an API. If not, just speak up and we can get some code posted here for you.

For curiousity’s sake, what is your business problem?

To correct my prior post:

getCallingService() – a member of the class. Returns the service that invoked the service from which getCallingService is being executed.

getPackageName() – a member of the class. Returns the name of the current package directory.


how can I use getCallingService() to display the calling service in a variable called serviceName?

Here you are (at v4.6):
String serviceName = null;

NSService myService = (NSService) Service.getCallingService();
serviceName = myService.getNSName().getFullName();

// pipeline out
IDataCursor pipelineCursor = pipeline.getCursor();
IDataUtil.put(pipelineCursor, “serviceName”, serviceName);

import com.wm.lang.ns.NSService