共用方式為


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

動態轉換代理程式的下列程式碼片段會顯示預設的 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.Success 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);