Hello,
I am using groovy scripts for logging in different steps. Since I do not want to copy the scripts repeatedly and change just two values, I thought there should be the possibility to use parameters.
Here is the script I want to use:
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message logpayload(Message message, String nameOfAttachment, String mimeType ) {
def payload = message.getBody(String.class);
def messageLog = messageLogFactory.getMessageLog(message);
messageLog.setStringProperty("Logging", nameOfAttachment);
messageLog.addAttachmentAsString(nameOfAttachment, payload, mimeType);
return message;
}
I configurate it like this:

However, when I run it I get the following exception. Does anyone have an Idea how I could solve this issue?
java.lang.NoSuchMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.logpayload(message, "FlatFile.txt", "text/plain")() is applicable for argument types: (com.sap.gateway.ip.core.customdev.processor.MessageImpl) values: [com.sap.gateway.ip.core.customdev.processor.MessageImpl@737f25ed]
Thank you,
Florian
Request clarification before answering.
Hey Morten,
thank you very much. With the void function it didn't worked for me. So thats the code how it works for me.
import com.sap.gateway.ip.core.customdev.util.Message
import java.util.HashMap
def Message logInitialFlatFile(Message message) {
message = logPayload(message, "initialFlatFile.txt", "text/plain")
}
def Message logInitialXml(Message message) {
message = logPayload(message, "initialXML.xml", "application/xml")
}
def Message logPayload(Message message, String nameOfAttachment, String mimeType ) {
def payload = message.getBody(String.class);
def messageLog = messageLogFactory.getMessageLog(message)
messageLog.setStringProperty("Logging", nameOfAttachment)
messageLog.addAttachmentAsString(nameOfAttachment, payload, mimeType)
return message
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Florian. Glad you could use it. As for void, use
def logPayload(Message message, String nameOfAttachment, String mimeType )
instead, and it should work. That requires changing the code as for the return statements.
Or you can leave it as it is now, if you prefer.
Regards,
Morten
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.