1
0
-1
  1. what does invokeservice() do here and what is its return type?

ServiceLocator.getServiceForName("service name").invokeService()  

2. how can the same functionality can be achieve in fluent groovy service?

    CommentAdd your comment...

    1 answer

    1.  
      2
      1
      0
      1. Legacy method to invoke the service with the specified name. The return type is whatever the service returns.
      2. In the Fluent API you use the ServiceInvoker class.

      I recommend you take 5 mins to read through the Transact Fluent API Reference in detail.

      1. umakanta dalai

        Hi Ben

        I have two services

        a. 1st Service name: Service1  (name is same in service definition) - this is a fluent groovy service

        b. 2nd Service name : Service2 -this is a fluent dynamic data service

        when I call service1 inside service2, I am getting bellow error. Can you please help where I am wrong?

        java.lang.RuntimeException: Service definition not found: Service1, null, null  com.avoka.tm

         

        Attached the code below:

        1)

        Service1 {

        String invoke(SvcDef svcDef, HttpServletRequest request, User user, Map params) {

        return JsonOutput.toJson([  token :  "from service1"  ])

           } }

         

        2)

        FluentDynamicData {

          String invoke(SvcDef svcDef, Txn txn, HttpServletRequest request, User user) {

          def result = new ServiceInvoker().setServiceName("Service1").invoke();

                logger.info "result: " +  result            

        return result

            } }

      2. Ben Warner

        All fluent services are scoped to an organization, so you need to identify the organisation by setting the client code as detailed in the documentation for the ServiceInvoker class.

        Client code can be obtained on the Organizations page under the Forms menu.

      3. umakanta dalai

        Thanks Ben, after I set the client code above error is gone. But now I am getting below error

        java.lang.IllegalArgumentException: could not resolve method invoke() for args: []  com.avoka.core.groovy.runtime.SecureStaticGroovyTask.call(SecureStaticGroovyTask.java:213)

        I tried with new new ServiceInvoker(svcDef) also getting same error.

        Any further suggestion will be appreciated.

         

      4. Ben Warner

        Hey Umakanta, apologies I should have advised to use the GroovyServiceInvoker class. If you change ServiceInvoker to GroovyServiceInvoker it should now work.

        Regards, Ben.

      5. umakanta dalai

        Thanks! lot Ben - worked for me with GroovyServiceInvoker 

        Just to have clarity, when to use GroovyServiceInvoker  and when to use ServiceInvoker ?

      CommentAdd your comment...