1
0
-1

Say I have two instances of TM, TM1 and TM2. Can say a groovy dynamic data service definition in TM1 call a groovy service service definition in TM2?
Thanks

 

Attachments to support the comments below:

screenshot-1.png

screenshot-4.png

screenshot-2.png

screenshot-3.png

  1. Chantal Thomas
    Hi Thamba,
    Systems from Transaction Manager 4.0 - 4.1.5 can kick off a groovy service, but will not be able to get a return value.

    1. T1 and T2 are on separate environments.

    a. T1 has a Groovy Service "RestTest" (refer to screenshot-1 below).
    screenshot-1.png

    b. On T2, create a Groovy Script that calls the rest interface on T1. This can be done via the Groovy API.

    Note:
    - This requires a user credentials to be passed using basic authentication.
    - The user need to have the right permissions to execute the service (refer to screenshot 2 below).
    screenshot-4.png
    This maybe tested using an http GET, although passing the parameters can be passed via an http POST.

    https://{T1 ServerName}/manager/secure/GroovyServiceServlet?sfmServiceName=RestTest&blah=asdasd

    - We can paste this link into the browser to test the behavior (GET).
    - Screenshot 3 below shows the browser requiring a user with the right permission to be entered.
    screenshot-2.png

    - Screenshot 4 below shows the final output from the service.
    screenshot-3.png
    Regards Chantal
  2. Thamba Pathmanathan
    Thanks for this Chantal.
    I have most of this sorted, except for 1b. I am unable to connect to TM, even if the service is on the same instance of TM. The browser justwaits and then times out. Its all good when done from the browser and even works if I put in the URL of another web site say https://google.com/hangouts. Funnily enough, this happens even when calling a dynamic data service, so I am not sure what is going on. The error and event logs say nothing.
    Here is the code I am using

    import org.apache.http.*
    import org.apache.http.protocol.*
    import groovyx.net.http.*
    def tm = new RESTClient('<tm url>')
    tm.auth.basic('<username>', '<password>')
    //tm.headers['Authorization'] = 'Basic '+"<username>:<password>".bytes.encodeBase64()
    /*tm.client.addRequestInterceptor(new HttpRequestInterceptor() {
    void process(HttpRequest httpRequest, HttpContext httpContext) {
    httpRequest.addHeader('Authorization', 'Basic ' + '<username>:<password>'.bytes.encodeBase64().toString())
    }
    })*/
    def res = tm.get(path : '/manager/secure/GroovyServiceServlet?sfmServiceName=<defn name>'){resp, json ->
    println resp println json
    }
  3. Chantal Thomas
    Hi Thamba,
    Unlike a Groovy Service, a Dynamic Data call is not secured with a users credentials.

    There is protection around these calls where the form will pass a sfmRequestKey.
    Note if the service parameter Test Mode = true then it will bypass these security checks.
    Cheers
    Chantal
  4. Thamba Pathmanathan
    Hello Chantal,
    I was already aware that dynamic data service doesn't require authentication and instead uses the request key from the request.
    What I was trying to get at was that even calling a dynamic data service from the groovy console doesn't work.

    I am suspecting that it is with the way that the network has been setup on the server. If I put in the URL to the same TM, it times out, but if I change it to localhost, I get an error saying that the certificate doesn't match name.

    Anyway, thanks for your help :). We will just put it in the too hard basket for now.
  5. Thamba Pathmanathan
    Thanks Chantal.
    This should save me the trouble offinding a form to get the request key from :)
CommentAdd your comment...

1 answer

  1.  
    1
    0
    -1

    Attachment to support comment below:

    testMode Service Parameter.png

    1. Chantal Thomas
      Hi Thamba,
      Not sure if this helps, but to call a dynamic data service from the groovy console, set the service parameter testMode (screenshot below) to true .
      testMode_Service_Parameter.png
      Note: only do this is a DEV environment. Once you have finished testing in the groovy console, change the service parameter testMode back to false.
      Regards
      Chantal

    CommentAdd your comment...