cancel
Showing results for 
Search instead for 
Did you mean: 

HCI Groovy Script Error

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

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

Former Member
0 Kudos

Fixed it with picklist replace

Answers (4)

Answers (4)

maxi1555
Contributor

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

vadimklimov
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

Hi Gaurav,

Could notice "}" is missing after "return message"

please change that and then compile the code.

hope that helps !

thanks and regards,

Praveen T