Click to Rate and Give Feedback
MSDN
MSDN Library
BizTalk Server
Development
 Examples of Custom Configuration Sc...
Examples of Custom Configuration Schemas for Adapters

This section provides the following examples for how to customize configuration schemas for adapters:

  • Example 1 shows a complete custom XSD schema file representing an adapter property page using the baf:designer and baf:description extensions.
  • Example 2 also uses the baf:designer and baf:description extensions to show how to create a custom property value window for the BatchSize property that only accepts values between 1 and 99, inclusive.
  • Example 3 shows how to limit the baf:Password to 8 characters. By default, it allows 22 characters.
  • Example 4 shows how to implement pattern-matching constraints on property values because XSD patterns are not supported.

This example shows a complete custom XSD schema. It represents an adapter property page using the baf:designer and baf:description extensions.

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema   targetNamespace="http://tempuri.org/XMLSchema.xsd" 
         elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" 
         xmlns:baf="BiztalkAdapterFramework.xsd" 
         xmlns:xs="http://www.w3.org/2001/XMLSchema" 
         xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
   <xs:import namespace="BiztalkAdapterFramework.xsd" />
   <xs:element name="Send">
      <xs:complexType>
         <xs:sequence>
            <xs:element name="directory" type="xs:string" />
               <xs:annotation>
                  <xs:appinfo>
                     <baf:designer>
                        <baf:description>Enter the directory that will receive sent files..
                        </baf:description>
                     </baf:designer>
                  </xs:appinfo>
               </xs:annotation>
            </xs:element>
            <xs:element name="fileName" type="" />
            <xs:element name="sendBatchSize" type="xs:int" />
            <xs:element name="fileCopyMode" type="CopyMode" />
            <xs:element name="uri" type="xs:string" >
               <xs:annotation>
                  <xs:appinfo>
                     <baf:designer>
                        <baf:browsable show="false" />
                     </baf:designer>
                  </xs:appinfo>
               </xs:annotation>
            </xs:element>
         </xs:sequence>
      </xs:complexType>
   </xs:element>
   <xs:simpleType name="CopyMode">
      <xs:restriction base="xs:string">
         <xs:enumeration value="Append">
            <xs:annotation>
               <xs:documentation>= 0</xs:documentation>
            </xs:annotation>
         <xs:enumeration value="Create">
            <xs:annotation>
               <xs:documentation>= 1</xs:documentation>
            </xs:annotation>
         <xs:enumeration value="CreateNew">
            <xs:annotation>
               <xs:documentation>= 2</xs:documentation>
            </xs:annotation>
         </xs:enumeration>
      </xs:restriction>
   </xs:simpleType>
</xs:schema>

This example uses the baf:designer and baf:description extensions to show how to create a custom property value window for the BatchSize property that only accepts values between 1 and 99, inclusive.

   <xs:element name="BatchSize">
          <xs:simpleType>
            <xs:annotation>
              <xs:appinfo>
                <baf:designer>
                  <baf:displayname>Batch Size</baf:displayname>
                  <baf:description>Enter the batch size (1-99)</baf:description>
                </baf:designer>
              </xs:appinfo>
            </xs:annotation>
            <xs:restriction base="xs:int">
              <xs:minInclusive value="1" />
              <xs:maxInclusive value="99" />
            </xs:restriction>
          </xs:simpleType>
        </xs:element>

This example shows how to limit the baf:Password to 8 characters. By default, it allows 22 characters.

<xs:element name="AdapterPassword">
          <xs:simpleType>
            <xs:annotation>
              <xs:appinfo>
                <baf:designer>
                  <baf:displayname>Adapter Password</baf:displayname>
                  <baf:description>Enter the password (up to 8 characters)</baf:description>
                  <baf:editor assembly="%BTSROOT%\\Developer Tools\\Microsoft.BizTalk.Adapter.Framework.dll">Microsoft.BizTalk.Adapter.Framework.ComponentModel.PasswordUITypeEditor</baf:editor>
                  <baf:converter assembly="%BTSROOT%\\Developer Tools\\Microsoft.BizTalk.Adapter.Framework.dll">Microsoft.BizTalk.Adapter.Framework.ComponentModel.PasswordTypeConverter</baf:converter>
                </baf:designer>
              </xs:appinfo>
            </xs:annotation>
            <xs:restriction base="xs:string">
              <xs:maxLength value="8" />
            </xs:restriction>
          </xs:simpleType>
        </xs:element>

