Serialize and deserialize a workflow ruleset

Serailze

private void SerializeRuleSet(RuleSet ruleSet)
{
StringBuilder ruleDefinition = new StringBuilder();
WorkflowMarkupSerializer serializer = new WorkflowMarkupSerializer();

if (ruleSet != null)
{
try
{
StringWriter stringWriter = new StringWriter(ruleDefinition, CultureInfo.InvariantCulture);
XmlTextWriter writer = new XmlTextWriter(stringWriter);
serializer.Serialize(writer, ruleSet);
writer.Flush();
writer.Close();
stringWriter.Flush();
stringWriter.Close();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}
else
{

}

XmlDocument rule = new XmlDocument();
rule.LoadXml(ruleDefinition.ToString());
rule.Save(“c:\\message.xml”);
}

Deserialize

public static RuleSet GetSampleRule(string type)
{

ruleSetXmlDefinition = GetEmbeddedTextFileContent(“SampleRule.xml”);

WorkflowMarkupSerializer serializer = new WorkflowMarkupSerializer();

StringReader stringReader = new StringReader(ruleSetXmlDefinition);
XmlTextReader reader = new XmlTextReader(stringReader);
return serializer.Deserialize(reader) as RuleSet;
}

Testing in biztalk 2009i

Well one of the drawback that i found is we cannot test the out of the box built in pipelines…..

well why do you want to do it???, because i want to test a transform, i want to see if my flat file is getting disassembled properly….etc, you can over come this by creating your own pipelines(a copy of the default ones with the same components)……

Tomas’s testing library handles this very nicely…

Debugging WCF LOB Custom Adapters

1) Gac the assembly
Install the WCF LOB Adapter assembly in the GAC and click Run and paste the following %systemroot%\assembly\gac, navigate to the msil folder(the .net 2.0 assembly are installed here) find your assembly and copy the pdb files in to it
your assembly will be stored in the following structure

— Name of the assembly
— public key token
— .dll file (copy the pdb files here)

in order to automate the process you might want to create a bat file or add a post build command in Visual studio.(Of course the above structure will appear only when you have gaced the assembly first and then create the bat file or the post build script).

So we are ready for debugging

2) Design Time
open up 2 instances of Visual studio
1st instance should contain the WCF LOB Adapter project
2nd should contain the client or biz talk project that you want to import the adapter proxy into

In the first instance attach the 2nd instance Visual studio process from the debug menu, and from the second VS instance perform Add Adapter reference for a .net client or a Add generated items for a Biz talk client.

Once done the debug point in the 1st instance of the Adapter code will be hit.

3) Run Time
Once you gaced WCF LOB Adapter assembly click F5 from your .net application
For biz talk you have to attach the Biz talk process.

and also throw in DebugView and add WCF tracing— 🙂

Note: As you do the changes to the adapter code, you have to restart Visual studio again to load the latest dll, i believe VS caches the dlls.

WCF LOB adapter Metadata changes don’t reflect when you consume the adapter.

Problem:
I was working the with the WCF LOB adapter and did a small change to the adapter’s operation (added another input parameter from 2 to 3), and gaced the adapter dll, then in the same VS instance i added another project and consumed thte adapter service, nothing has changed the operation still showed only 2 parameters!!!!!!!!!!!!!

Solution: Restart VS and consume the adapter again.

BizTalk Dissasembler

This is an amazing tool to have, one of my resources deleted a BizTalk Map, in came the dissasembler for Reflector and the XSLT was generated from the DLL, ufff… It did save us a lot of time(About to be deployed to PRD).

The disassembler can generate schemas, xslt, orchestartions, pipelines etc…

its a must have for every BizTalk Devloper out there.