다음을 통해 공유


BAM API를 사용하여 BAM 인터셉터 로드

이 항목에서는 구성 파일을 통해서가 아닌 코드에서 WF 및 WCF 인터셉터를 로드하는 방법에 대한 정보를 제공합니다.

코드에서 WF 인터셉터 로드

코드에서 WF 인터셉터 런타임을 로드하려면 새 WorkflowRuntime 인스턴스를 만들고 새 BamTrackingService 인스턴스를 사용하여 AddService 메서드를 호출해야 합니다. 이 작업은 아래에 나와 있습니다.

string connectionString = "Integrated Security=SSPI;Data Source=.;Initial Catalog=BAMPrimaryImport";  
int PollingIntervalSec = 300;  
  
WorkflowRuntime workflowRuntime = new WorkflowRuntime();  
workflowRuntime.AddService(new BamTrackingService(connectionString, interceptorConfigurationPollingInterval));  

코드에서 WCF 인터셉터 로드

WCF 인터셉터를 로드하려면 서비스를 열며 구현에 액세스할 수 있는 파생 클래스를 만들어야 합니다. 이 작업은 아래에 나와 있습니다.

// Your project must have a reference to Microsoft.BizTalk.BAM.Interceptors.dll.  
// Create a derived class accessible to the implementation that opens the service.  
internal class MyBamBehaviorExtension : BamBehaviorExtension  
{  
    internal MyBamBehaviorExtension(string connectionString, int pollingInterval)  
        : base()  
    {  
        this.ConnectionString = connectionString;  
        this.PollingIntervalSec = pollingInterval.ToString();  
    }  
  
    internal IEndpointBehavior Create()  
    {  
        return (IEndpointBehavior) this.CreateBehavior();  
    }  
}  
  
// Add the endpoint behavior just before the service is opened.   
// In this example the connection string and polling intervals are being read from appSettings in App.config.  
MyBamBehaviorExtension bamBehaviorExtension = new MyBamBehaviorExtension(ConfigurationManager.AppSettings["ConnectionString"], int.Parse(ConfigurationManager.AppSettings["PollingIntervalSec"]));  
IEndpointBehavior bamBehavior = bamBehaviorExtension.Create();  
foreach (System.ServiceModel.Description.ServiceEndpoint endpoint in myServiceHost.Description.Endpoints)  
{  
    if (endpoint.Behaviors.Find<MyBamBehaviorExtension>() == null)  
        endpoint.Behaviors.Add(bamBehavior);  
}  

참고 항목

BAM WCF 및 WF 인터셉터 사용