A java service that takes ‘svcName’ as input and then invokes that service using Service.doInvoke
Parent service that performs a lookup against a table to get ‘svcName’ and then calls the java service with ‘svcName’ as input.
Here’s what I am looking for -
Since ‘svcName’ is read from a db table (without going into details of why it is in a table and how it gets there), I want to check - whether or not service exists and if does, whether or not it follows an IS specification. If the service ‘svcName’ does not follow the specification - the flow needs to fail. Is there a straight forward way to do this? I couldn’t find a built-in service that does this - is there one?
Please Note: This sample code uses classes that are not documented and use by wM customers is not supported by wM. Future release may break this code.
public static final void serviceExists(IData pipeline)
throws ServiceException
{
IDataCursor idc = pipeline.getCursor();
String nsNameStr = IDataUtil.getString(idc, “nsname”);
com.wm.lang.ns.NSName nsname = com.wm.lang.ns.NSName.create(nsNameStr);
com.wm.app.b2b.server.ns.Namespace namesp = com.wm.app.b2b.server.ns.Namespace.current();
IDataUtil.put(idc, “exists”, “”+namesp.nodeExists(nsname));
idc.destroy();
}
This can verify the existence of any namespace node, not just services.
Thanks for your reply Rob and the java service… Actually a Service.doInvoke would itself return an error if the service does not exist - it is the latter part that I am more importantly looking for, ie whether the service complies to the IS specification in question.
Well I haven’t found anything that wouldn’t be more work than I want to invest right now. Plus, the scheme used to verify compliance should depend a little bit on how strict the verification should be. For example, do you want the names and types to match? Or just the names? Check just the top-level fields or enforce record structures too?
A high-level approach might be:
A service that accepts the service name to invoke and the service specification to check against.
Retrieve the NSService object from the namespace. Get the assigned specification (NSSpecification), if it has one. If the name of the specification configured for the service matches the input spec name, then it complies.
If the service doesn’t have a spec, retrieve its signature (NSSignature). Retrieve the signature of the specified service spec too.
Get the input record (NSRecord) for both signatures. Compare them in a way that makes sense for what you want to verify (names of all the fields match, types of all the fields match, recursively check, etc.). Do the same for the output records.
That last step will be the most work. I haven’t found a class/method/service that will compare the structure of two NSRecords. It might exist somewhere but I’ve had no luck finding it so far.
I appreciate the time you invested to dig out those helpful hints - I was wondering if anyone has implemented such a thing already - apparently not. The direction which you have pointed me in, is where I intend to explore further myself.
I recommend you to use this service as regression test against DB values instead of checking all the time at runtime, but if you see as a need (DB values changes frequent) you can use it as runtime: