Dynamic Message- Message where certain XML elements might or might not be available.
Assume incoming message might or might not have XML Element "Contact_Business Address"(Contact_undBusiness_spcAddress in xml example shown below). If we have a XML element we need to retrieve the value of attribute "Country" and if its value is USA we need to set it.
Assume incoming message might or might not have XML Element "Contact_Business Address"(Contact_undBusiness_spcAddress in xml example shown below). If we have a XML element we need to retrieve the value of attribute "Country" and if its value is USA we need to set it.
We were not able to use "PRM
ANI Utility Service" and "Workflow Utilities" business service
here as it throws error if XML Element
"Contact_Business Address" is not found in the incoming message.
We have used business service to retrieve same. Please find the code written in BS below:
Input of Business Service
if(MethodName=="Execute")
{
try
{
var
PropVal = "";
var
NumChilds = 0;
var
psListOfContact = Inputs.GetChild(0);
var
psContact = psListOfContact.GetChild(0);
var
psListOfConAddr = psContact.GetChild(0);
NumChilds
=psListOfConAddr.GetChildCount();
for
(var i = 0; i < NumChilds; i++)
{
var
psAddr = psListOfConAddr.GetChild(i);
var
Type = psAddr.GetType();
//Check
if the type exists then only fetch the value else skip this part.
if(Type
== "Contact_Business Address")
{
Outputs.SetProperty("Type",
Type);
PropVal
= psAddr.GetProperty("Country");
if(PropVal
== "USA")
{
Outputs.SetProperty("Country",
PropVal);
}
}
}
return
(CancelOperation);
}
catch(e)
{
throw(e);
}
finally
{
psAddr=
null;
psListOfConAddr=
null;
psContact=
null;
psListOfContact=
null;
}
return
(ContinueOperation);
}
Output of Business Service
No comments:
Post a Comment