Hello Experts,
I'm trying to build an xml body using groovy script from different sender. I could build xml file and convert to string, same way I could test in IntelliJ without an issue. when I deploy the same code in CPI, I'm getting the below Error.
com.sap.it.rt.adapter.http.api.exception.HttpResponseException: An internal server error occured: No signature of method: com.sap.gateway.ip.core.customdev.processor.MessageImpl.SetBody() is applicable for argument types (java.lang.String) values: [<ProdCatalog>....

Groovy Script
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import groovy.xml.MarkupBuilder
import groovy.xml.XmlSlurper
def Message processData(Message message) {
//Body
def body = message.getBody();
def root = new XmlSlurper().parseText(body)
def writer = new StringWriter()
def builder = new MarkupBuilder(writer)
builder.ProdCatalog {
'ArrayOfPCatInfo' {
root.Root.each { item ->
'PCatInfo' {
'PFC'(item.PFCCode)
'PF'(item.ProductFamily)
'S'(item.Security)
'PC'(item.TFSProductID)
'P'(item.ProductDescription)
}
}
}
'ArrayOfPCatVersion' {
root.Root.Version.Version.Package.Package.Module.Module.each { item ->
'PCatVersion' {
'PC'(item.parent().parent().parent().parent().parent().parent().TFSProductID)
'VC'(item.parent().parent().parent().parent().VersionCode)
'VC'(item.parent().parent().parent().parent().VersionDescription)
'PKC'(item.parent().parent().PackageCode)
'PK'(item.parent().parent().PackageDescription)
'MC'(item.ModuleCode)
'M'(item.ModuleDescription)
}
//println item.parent().parent().PackageDescription
}
root.Root.Version.Version.Package.Package.each { item ->
if (item.Module.Module.size() <= 0) {
'PCatVersion' {
'PC'(item.parent().parent().parent().parent().TFSProductID)
'VC'(item.parent().parent().VersionCode)
'VC'(item.parent().parent().VersionDescription)
'PKC'(item.PackageCode)
'PK'(item.PackageDescription)
'MC'("NULL")
'M'("NULL")
}
}
}
root.Root.Version.Version.each { item ->
if (item.Package.Package.size() <= 0) {
'PCatVersion' {
'PC'(item.parent().parent().TFSProductID)
'VC'(item.VersionCode)
'VC'(item.VersionDescription)
'PKC'("NULL")
'PK'("NULL")
'MC'("NULL")
'M'("NULL")
}
}
}
}
}
// println("-----------------" + dc)
def op = writer.toString()
message.SetBody(op)
return message;
}
As I'm still in learning phase of CPI, any explanation/guidance/recommended approach along with solution would be much helpful
Thanks,
Senz
Request clarification before answering.
Hi senz.evo,
Hope you are doing well!
Could you please try message.setBody(op) ?
Regards,
Pavan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.