Configurable service invoke

Imagine you have to code a bunch of services that all share the same skeleton with only a small changing part containing the specific business logic.

Example for a Web Service:

  1. Parse SOAP request
  2. Validate request
  3. Specific logic to create response --THIS is what we really care about
  4. Validate response
  5. Build SOAP response

Obviously, one doesn’t want to replicate code all around as this quickly become unmaintable and anyway, redundancy is not good.

To solve this I wrote a small Java service that works as a configurable Invoke: it gets in input the full path to a service to be invkoked and it calls it.


INPUT: full path to the service to invoke

CODE
// Read pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
String serviceToInvoke = IDataUtil.getString( pipelineCursor, “service” );
pipelineCursor.destroy();
// Get service to call
int commaIndex = serviceToInvoke.lastIndexOf(“:”);
String nameSpace = serviceToInvoke.substring(0, commaIndex);
String serviceName = serviceToInvoke.substring(commaIndex + 1);
// Call the service
IData resultPipeline = null;
try
{resultPipeline = Service.doInvoke(nameSpace, serviceName, pipeline);}
catch(Exception e)
{
throw new ServiceException(e);
}
pipelineCursor.destroy();

Then I wrote a skeleton service doing all the common stuff that would get the specific service to call in parameters and use the Java service above to call it (Hope this is clear…)

This is all working great and I now have several skeletons for various type of services I have to implement BUT there is an issue: this forces the code to contain hard-coded service path all around which makes it REALLY hard to track dependencies.
So I’m now wondering whether there is a better way to do this… Is there maybe a way to tell Developer that a string actually refers to a service so it uses it when checking depends and dependencies

Thks