Skip to Content
avatar image
Former Member

HCI Groovy Script Error

Hi Experts,

I am new to HCI and doing a test IFLOW soap to soap for currency converter

I am trying to execute groovy script to replace a in coming value and i get error "Script may not pass xml message to soap receiver, any suggestions are helpfull

Thank you

iflow.jpg (153.5 kB)
groovyscript.jpg (169.2 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    Mar 02 at 03:23 AM

    Hi Gaurav,

    It's a warning. Please try to deploy the iflow and let us know if you are getting an error.

    thanks and regards,

    Praveen T

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 02 at 05:26 PM

    Hi Gaurav,

    Few issues that I noticed in your code:

    • method getBody() is declared, but not implemented - the method definition looks superfluous and can be removed,
    • operations with the message object within script shall be performed using corresponding instance of Message object that is passed to the method processData() as those methods are instance, not static methods - hence, you cannot refer to message in a static way (in the script above, you make attempts to get and set body of the message referring to methods of Message class as if they would have been static methods, rather than invoking them against specific instance of Message class that is available in your script and accessed via variable message).

    Have a look into the adjusted code below:

    def Message processData(Message message) {
    def msgBodyOriginal = message.getBody(java.lang.String) as String
    def msgBodyModified = msgBodyOriginal.replace('test', 'US')
    message.setBody(msgBodyModified)
    return message
    }

    Regards,

    Vadim

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 02 at 11:51 AM

    add "}" at the end of your script my friend.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 02 at 04:00 AM

    Thank you checking it....

    Below is the error

    Processing exchange ID-vsa in bean[ref:scriptprocessor method:process]: StartTime = Fri Mar 02 03:56:18.031 UTC 2018 StopTime = Fri Mar 02 03:56:18.035 UTC 2018 ChildCount = 9 Error = javax.script.ScriptException:

    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: script.groovy: 18: expecting '}', found '' @ line 18, column 16. return message; ^ 1 error , cause: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: script.groovy: 18: expecting '}', found '' @ line 18, column 16. return message; ^

    Thanks

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 02 at 02:03 PM

    I forgot to update you

    I already added the closing bracket and still get different error

    1 error , cause: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: script.groovy: 4: You defined a method without body. Try adding a body, or declare it abstract. at line: 4 column: 1. File: script.groovy @ line 4, column 1. public java.lang.Object getBody() ^

    SCRIPT:

    import com.sap.gateway.ip.core.customdev.util.Message;

    import java.util.HashMap;

    public java.lang.Object getBody() def Message processData(Message message){

    //Body def body = Message.getBody(); message.setBody(body + "Body is modified");

    def body_xml= Message.getBody(java.lang.String); def input_xml=body_xml.replace("test","US");

    Message.setBody(input_xml);

    return Message; }

    Thanks

    Add comment
    10|10000 characters needed characters exceeded