ESB Toolkit Blogical SFTP Adapter Provider

Some sample source code for a custom adapter provider for the Blogical SFTP adapter.  After installing the BLogical SFTP adapter create a class library project and add a reference as below


Add the below source code to you class, sign the assembly, build, and deploy to the GAC.

using System;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Collections.Generic;
using Microsoft.Practices.ESB.Adapter;
using Microsoft.Practices.ESB.Exception.Management;
using Microsoft.Practices.ESB.GlobalPropertyContext;

namespace SysTalk.ESB.Common.Adapter.SFTP
 public class SFTPAdapterProvider : BaseAdapterProvider
 #region Public Methods

public override string AdapterName
 get { return "SFTP"; }

public override void SetEndpoint(Dictionary<string, string> ResolverDictionary, Microsoft.BizTalk.Message.Interop.IBaseMessageContext pipelineContext)
 throw new NotImplementedException();

public override void SetEndpoint(Dictionary<string, string> ResolverDictionary, Microsoft.XLANGs.BaseTypes.XLANGMessage message)
 if (ResolverDictionary == null)
 throw new ArgumentNullException("ResolverDictionary");
 if (message == null)
 throw new ArgumentNullException("message");

base.SetEndpoint(ResolverDictionary, message);

 string transportLocation = ResolverDictionary["Resolver.TransportLocation"];
 string outboundTransportCLSID = ResolverDictionary["Resolver.OutboundTransportCLSID"];
 string endpointConfig = ResolverDictionary["Resolver.EndpointConfig"];
 string transportType = ResolverDictionary["Resolver.TransportType"];

message.SetPropertyValue(typeof(BTS.OutboundTransportLocation), transportLocation);
 message.SetPropertyValue(typeof(BTS.OutboundTransportType), transportType);
 message.SetPropertyValue(typeof(BTS.OutboundTransportCLSID), outboundTransportCLSID);

// parse ; delimited endpointconfig and set SFTP specific adapter properties
 if (!string.IsNullOrEmpty(endpointConfig))
 Dictionary<string, string> config = ParseKeyValuePairs(endpointConfig);

// Set the context for the SFTP adapter here
 message.SetPropertyValue(typeof(, config["HOST"]);
 message.SetPropertyValue(typeof(Blogical.Shared.Adapters.Sftp.Schemas.portno), config["PORTNO"]);
 message.SetPropertyValue(typeof(Blogical.Shared.Adapters.Sftp.Schemas.user), config["USER"]);
 message.SetPropertyValue(typeof(Blogical.Shared.Adapters.Sftp.Schemas.identityfile), config["IDENTITYFILE"]);
 message.SetPropertyValue(typeof(Blogical.Shared.Adapters.Sftp.Schemas.remotefile), config["REMOTEFILE"]);
 message.SetPropertyValue(typeof(Blogical.Shared.Adapters.Sftp.Schemas.password), config["PASSWORD"]);
 message.SetPropertyValue(typeof(Blogical.Shared.Adapters.Sftp.Schemas.remotepath), config["REMOTEPATH"]);

 catch (System.Exception ex)
 EventLogger.Write(MethodInfo.GetCurrentMethod(), ex);



#region Private Methods

private static Dictionary<string, string> ParseKeyValuePairs(string stringToParse)
 Dictionary<string, string> dictionary = new Dictionary<string, string>();
 if (!string.IsNullOrEmpty(stringToParse))
 foreach (string str in stringToParse.Split(";".ToCharArray()))
 int index = str.IndexOf('=');
 if (index > 0)
 dictionary.Add(str.Substring(0, index).ToUpper(System.Globalization.CultureInfo.CurrentCulture), str.Substring(index + 1, (str.Length - 1) - index));
 return dictionary;


Be sure to register your new adapter provider in your ESBT config store, either esb.config or the SSO store.

<adapterProvider name="SFTP" type="SysTalk.ESB.Common.Adapter.SFTP.SFTPAdapterProvider, SysTalk.ESB.Common.Adapter.SFTP, Version=, Culture=neutral, PublicKeyToken=#########" moniker="SFTP" />

Now you can start using the SFTP adapter dynamically via the ESBT routing service.  You can either code up an itinerary extender to add support for the SFTP adapter provider to the Visual Studio itinerary designer, or edit the exported xml itinerary for the time being.  Note the adapter provider sample code above grabs the various settings from the EndpointConfig section of the resolver which is delimited by semi-colon.

Footnote.  Another option for using the SFTP adapter with ESBT is to use static ports.  In the case of static ports none of the above is needed and the full adapter properties are available for edit via the BizTalk administration console.  More info here on using static ports from an itinerary here,

This entry was posted in BizTalk Server. Bookmark the permalink.

3 Responses to ESB Toolkit Blogical SFTP Adapter Provider

  1. vk says:

    Appreciate you help mike !


    • Vk says:

      Mike:- I received .asc format (.asc pgp public key) file from client which I need to use to encrypt the flat file and send it to a SFTP location (i’m using blogical SFTP adapter from ESB toolkit 2.1) But when I am trying to import that, file format is not accepting in certificate import wizard (mmc). Can you suggest how I can import .asc file and use inside biztalk send port.

      Your response is greatly appreciated!!


  2. Pingback: ESB Toolkit RetryCount and RetryInterval | Microsoft Tech

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s