Checking a hard-coded value in a service through code

What product/components do you use and which version/fix level are you on?

WM designer 10.1

What are you trying to achieve? Please describe it in detail.

Hi everyone, I’m trying to check using code if the hard-coded value in the variable called ‘function’ correspond to the service path.

I already started the code using the following logic:

  • Gathers the package info
  • Take the services names
  • Get the references of the services, one at a time, via loop
  • If the service pub.flow.DebugLog is one of the referenced services, enters the condition to check the variable ‘function’

The problem is that using the getReferences is that just returns the names of the services and I need to check a value within the service pub.flow.DebugLog. It is possible to do it?

Best Regards everyone, take care!

Oi Joao,

Is it possible to do it? Yes, everything is possible. :slight_smile: It depends on how much effort you want to put into it as there are different options.

If you’re looking for an almost pure Flow option, then I’m assuming you’re using the services under WmRoot/wm.server.ns.dependency, yes? If so, then first a standard disclaimer: these are not meant for public use so use them at your own risk.

Now, if you’re interested in finding services that invoke pub.flow:debugLog, why not use wm.server.ns.dependency:getDependent instead of :getReferences? If you call :getDependent and pass in node = ‘pub.flow:debugLog’, it will return a document list called referencedBy that has a list of all the nodes that invoke pub.flow:debugLog. Not only that, inside referencedBy, you will find a string list called paths, which is the unique path to the pub.flow:debugLog invocation inside that service. You can loop over referencedBy, extract just the node name from referencedBy.name (i.e. remove the package name from it) and have an inner loop that loops over paths: for each node and path, call wm.server.ns.dependency:getPathNodes and it will give you the details of that invocation.

Here’s the tricky thing though and why I said “almost pure Flow option”: nodeList returned by getPathNodes is not really a document list. In your case, it will be an object of type com.wm.lang.flow.FlowInvoke so parsing that function name automatically might be tricky with pure Flow. At this point, you may want to pass the object to a Java service to extract the information you want out of the FlowInvoke object.

If you’re not interested in a pure Flow implementation, your other option is to just write a Java service from the get-go that does all the things we’ve talked about so far. As you can imagine, all of the WmRoot Java services are calling Java methods in the background so nothing prevents you from calling them yourself as long as you understand they are not supported.

Last but not least: if you’re not interested in messing with undocumented APIs and you’re comfortable writing shell scripts, you could write a bash or Powershell script that loops over all flow.xml files in your packages, looking for an INVOKE tag where the attribute SERVICE equals pub.flow:debugLog. Then, inside that INVOKE tag, you’re looking for a MAP/MAPSET element that sets the function field. Here’s a potential XPath to get you that element:

//INVOKE[@SERVICE=‘pub.flow:debugLog’]/MAP[@MODE=‘INPUT’]/MAPSET[@FIELD=‘/function;1;0’]/DATA/Values/value[@name=‘xml’]

Hope this helps,
Percio

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.