IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.



#Automation


#Applicationintegration
#webMethods
#Integration
 View Only
  • 1.  Get service name at runtime

    Posted 10/05/06 03:30 PM

    Hi

    Is it possible to get the “root” service name that was invoked, at runtime?
    E.g. to get “common.utils:fooService”.

    Example:
    If a have tree services; serviceA, serviceB & serviceC.
    serviceA is first invoked and serviceB is then called from serviceA and serviceC is then called from serviceB.
    Can I from serviceC somehow find out that serviceA was the first service that was invoked in the execution chain?

    Regards
    Mikael


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 2.  RE: Get service name at runtime

    Posted 10/05/06 03:54 PM

    This uses unpublished methods so may break in future versions. Use at your own risk.

    [highlight=java]getServiceStack(IData pipeline)
    {
    IDataCursor idc = pipeline.getCursor();
    java.util.Stack callStack = com.wm.app.b2b.server.InvokeState.getCurrentState().getCallStack();

    // Note that we allocated one less than what the stack has
    // to omit this service from being in the list
    String[] serviceStack = new String[callStack.size()-1];
    
    for(int j=0,i=serviceStack.length; --i>=0;j++)
    serviceStack[j] = ((com.wm.lang.ns.NSService)callStack.elementAt(i)).toString();
    
    IDataUtil.put(idc, "serviceStack", serviceStack);
    idc.destroy();
    

    }[/highlight]

    This reverses the order of the stack. Depending on your preference, you might want to change the for loop to keep the order as returned by getCallStack.

    HTH


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 3.  RE: Get service name at runtime

    Posted 10/07/06 02:47 AM

    Nice job! I tried your code and it worked flawlessly.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods