Skip to Content
0

Payload Logging with Groovy Script: java.lang.NoSuchMethodException: No signature of method

Sep 11, 2017 at 06:28 PM

356

avatar image

Hello,

I am trying to log payloads in an integration flow using the following code in a groovy script step:import com.sap.gateway.ip.core.customdev.util.Message;

import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message) {
    def body = message.getBody(java.lang.String) as String;
    def messageLog = messageLogFactory.getMessageLog(message);
    if(messageLog != null){
        messageLog.addAttachmentAsString("Payload", body, "text/plain");
     }
    return message;
}

When executing the integration flow the following error appears in monitoring:

Message processing failed.

java.lang.NoSuchMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.Log message payload() is applicable for argument types: (com.sap.gateway.ip.core.customdev.processor.MessageImpl) values: [com.sap.gateway.ip.core.customdev.processor.MessageImpl@5b15080c]

Does anyone have an idea what is causing this or if there is a problem in the code itself?

Thank you for your help!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

avatar image
Former Member Sep 12, 2017 at 01:03 AM
0

Hi Florian,

Can you please post a screenshot which shows the details of your Groovy script artifact?

This piece of code works for me:

import com.sap.gateway.ip.core.customdev.util.Message;
def Message processData(Message message) {
    def body = message.getBody(java.lang.String) as String;
    def messageLog = messageLogFactory.getMessageLog(message);
    if(messageLog != null){
        messageLog.setStringProperty("Logging#1", "Printing Payload As Attachment")
        messageLog.addAttachmentAsString("ResponsePayload1:", body, "text/plain");
     }
    return message;
}

Regards,

Prasanna


Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hello,

thank you for your reply. To be on the safe side I have copied your code to my Groovy Script artefact, but still get the same error.

Here are the screenshots:

Thank you!

0
Former Member

Make sure you leave the field Script Function blank, as per my earlier screenshot.

0
Jens Schwendemann Sep 12, 2017 at 06:56 AM
0

Is there really a Need for logging the payload with Groovy script? I'm quite new to SCPI, so be lenient with me, if you happen to be able to reproduce the wanted message at any time, traceing might be easier, especially since it will persist payload at any message step. Backdraw would be, that it is only on for 10 minutes, so no Long term logging there.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Well there are two reasons why I would like to trace payload in the integration flow in the test environment:

1. Reproducing of the message is not easily possible on sender side

2. WebUI should be the central point of access for development / monitoring

Otherwise I agree with you.

1