在代码中使用解析程序组件

动态转换代理的以下代码片段显示了默认的实时 (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);