Skip to Content
0

HCI Groovy Script Error

Mar 02 at 12:23 AM

228

avatar image
Former Member

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)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Best Answer
Praveen Tirumareddy
Mar 02 at 03:23 AM
0

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

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

Fixed it with picklist replace

0
Vadim Klimov Mar 02 at 05:26 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Maximiliano Colman Mar 02 at 11:51 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Mar 02 at 04:00 AM
0

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

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

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

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

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

Share
10 |10000 characters needed characters left characters exceeded