BizTalk Server Orchestration - Consuming Dataset in orchestration

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server Orchestration > February 2005 > Consuming Dataset in orchestration





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Consuming Dataset in orchestration
MHS

2004-10-19, 2:47 am

Hello,

I have a .net Assembly that returns a dataset. I created an instance of my
class in expression shape and assigned it to dataset variable.

in order to get the row count I am unable to write
dataset.tables[0].rows.count. It gives an error. More over I do not see
rows.count in context menu when I type dataset.tables[0].


I was hoping to get the row count and assign it to a variable and then use
loop shape to loop through and try to retrieve values from dataset rows by
incrementing index.

Can I do this?

Can anyone please suggest how can I make this to work?

Any help would be greatly appreciated.

Thanks
MHS

Matt Meleski

2004-10-24, 8:46 pm

MHS

One method you can use, is to create an .XSD schema in your BizTalk
Project, that represents the dataset that you have in your .net assembly.
1) If the you are using a strongly typed dataset, then you can copy the .xsd
file
from your .net assembly to your BizTalk assembly. If not, then you will
have to create the schema. I believe there is a method on the dataset to do
this (creating the schema from the dataset).
2) Now in your Orchestration you can create a message that represents the
BTS xsd schema.
3) In an expression shape you can then populate the BizTalk Message by
calling your .Net assembly.
4) Now you can use xpath in your message to get the total row count and loop
through the items in your message like below:

// In one expression shape get the total count :
orderItemCount = 1;
orderItemTotal = xpath(InComingOrder,"number (count (//OrderItems))");

// Usiing a Looping Shape (with a contained expression shape get specific
// attributes from the BizTalk Message that you are interested in, using xpath

currentAmount = xpath(InComingOrder,"string(//OrderItems[" +
strorderItemCount + "]//@Amount)");

// Increment the counter
orderItemCount = orderItemCount + 1;

// Your loop shape will have an expression like this:
orderItemCount <= orderItemTotal

Matt


"MHS" wrote:

> Hello,
>
> I have a .net Assembly that returns a dataset. I created an instance of my
> class in expression shape and assigned it to dataset variable.
>
> in order to get the row count I am unable to write
> dataset.tables[0].rows.count. It gives an error. More over I do not see
> rows.count in context menu when I type dataset.tables[0].
>
>
> I was hoping to get the row count and assign it to a variable and then use
> loop shape to loop through and try to retrieve values from dataset rows by
> incrementing index.
>
> Can I do this?
>
> Can anyone please suggest how can I make this to work?
>
> Any help would be greatly appreciated.
>
> Thanks
> MHS
>

Ben Cuttriss

2005-02-26, 5:52 pm

MHS.
I was looking into this (for messaging reasons from my data layer without
using the SQL Adapter) and I have finally figured it out.

I think the other answer you got was a bit misleading since you can't do
what he was saying (messages have to be constructed in construct block etc.
etc.)

Basically the steps are as follows:
1. Create the .Net assembly typed dataset. This will generate your xsd as
well as the code behind that you can use.
2. Create a function (statuic is good) that calls and create the dataset.
eg:

****Start Example ****
public static string GetDataSet ()
{
System.Diagnostics.Debug.WriteLine("abc called");
string spName = "CustOrderHist";

Document bc = new Document();
string[] tableNames = new string[]{bc.CustOrderHist.TableName};

// Set up parameters
SqlParameter [] arParams =
SqlHelperParameterCache.GetSpParameterSet(@"Integrated
Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind;Data
Source=PC00516\PC00516_BENC;", spName);

arParams[0].Value = @"ALFKI";


SqlHelper.FillDataset(@"Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=Northwind;Data Source=PC00516\PC00516_BENC;",
spName, bc,tableNames, arParams);

System.Diagnostics.Debug.WriteLine(bc.GetXml());
return bc.GetXml();
}
****End Example*****

3. Now that this function returns a string (XML document representation) we
go to the orchestration.
4. Copy the schema from your .Net assembly to the Biztalk project.
(Rename the default namespace on the schema so it matches the one from your
..Net assembly (not sure if this is required...))
5. Create a variable of type XmlDocument.
6. Create an expression that sets the variable XmlDoc = class.GetDataSet
(from 2)
7. Now create a message of type schema that you copied from the .Net assembly
8. Create a construct block to create the message
9. You can set directly the message to the XmlDocument you created in 6.

Neat 'eh?
Hope this helps some more. If it doesn't reply and I'll contact you
directly with some example code.
Regards
Ben Cuttriss
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com