Can you invoke a service in PreProcessor?

This thread was migrated from an old forum. It may contain information that are no longer valid. For further assistance, please post a new question or open a support ticket from the Customer Support portal.

So I have a session token I'm passing around as part of the header. There might be a case wherein the token expires or is not present. Can I invoke the service that creates the token to be passed as part of the session?

Hi @Thomvs White​ , In PreProcessor you can check the condition for session token and stop the service call. Please find the sample code to check

function fun2(){

if(serviceInputParams.get('seesiontoken') === undefined)

{

return false; //service call doesn't happen

}

else

{

return true; // service call happens

}

}fun2();

So if the PreProcessor returns false, the service call won't proceed further.

This is in the PreProcessor of the service that generates the token, right?

No, this code should be part of preprocessor of the services that consume the session token i.e. session token as an input param.

I see. But what I need is to generate that token to be able to continue.

Hi @Thomvs White​ preprocessor only helps you to manipulate the request params before executing the service. For more info, http://docs.kony.com/konylibrary/konyfabric/kony_fabric_user_guide/Content/Java_Preprocessor_Postprocessor_.htm

@Thomvs White​ You can have a check at the side side itself instead of depending on the preprocessor.

  1. If the check is only to check if token exists, have the check at the client JS code itself.
  2. If you are aware of the expiry time of token, make use of JS API's to check if it is still valid.
  3. You should be able to make a serivce call using httpClient inside the execute method, but I would not recommend this.