Good day.
I am working on this groovy script
import groovy.xml.MarkupBuilder;
import groovy.xml.*;
def writer = new StringWriter();
def xmlResponse = new MarkupBuilder(writer);
def index = 0;
xmlResponse.CalculatePayoutFigureResponse() {
Identifier([UniqueID:'CalculatedLoanRepayment-1'])
}
String response = writer.toString();
return XmlUtil.serialize(response);
Every time this gets called, I am getting the ff error:
SEVERE: java.lang.Exception: No method named 'Identifier' found for arguments [[UniqueID:CalculatedLoanRepayment-1]]
java.lang.Exception: No method named 'Identifier' found for arguments [[UniqueID:CalculatedLoanRepayment-1]]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:80)
at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:74)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:84)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247)
Anyone familiar with this? Can you point me to the correct direction.
I have been looking for solutions but to no avail. Is the way I am building the XML wrong? I am using groovy 2.4.4.
THanks in advance!
Chris
After doing some tweaks to the code, I was able to make this work. I used the MarkupBuilder object before every element I am trying to add. Code became like this:
xmlResponse.CalculatePayoutFigureResponse() {
xmlResponse.Identifier(UniqueID:'CalculatedLoanRepayment-1')
}
I got the output that I expected.
<CalculatePayoutFigureResponse>
<Identifier UniqueID='CalculatedLoanRepayment-1' />
</CalculatePayoutFigureResponse>
No idea though as to why this solution worked and what caused the issue I initially encountered.
Thanks! -Chris