Forum Discussion

h_ixon's avatar
h_ixon
Occasional Contributor
16 years ago

[Groovy] Get operation from a request

Hello,

I have some request with different operation. I have some mockService with many operation on my computer.

When i receive a request on my mockService i want to log the operation name of this request.

The script must be written on "OnRequest Script" on my mockService.

I try log.info mockRequest.getSoapAction() but there is no value (blank log).

Someone can help me ?

Thank's

1 Reply

  • h_ixon's avatar
    h_ixon
    Occasional Contributor
    Hy,

    I have found a solution to my problem. I post it below. Thank's


    def opeList = mockRunner.mockService.getMockOperationList()
    def operation = ""
    // Check if an operation name appear on my request, if it's true the variable operation take is updated.
    opeList.eachWithIndex() {
    key, value ->
    if ( requete =~ /\b${key.name}\b/ ){
    operation = "${key.name}"
    //log.info "operation = " + operation
    }
    }