I am facing a problem in assigning default String value in Smooks. When I assign the default value as "Unknown"
for <jb:value>
it doesn't take it and throws an error.
Smooks config file:
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
xmlns:core="http://www.milyn.org/xsd/smooks/smooks-core-1.3.xsd"
xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.4.xsd">
<jb:bean beanId="ResData" class="java.util.HashMap"
createOnElement="perReturn" retain="true">
<jb:value property="TransactionId" data="TransactionId" />
<jb:value property="amount" data="amount" />
<jb:value property="subscriberConfirmationNo" data="ConfirmationNo" />
<jb:value property="errorMessage" data="errorMessage" />
<jb:value property="status" data="status" />
<jb:value property="Tokan" data="Tokan" />
<jb:value property="Freefield1" data="Freefield1" />
</jb:bean>
<jb:bean beanId="ErrorMap" class="java.util.HashMap"
createOnElement="Body" retain="true">
<jb:expression property="errorText">
if(VARS.isdef("ResData"))
{
if(ResData.status == "0" )
{
return "Success";
}
else if(ResData.status == "1")
{
return ResData.errorMessage;
}
else if(ResData.status == null)
{
return "Sorry! Request could not be processed due to a technical issue.
Status will be updated in 48hrs.";
}
else
{
return ResData.errorMessage;
}
}
else
{
return "Sorry! Request could not be processed due to a technical issue.
Please try again later.";
}
</jb:expression>
<jb:value property="errorCode" data="Response/perReturn/errorMessage"
decoder="String" default="Error" />
<jb:value property="errorFlag" data="Response/perReturn/status"
decoder="Integer" default="2" />
<jb:value property="partnerId" data="Body" decoder="String">
<jb:decodeParam name="valuePreprocess">return "8011";</jb:decodeParam>
</jb:value>
</jb:bean>
Source File:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sync="http://sync.partner.virtualization.xyzz.com">
<soapenv:Header />
<soapenv:Body>
<sync:Response>
<perReturn>
<TransactionId>123456789</TransactionId>
<amount>10</amount>
<ConfirmationNo>0000000000</ConfirmationNo>
<errorMessage></errorMessage>
<status>0</status>
<Tokan>01244243016</Tokan>
<Freefield1>1437083181</Freefield1>
</perReturn>
</sync:Response>
</soapenv:Body>
I added the Smooks config file and source data. When the error message is null in the source file, I want to default error code to some text but it isn't working.