This example shows how to implement pattern-matching constraints on property values because XSD patterns are not supported.

Fields such as ClientIdentifier are always a three-character numeric string. A property value of 10 is not valid, whereas 010 is valid. The following configuration schema fragment defines a ClientIdentifier property. The ClientIdentifierConverter class, implemented in your adapter assembly, implements pattern matching. In this case, the custom type converter restricts values to a string of exactly three digits (000 to 999). In the configuration schema, make sure the baf:converter node has the assembly and type full name set correctly. If the user attempts to enter a value that is not valid, an exception message pops up when a validation error occurs in the property page.

You can use the following code in the adapter property page configuration schemas.

        <xs:element name="ClientIdentifier" type="xs:string">
          <xs:annotation>
            <xs:appinfo>
              <baf:designer>
                <baf:displayname>Adapter Client</baf:displayname>
                <baf:description>Enter the Adapter Client (3 digit string)</baf:description>
                <baf:converter assembly="%BTSROOT%\\Developer Tools\\Microsoft.BizTalk.TestAdapter.dll">Microsoft.BizTalk.TestAdapter.ClientIdentifierConverter</baf:converter>
              </baf:designer>
            </xs:appinfo>
          </xs:annotation>
        </xs:element>

You can place the following code in your adapter assembly.

using System;
using System.ComponentModel;
using System.Globalization;
using System.Text.RegularExpressions;
 
namespace Microsoft.BizTalk.TestAdapter
{
       /// <summary>
       /// Summary description for ClientIdentifierConverter.
       /// </summary>
       public class ClientIdentifierConverter : System.ComponentModel.StringConverter 
       {
              private void Validate(string value)
              {
                     Regex regex = new Regex(@"^\d{3}$"); // ^=begin, \d=digit, {3}=exactly 3 occurrences, $=end
                     Match match = regex.Match((string)value);
                     if (!match.Success)
                     {
                           throw new ApplicationException("Value does not match pattern \"" + regex.ToString() + "\".");
                     }
              }
 
              public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
              {
                     if (value is string)
                     {
                           this.Validate((string)value);
                     }
                     return base.ConvertFrom(context, culture, value);
              }
 
              public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
              {
                     if (typeof(string) == destinationType && value is string)
                     {
                           this.Validate((string)value);
                     }
                     return base.ConvertTo(context, culture, value, destinationType);
              }
       }
}
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Custom Configuration      Eric Stott   |   Edit   |  

