Jon Flanders' Blog

Creating your own BizTalk Assembly

Monday, October 25, 2004 7:00:00 AM (GMT Standard Time, UTC+00:00)

So during class last week one of the students asked me an interesting question. In their application(s) they have a common server (http) for hosting all their schemas. When an application needs an XSD it makes an http request for the schema. The question was essentially how they could make this work with BizTalk.


In BizTalk schemas are compiled into a .NET type. The type derives from Microsoft.XLANGS.BaseTypes.BaseSchema and has a read-only property named XmlContent that returns a string which is really just the XSD. When an assembly with a schema type is deployed into BizTalk, the deployment tool uses Reflection to enter the schema information into the management database (it actually does this will all types created from a BizTalk project).


So what I thought I'd try to do was create a class in C#, add all the appropriate types and attributes, sign the assembly and then deploy my own custom assembly into BizTalk (essentially mimicking the BizTalk project system). Then from the XmlContent property I could write code that would go out via http and retrieve the appropriate schema. BizTalk was happy to take my assembly and use it for its schema registration and other schema purposes. This version just has the string hardcoded - but should work fine with grabbing the schema from some other locaion.


Here is the code:

using System;
using Microsoft.XLANGs.BaseTypes;

namespace CustomSchema
{
[Serializable, SchemaRoots(new string[1] { "Root" } ), 
SchemaType(SchemaTypeEnum.Document), 
Schema("http://CustomSchema.TestSchema", "Root")]
public class TestSchema : SchemaBase 
{
[NonSerialized]
const string _strSchema = "";//TODO: schema string *must* be hardcoded here
[NonSerialized]
static object _RawSchema;
protected override object RawSchema
{
get
{
return _RawSchema;
}
set
{_RawSchema = value;
}
}

public override string XmlContent
{
get
{
//this is where you could go get the schema from 
//an alternate location
return GetSchema();}
}
string GetSchema()
{
}
public override string[] RootNodes
{
get
{
return new string[1] { "Root" };
}
}



}
}

  #    Comments [1]   Tracked by:
http://www.u-g-h.com/PermaLink,guid,9f26f4d7-25ba-42a3-bf0f-251e00523298.aspx [Pingback]

Navigation

Books

Courses

Search

Subscribe

  • RSS 2.0
  • Add to Windows Live button
  • Add to Google button
  • Add to MyMSN button
  • Add to MyYahoo button
  • Add to Bloglines button
  • Add to Newsgator button