共用方式為


在程式碼中使用解析器元件

動態轉換代理程式的下列代碼段會顯示預設 Just-In-Time (JIT) 解析功能。 您可以使用類似的程式代碼,輕鬆地在自己的應用程式中實作解析。

  
//XLANGs  
itinerary = new Microsoft.Practices.ESB.Itinerary.SerializableItineraryWrapper();  
step = new Microsoft.Practices.ESB.Itinerary.SerializableItineraryStepWrapper();  
  
itinerary.Itinerary = Microsoft.Practices.ESB.Itinerary.ItineraryOMFactory.Create(InboundMessage);  
step.ItineraryStep = itinerary.Itinerary.GetItineraryStep(InboundMessage);  
resolvers = step.ItineraryStep.ResolverCollection;  
resolvers.MoveNext();  
resolver = resolvers.Current;  
  
// Pass the resolver configuration to the Resolver mgr for resolution.  
resolverDictionary = Microsoft.Practices.ESB.Resolver.ResolverMgr.Resolve(InboundMessage, resolver);  
  
// Set the transform type.  
transformType = resolverDictionary.Item("Resolver.TransformType");  

在上述清單中,ResolverMgr 類別的 Resolve 方法會傳回 Dictionary 物件,其中包含所有預設解析屬性及其解析的值。 任何自定義解析程式都可以將自定義屬性新增至 Dictionary 物件;這麼做可讓這些屬性可供任何自定義行程服務使用。

下表顯示 Microsoft BizTalk ESB 工具組中的解析程式可選擇性填入的屬性。 任何路線服務都可以從傳回的 Dictionary 物件擷取屬性值以取得這些屬性值。

屬性

     
Resolver.Action Resolver.ActionField Resolver.DocumentSpecName
解析器.成功 Resolver.EndpointConfig Resolver.DocumentSpecStrongName
Resolver.FixJaxRpc Resolver.InboundTransportType Resolver.EpmRRCorrelationToken
Resolver.InterchangeId Resolver.IsRequestResponse Resolver.InboundTransportLocation
Resolver.MessageType Resolver.MethodName Resolver.MessageExchangePattern
Resolver.ReceivePortName Resolver.TransportLocation Resolver.OutboundTransportCLSID
Resolver.TransformType Resolver.TargetNamespace Resolver.ReceiveLocationName
Resolver.TransportType Resolver.TransportNamespace Resolver.WindowUserField
Resolver.CacheTimeout

解析程式管理員傳回 Dictionary 物件實例之後,配接器管理員會設定訊息的特定 BizTalk 配接器內容屬性。 路由代理程式的下列代碼段示範如何使用配接器管理員來設定傳出訊息的端點屬性。

  
//XLANGs  
// Set the transport properties.  
transportLocation = resolverDictionary.Item("Resolver.TransportLocation");  
transportType = resolverDictionary.Item("Resolver.TransportType");  
  
// Create the delivery message.  
DeliveryMessage = InboundMessage;  
  
// Call the adapter manager to set all necessary properties on the message.  
Microsoft.Practices.ESB.Adapter.AdapterMgr.SetEndpoint(  
                                resolverDictionary,DeliveryMessage);  
  
// Set the delivery port address.  
DeliveryPort(Microsoft.XLANGs.BaseTypes.Address) = transportLocation;  
DeliveryPort(Microsoft.XLANGs.BaseTypes.TransportType) = transportType;  

路由代理程式的下列代碼段示範如何使用自定義管線元件內的配接器管理員來設定傳出訊息的端點屬性。

// Resolve the configuration for routing.  
ResolverDictionary = ResolverMgr.Resolve(info, pInMsg, pContext);  
  
// Call the adapter manager to set all required message properties.  
AdapterMgr.SetEndpoint(ResolverDictionary, pInMsg.Context);