When you write a custom adapter, chances are you want to have some custom context properties. Context properties are handy when you want to do dynamic routing or change any port info inside an orchestration. The problem is that how to do this with a custom adapter is not very clear. Here are my tips:

First, you need to create a "property schema". To do this, first create a BizTalk project then add a new "property schema".

Property schemas are different from regular schemas. Most importantly, they are a different icon in the "Add new" dialog in visual studio :) Besides that, they do not have a heirarchy within xml, just a list of properties.

After you add the property schema to your project, choose the "xsd" file in the solution explorer and in the properties pane for this file change "Build Action" to "compile". Next enter a "Namespace" and "Type Name". I would suggest using "MyAdapter" as the Namespace and "ContextProperty" as the Type name. This is the way you will reference your context properties in your orchestration. For example, you "Assign Message" shape might have some code as follows: MyMessage(MyAdapter.ContextProperty.DestinationAddress) = "jimmy@nospam.com"

You can use the BizTalk property schema editor to work with properties. This makes it quicker to edit. Just right-click on the "" node and choose "Insert->Child Field Element".

Most important thing: For a given item. i.e. "DestinationAddress", in the properties pane for this schema item you need to set the "Property Schema Base" to "MessageContextPropertyBase". Second most important thing, for the "" item, set the property "Target Namespace" to something meaningful to you i.e. "http://myadapter.schema/contextproperties".

Element names are case sensitive.

In your adapter code, you can get and set context properties using "msg.Context.Read(...)" and "msg.Context.Write(...) or msg.Context.Promote(...)" respectively.

And finally, to use the adapter context property schema in an orchestration, you will simply add a reference to the schema assembly.