カスタム リゾルバーを作成する
Microsoft BizTalk ESB Toolkit のリゾルバーとアダプター プロバイダー フレームワークの実装では、Dispatcher という名前のパイプライン コンポーネントと、ItineraryReceive および ItinerarySend という名前のパイプラインを使用します。
ディスパッチャー パイプライン コンポーネントには、Validate、Enabled、EndPoint、MapName の 4 つのプロパティがあります。 EndPoint プロパティには、次のような値を持つリゾルバー接続文字列を含めることができます。ここで、UDDI:\\ は使用する解決の種類 (ルート モニカー) を表します。
UDDI:\\serverUrl=http://localhost/uddi;serviceName=OrderPurchaseToOrderPost;serviceProvider=Microsoft.Practices.ESB
サポートされているその他のモニカーには、XPATH:\\、STATIC:\\、BRE:\\ があります。 各モニカー型は、 IResolveProvider インターフェイスを実装する特定のクラスを使用します。 他のモニカー型用に独自のカスタム リゾルバーを作成し、動的解決システムで使用するために登録できます。
モニカーはリゾルバー 接続文字列に相当します。 個々のスキーマは、パラメーターとそのルート モニカーを定義します。 リゾルバーは、リゾルバー 接続文字列を受け取り、検証し、その結果を使用して、ルーティング、変換、スケジュールの選択、またはサービスに固有のその他の目的に使用できる Dictionary オブジェクトのクエリと設定を行います。
リゾルバーの構成
すべてのリゾルバーを Esb.config 構成ファイルに登録する必要があります。 次の XML は、構成ファイルの内容の例を示しています。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="esb" type="Microsoft.Practices.ESB.Configuration.ESBConfigurationSection, Microsoft.Practices.ESB.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c62dd63c784d6e22"/>
<!-- Other Section Definitions Here -->
</configSections>
<esb>
<resolvers cacheManager= "Resolver Providers Cache Manager" absoluteExpiration="3600">
<resolver name="UDDI" type="Microsoft.Practices.ESB.Resolver.UDDI.ResolveProvider, Microsoft.Practices.ESB.Resolver.UDDI, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c62dd63c784d6e22">
<resolverConfig>
<add name="cacheTimeoutValue" value="120" />
<add name="cacheName" value="UDDI Cache Manager" />
</resolverConfig>
</resolver>
<resolver name="XPATH" type="Microsoft.Practices.ESB.Resolver.XPATH.ResolveProvider, Microsoft.Practices.ESB.Resolver.XPATH, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c62dd63c784d6e22"/>
<!-- Other Resolver Definitions Here -->
</resolvers>
<!-- Other ESB Configuration Settings Here -->
</esb>
<!-- Other Configuration Sections Here -->
</configuration>
各リゾルバー ノードの下にある resolverConfig セクションを使用すると、リゾルバーが特定の環境で動作するために必要な追加のプロパティを構成できます。 構成にアクセスするには、競合回避モジュールで 、Microsoft.Practices.ESB.Configuration.Resolver 型のパラメーターを受け取るコンストラクターを公開する必要があります。 リゾルバーの実装では、ResolverConfigHelper クラスの ReadResolverConfigByKey メソッドを使用して構成プロパティにアクセスできます。これを行うには、最初にコンストラクターに渡されたパラメーターを渡し、問題の値の名前を渡します。 resolverConfig ノードで名前と値のペアが指定されていない場合は、既定のパラメーターなしのコンストラクターを使用してリゾルバーがインスタンス化されます。
構成には、UDDI 3 と UDDI 3-SOASOFTWARE という 2 つのユニバーサル記述、検出、統合 (UDDI) 3 リゾルバーが定義されています。 これらのリゾルバーはどちらも同じ基になるアセンブリを使用しますが、異なる URI (Uniform Resource Identifier) 形式とセキュリティ要件で異なる UDDI 3.0 準拠レジストリをサポートするための構成が異なります。 UDDI 3.0 準拠のレジストリに対して、既にサポートされているもの以外に追加のモニカーを構成する必要がある場合は、次の構成プロパティを使用できます。
cacheTimeoutValue
Cachename
publisherKey
useUddiAuth
Baseuri
inquireUriSuffix
securityUriSuffix
securityMode。 有効な値については、列挙 System.ServiceModel.BasicHttpSecurityMode (https://go.microsoft.com/fwlink/?LinkID=188284&clcid=0x409)。 既定値は TransportCredentialOnly です。
credentialType。 有効な値については、列挙 System.ServiceModel.HttpClientCredentialType (https://go.microsoft.com/fwlink/?LinkId=188285) を参照してください。 既定値は Windows です。
username
password
Unity アプリケーション ブロックの依存関係挿入機能に依存するリゾルバーを作成する場合は、追加の構成が必要です。 詳細については、「 Unity コンテナーを使用したカスタム リゾルバーの作成」を参照してください。
IResolveProvider インターフェイス
すべてのリゾルバーは 、IResolveProvider インターフェイスを実装する必要があります。 Microsoft.Practices.ESB.Resolver プロジェクトにある IResolveProvider インターフェイスは、Dictionary クラスのインスタンスを返す Resolve メソッドの 3 つのオーバーロードで構成されます。このオーバーロードには、具象リゾルバー クラスのインスタンスによって提供される解決ファクトが含まれています。 次のコード例は、これらのメソッド オーバーロードのシグネチャを示しています。
// <summary>
// This is the main interface that is called from the
// ResolverMgr class.
// This interface supports being called from a Microsoft BizTalk
// Server pipeline component.
// </summary>
// <param name="config">Configuration string entered into
// pipeline component as argument</param>
// <param name="resolver">Moniker representing the resolver
// to load</param>.
// <param name="message">IBaseMessage passed from pipeline</param>.
// <param name="pipelineContext">IPipelineContext passed from
// pipeline</param>.
// <returns>Dictionary object fully populated</returns>.
Dictionary<string, string> Resolve(string config, string resolver,
IBaseMessage message, IPipelineContext pipelineContext);
// <summary>
// This is the main interface that is called from the ResolverMgr
// class.
// This interface supports being called from a Web service interface.
// </summary>
// <param name="config">Configuration string entered into Web
// service as argument</param>.
// <param name="resolver">Moniker representing the resolver
// to load</param>.
// <param name="message">XML document passed from Web
// service</param>.
// <returns>Dictionary object fully populated</returns>.
Dictionary<string,string> Resolve(string config, string resolver, System.Xml.XmlDocument message);
// <summary>
// This is the main interface that is called from the
// ResolverMgr class.
// This interface supports being called from an orchestration.
// </summary>
// <param name="resolverInfo">Configuration string containing
// configuration and resolver</param>.
// <param name="message">XLANGMessage passed from
// orchestration</param>.
// <returns>Dictionary object fully populated</returns>.
Dictionary<string, string> Resolve(ResolverInfo resolverInfo, XLANGs.BaseTypes.XLANGMessage message);
Microsoft.Practices.ESB.Resolver プロジェクトにある Resolution 構造体では、 Dictionary インスタンスに格納されている名前と値のペアも定義されます。 Resolution 構造体は、いくつかのプロパティを公開します。次の表に、これらの中で最も関連性の高い項目を示します。 ResolutionHelper クラスの CreateResolverDictionary メソッドを使用すると、最も使用されるキーを含むリゾルバー ディクショナリを、空の文字列値で生成できます。 Dictionary インスタンスは、リゾルバー クラスの具象実装を通じて、カスタム リゾルバーの名前と値のペアの追加をサポートします。
プロパティ | データ型 | データ型 | データ型 |
---|---|---|---|
TransformType | 文字列 | ActionField | 文字列 |
Success | Boolean | EpmRRCorrelationTokenField | 文字列 |
TransportNamespace | 文字列 | InboundTransportLocationField | 文字列 |
TransportType | 文字列 | InterchangeIDField | 文字列 |
TransportLocation | 文字列 | ReceiveLocationNameField | 文字列 |
操作 | 文字列 | ReceivePortNameField | 文字列 |
MessageExchangePattern | 文字列 | InboundTransportTypeField | 文字列 |
EndpointConfig | 文字列 | IsRequestResponseField | 文字列 |
TargetNamespace | 文字列 | DocumentSpecStrongNameField | 文字列 |
FixJaxRPC | ブール値 | DocumentSpecNameField | 文字列 |
WindowUserField | 文字列 | [MessageType] | 文字列 |
CacheTimeout | 文字列 | OutboundTransportCLSID | 文字列 |
MethodNameField | 文字列 |
カスタム リゾルバーを作成する
実行時に、パイプラインはリゾルバー 接続文字列を取得し、リゾルバー マネージャー (ResolverMgr クラスのインスタンス) を呼び出します。 リゾルバー マネージャーは、リゾルバーの接続文字列を解析、設定、検証します。 これは、次の手順を実行して行います。
接続文字列を解析して、読み込む競合回避モジュールの種類を決定します。
この型は、構成ファイルで定義されているモニカーと一致します (キーは UDDI などのルート モニカーです)。
このモニカーのリゾルバーのアセンブリ名を読み取ります。
指定したアセンブリが読み込まれます。
動的解決メカニズムは 、IResolveProvider インターフェイスのすべての読み込み済み実装をキャッシュして、複数の受信メッセージで同じリゾルバーが使用されている場合に構成情報とアセンブリの読み込みを繰り返し読み取らないようにします。
最後に、リゾルバー マネージャーは、具体的な IResolveProvider 実装の Resolve メソッドを実行し、設定された Dictionary インスタンスを返します。
カスタム リゾルバーを作成するには
IResolveProvider インターフェイスを実装し、リゾルバーファクトを Dictionary クラスのインスタンスとして返す Resolve メソッドを含むクラスを使用してアセンブリを作成します。
ルート モニカーを name 属性として、完全修飾アセンブリ名を type 属性として含むリゾルバー要素を使用して<、リゾルバー>を Esb.config 構成ファイルに追加して、リゾルバーを登録します。
(省略可能)ルート モニカーとクエリ パラメーターを定義するスキーマを作成し、ESB に保存します。Schemas.Resolvers フォルダー。 名前は、既存の ESB 名前付け規則に従う必要があります。これは、"_Resolution.xsd" が付加されたルート モニカーの名前を使用する必要があることを意味します。
(省略可能)新しいスキーマからクラスを生成し、カスタム リゾルバー アセンブリに保存します。 これにより、カスタム リゾルバーで型指定されたパラメーターが公開されます。
新しいアセンブリをグローバル アセンブリ キャッシュに登録します。