Advertisement

Responsive Advertisement

webMethods Java Code to get the Current Package and Service Name

Hello EveryBody ,

I am going to present to you a simple java code to get the current package name and the service name. Here is the simple java code.

import com.wm.data.*;
import com.wm.util.Values;
import com.wm.app.b2b.server.Service;
import com.wm.app.b2b.server.ServiceException;
import com.wm.lang.ns.NSName;
import com.wm.lang.ns.NSNode;
import com.wm.lang.ns.NSPackage;
import com.wm.lang.ns.NSService;

public final class getCurrentPackageName_SVC

{

/**
* The primary method for the Java service
*
* @param pipeline
*            The IData pipeline
* @throws ServiceException
*/
public static final void getCurrentPackageName(IData pipeline)
throws ServiceException {
NSService callingServiceName=Service.getCallingService();
NSName serviceNSNode=callingServiceName.getNSName();
String serviceName=serviceNSNode.getFullName();
NSPackage nsNodePackageName=callingServiceName.getPackage();
String packageName=nsNodePackageName.getName();

// pipeline

// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
IDataUtil.put( pipelineCursor, "packageName", packageName );
IDataUtil.put( pipelineCursor, "serviceName", serviceName );
pipelineCursor.destroy();

}

// --- <<IS-BEGIN-SHARED-SOURCE-AREA>> ---



// --- <<IS-END-SHARED-SOURCE-AREA>> ---
}


If you want to know the package name of a particular node (for e.g. service,tiggers,javaservices etc) , then you can use the following code snippet to get the package name of that particular asset :-

packageName=Namespace.current().getNode(nodeName).getPackage().getName();

Please note that using the above method from the namespace method , you have to pass the nodeName , here the nodeName is the string of the service or any other asset which you are passing.

Also note that the above method will not work on interfaces (i.e. folders and subfolders) i.e. if you pass any folder/sub folder name in the nodeName , it will throw exception.


Enjoy Reading , If you have any Question related to webMethods please comment below , I will try to answer the questions.Please Subscribe for latest update on the blogs

Post a Comment

2 Comments

  1. Videos by Jay Ganapathi on Vimeo - Videodl.cc
    Find videos related to Jay Ganapathi, youtube mp3 an indian filmmaker, on Videodl.cc. Watch short videos related to Jay Ganapathi, an indian filmmaker, on Videodl.cc.

    ReplyDelete