I’ve found local-variable-holder style programming (like the pattern that Customware have documented) necessary only once… this was for services that received arbitrary HTML form variables posted in. Since webMethods allows multiple variables to have the same name, there was the risk of user-posted variables colliding with internal variables and affecting control flow. To minimise this risk, I created a local holder variable and “indented” local variables under it. For eg:
_UniqueName
- Allowed
- ErrorMsg
... etc
To remove any user-variables named ‘_UniqueName’, I also used a simple Java service to remove specified variables from the pipeline (this is opposite to clearPipeline which preserves specified variables and clears the pipeline).
// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
String[] filter = IDataUtil.getStringArray( pipelineCursor, "filter" );
pipelineCursor.destroy();
if (filter == null)
{
throw new ServiceException("No variable names to filter out were passed in");
} else {
for (int i = 0; i < filter.length; i++) {
String filterMePlease = filter[i];
while (pipelineCursor.first(filterMePlease)) {
pipelineCursor.delete();
}
}
}
#Flow-and-Java-services#Integration-Server-and-ESB#webMethods