BloggingAbout.NET
Thoughts of developers
BizTalk: CreateBTSMessage revisited

This post is a follow-up to the previous BizTalk: Create Message based on deployed schema post.

In the current solution I am working on, we are implementing the ability to run versions of the BizTalk application side-by-side.  This will allow us to deploy early and verify the solution before any real messages are sent through.  This will also allow us to finish the processing of dehydrated orchestrations.  Aside: if anyone has some good best practices/techniques around this, please let me know!

One bit of functionality that has cause a little grief is using the helper utility described in the previous post.  Fortunately, this was overcome with a minor code change to filter by the assembly full name:

public static XmlDocument CreateMessage(string schemaName, string rootNode, string assembly)
{
    XmlDocument doc = new XmlDocument();
    DocumentSpec docSpec;
 
    BtsCatalogExplorer catalog = new BtsCatalogExplorer();
    catalog.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings[BTS_CONNECTION_STRING].ConnectionString;
            
    Schema schema = null;
 
    if (assembly == string.Empty)
        schema = catalog.Schemas[schemaName];
    else
        schema = catalog.Schemas[schemaName, assembly];
 
    if (schema == null)
        throw new BTSUtilitiesException(string.Format("Failed to retrieve the {0} schema from the management database.", schemaName));
    else
    {             
        docSpec = new DocumentSpec(rootNode, schema.BtsAssembly.DisplayName);
                
        if (docSpec == null)
            throw new BTSUtilitiesException(string.Format("Failed to build the document {0}.", rootNode));
        else
        {
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
 
            try
            {
                doc.Load(docSpec.CreateXmlInstance(sw));
            }
            finally
            {
                sw.Dispose();
            }                    
        }
    }
    return doc;
 }

Posted Thu, Feb 5 2009 9:41 AM by chilberto
Filed under: ,

Add a Comment

(required)  
(optional)
(required)  
Remember Me?

Please add 6 and 6 and type the answer here:
Copyright © 2003-2010 BloggingAbout.NET