| Author |
Execute multiple Biztalk 2004 messages from .NET bojects
|
|
| Pankaj 2006-06-14, 7:17 pm |
| Hi
I am using .NET component to execute a Biztalk 2004 rules policy which takes
an input xml message and returns me updated xml message, as explained in Case
A.
Case A:
Input xml with ID value:
<Emp>
<ID>1002</ID>
<Income/>
</Emp>
Output xml with ID and Income value:
<Emp>
<ID>1002</ID>
<Income>50000</Income>
</Emp>
Case B:
Input xml with IDs of multiple employees:
<Employees>
<Emp>
<ID>1000</ID>
<Income/>
</Emp>
<Emp>
<ID>1001</ID>
<Income/>
</Emp>
<Emp>
<ID>1002</ID>
<Income/>
</Emp>
</Employees>
Output desired:
<Employees>
<Emp>
<ID>1000</ID>
<Income>40000</Income>
</Emp>
<Emp>
<ID>1001</ID>
<Income>50000</Income>
</Emp>
<Emp>
<ID>1002</ID>
<Income>60000</Income>
</Emp>
</Employees>
My question is: How can I acheive the desired output using .NET components?
I want to execute policy only through C# code and get back the result.
Please advise. Thanks in advance.
| |
| BizTalkVirtuoso 2006-06-15, 1:21 am |
| Use the XmlDocument object and Xpath:
XmlNodeList EmpList = EmployeesXmlDoc.SelectNodes("//Employees/Emp");
foreach(XmlElement Emp in EmpList){
XmlDocument EmpXmlDoc = new XmlDocument();
EmpXmlDoc.LoadXml(Emp.OuterXml);
// Execute Rule Here;
EmpXmlDoc = ExecuteRule(EmpXmlDoc);
Emp.SelectSingleNode("Income").InnerText =
EmpXmlDoc.SelectSingleNode("//Emp/Income").InnerText;
}
Ben McFarlin
Microsoft BizTalk Server Consultant
www.biztalkvirtuoso.com
| |
| Pankaj 2006-06-15, 1:19 pm |
| Thanks for the response Ben.
Your suggested iteration is happening in .NET code. But, is there a way the
entire input can be passed to Rules Engine and iteration happens there. Just
trying to know a possibility of that. This way I don't have to make calls to
rules engine in every iteration.
By any chance do you have good examples for executing Rules from .NET code?
I would really appreciate some.
Pankaj
"BizTalkVirtuoso" wrote:
> Use the XmlDocument object and Xpath:
>
> XmlNodeList EmpList = EmployeesXmlDoc.SelectNodes("//Employees/Emp");
> foreach(XmlElement Emp in EmpList){
> XmlDocument EmpXmlDoc = new XmlDocument();
> EmpXmlDoc.LoadXml(Emp.OuterXml);
> // Execute Rule Here;
> EmpXmlDoc = ExecuteRule(EmpXmlDoc);
> Emp.SelectSingleNode("Income").InnerText =
> EmpXmlDoc.SelectSingleNode("//Emp/Income").InnerText;
> }
>
> Ben McFarlin
> Microsoft BizTalk Server Consultant
> www.biztalkvirtuoso.com
>
>
| |
| BizTalkVirtuoso 2006-06-15, 7:19 pm |
| Can you post the Xpath Field and Selector for the rule?
|
|
|
|