If you want to add Decoration Tags, this page doesn't show much of how to do this. The following example uses a resx file, but also has 3 different categories (Business Activity Monitoring, FTP, and Polling Interval groups)

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:baf="BiztalkAdapterFramework.xsd" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" targetNamespace="http://tempuri.org/XMLSchema.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="BiztalkAdapterFramework.xsd" />
<xs:element name="Config">
<xs:complexType>
<xs:sequence>
<xs:element name="BAMServer" type="xs:string">
<xs:annotation>
<xs:appinfo>
<baf:designer xmlns:baf="BiztalkAdapterFramework.xsd">
<baf:displayname _locID="BAMServerName">Edit this field in the resource file</baf:displayname>
<baf:description _locID="BAMServerDesc">Edit this field in the resource file</baf:description>
<baf:category _locID="BAMGroup">Edit this field in the resource file</baf:category> <!-- Here is the Group Identifier -->
</baf:designer>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="BAMDatabase" type="xs:string">
<xs:annotation>
<xs:appinfo>
<baf:designer xmlns:baf="BiztalkAdapterFramework.xsd">
<baf:displayname _locID="BAMDatabaseName">Edit this field in the resource file</baf:displayname>
<baf:description _locID="BAMDatabaseDesc">Edit this field in the resource file</baf:description>
<baf:category _locID="BAMGroup">Edit this field in the resource file</baf:category> <!-- Here is the same Group Identifier -->
</baf:designer>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element minOccurs="1" default="10" name="pollingInterval" type="xs:int">
<xs:annotation>
<xs:appinfo>
<baf:designer xmlns:baf="BiztalkAdapterFramework.xsd">
<baf:displayname _locID="pollingIntervalName">Polling Interval</baf:displayname>
<baf:description _locID="pollingIntervalDesc">The elapsed time between transactions against the database.</baf:description>
<baf:category _locID="categoryGroup">Edit this field in the resource file</baf:category> <!-- Here is the second Group Identifier -->
</baf:designer>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element minOccurs="1" default="minutes" name="pollingIntervalUnit">
<xs:annotation>
<xs:appinfo>
<baf:designer xmlns:baf="BiztalkAdapterFramework.xsd">
<baf:displayname _locID="pollingIntervalUnitName">Polling Interval Unit</baf:displayname>
<baf:description _locID="pollingIntervalUnitDesc">The unit of time measure for the Polling Interval.</baf:description>
<baf:category _locID="categoryGroup">Edit this field in the resource file</baf:category> <!-- Here is the second Group Identifier -->
</baf:designer>
</xs:appinfo>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string"> <!-- Here is a drop down list of the available options for pollingIntervalUnit -->
<xs:enumeration value="milliseconds">
<xs:annotation>
<xs:appinfo>
<baf:designer xmlns:baf="BiztalkAdapterFramework.xsd">
<baf:displayname _locID="">Milliseconds</baf:displayname>
</baf:designer>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="seconds">
<xs:annotation>
<xs:appinfo>
<baf:designer xmlns:baf="BiztalkAdapterFramework.xsd">
<baf:displayname _locID="">Seconds</baf:displayname>
</baf:designer>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="minutes">
<xs:annotation>
<xs:appinfo>
<baf:designer xmlns:baf="BiztalkAdapterFramework.xsd">
<baf:displayname _locID="">Minutes</baf:displayname>
</baf:designer>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Server" type="xs:string">
<xs:annotation>
<xs:appinfo>
<baf:designer xmlns:baf="BiztalkAdapterFramework.xsd">
<baf:displayname _locID="ServerName">Edit this field in the resource file</baf:displayname>
<baf:description _locID="ServerDesc">Edit this field in the resource file</baf:description>
<baf:category _locID="ftpGroup">Edit this field in the resource file</baf:category>
</baf:designer>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="UserName" type="xs:string">
<xs:annotation>
<xs:appinfo>
<baf:designer xmlns:baf="BiztalkAdapterFramework.xsd">
<baf:displayname _locID="UserNameName">Edit this field in the resource file</baf:displayname>
<baf:description _locID="UserNameDesc">Edit this field in the resource file</baf:description>
<baf:category _locID="ftpGroup">Edit this field in the resource file</baf:category>
</baf:designer>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Password" type="xs:string">
<xs:annotation>
<xs:appinfo>
<baf:designer xmlns:baf="BiztalkAdapterFramework.xsd">
<baf:displayname _locID="PasswordName">Edit this field in the resource file</baf:displayname>
<baf:description _locID="PasswordDesc">Edit this field in the resource file</baf:description>
<baf:category _locID="ftpGroup">Edit this field in the resource file</baf:category>
<!-- Here is the start of the code to mask the passowrd -->
<baf:editor assembly="%BTSROOT%\\Developer Tools\\Microsoft.BizTalk.Adapter.Framework.dll">Microsoft.BizTalk.Adapter.Framework.ComponentModel.PasswordUITypeEditor</baf:editor>
<baf:converter assembly="%BTSROOT%\\Developer Tools\\Microsoft.BizTalk.Adapter.Framework.dll">Microsoft.BizTalk.Adapter.Framework.ComponentModel.PasswordTypeConverter</baf:converter>
</baf:designer>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Folder" type="xs:string">
<xs:annotation>
<xs:appinfo>
<baf:designer xmlns:baf="BiztalkAdapterFramework.xsd">
<baf:displayname _locID="FolderName">Edit this field in the resource file</baf:displayname>
<baf:description _locID="FolderDesc">Edit this field in the resource file</baf:description>
<baf:category _locID="ftpGroup">Edit this field in the resource file</baf:category>
</baf:designer>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Mask" type="xs:string">
<xs:annotation>
<xs:appinfo>
<baf:designer xmlns:baf="BiztalkAdapterFramework.xsd">
<baf:displayname _locID="MaskName">Edit this field in the resource file</baf:displayname>
<baf:description _locID="MaskDesc">Edit this field in the resource file</baf:description>
<baf:category _locID="ftpGroup">Edit this field in the resource file</baf:category>
</baf:designer>
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker