September 2010 - Posts

How to use the new “FTPS adapter” with BizTalk 2010
26 September 10 11:30 PM | wmmihaa | 1 comment(s)

First of all – there is no new FTPS adapter. The already existing FTP adapter has been extended to support FTPS, which is really all you need anyway. However, several publications from Microsoft states there is a new FTPS adapter, which might be somewhat confusing.

So what is FTPS?

The support for FTPS was added with IIS 7.5, and is FTP over SSL, similar to HTTPS. Although it lacks some of the underlying infrastructure. When you visit an HTTPS site, you might be given various warnings if the certificate is not among your trusted ones. If you chose to ignore these warnings (and recommendations), you’re provided with the option of installing the public key in your certificate store. This logic is provided by your browser, and is a helpful way to manage your trusted sites.

The FTPS client (BizTalk in this case), however,  require the public key to be installed manually before it can use it. When you’ve installed it, it works like a charm.        


Create a Certificate

First you’ll need a certificate, a private key. There are several ways to create a certificate, but for the purpose of this sample, I’ll create one using IIS 7.5 manager.

Select the site root in the Connections pane on your left side. In the Action pane on your right, click the “Create Self-Signed Certificate”.


This will open a new dialog, where you can set a friendly name of your certificate:


When you’ve clicked Ok, you should be able to see the certificate in the list of Server Certificates. Select your newly created certificate and click “Export” in the Action pane. Set the path and password, and click Ok. this step will export the public key, which we’ll use later on.


Enable FTPS on your FTP site

As we now have a certificate created and registered on our server, we can proceed to enable our FTP site to use it. Select your FTP site, and double-click the “FTP SSL Settings” icon on your FTP Home page.


In the SSL Certificate dropdown list, select your certificate. You can choose either to Allow or to Require SSL connections. In this case I’ve chosen to “Require SSL Connections”. Click “Apply” in the Action pane, before you continue.


While in the FTP Home page, you might want to overlook the “FTP Authentication”, and “FTP Authorization Rules”.

Install the Public Key

Your FTP server is now ready to accept incoming SSL connections, and we can pursue with setting up the client (BizTalk). But first we need to install the public key, which you exported earlier. In my case, I’m logged in as Administrator, which happens to be the same account I use for my host instance. Hopefully, this is not the case for you, why you’ll to import the public key as the same account as you’re running the host instance with. However if you are logged in with the service account, double-click the certificate, and proceed with default values.

If you’re not logged on as the service account, open a command prompt and write the following:

runas /user:[Domain]\[User] "cmd.exe"

This will open a new command prompt, in which you type the path to where you saved the public key. Hit enter and proceed the wizard.

Extract the Thumbprint


Open the Certificate Manager (Start->Run->certmgr.exe), browse to the Trusted Root Certificate Authorities\Certificates folder, and double-click the certificate. Select the “Details” tab on top. Scroll down to the Thumbprint field, select it, and copy the value.


Configure Your BizTalk Port


I assume you are familiar to the normal FTP transport settings, so when you’re done configuring the server, port, username and password, paste the thumbprint in the “Client Certificate Hash” property. Set the “Use SSL” property to “true”. Start the port…You are done!

I’m a superstar and that’s how I do it!


BizTalk Sftp Adapter - New release 1.4 available on CodePlex
21 September 10 02:10 PM | wmmihaa | 1 comment(s)

I’ve got quite a few request for Proxy support through the years, and eventually someone (no names) got tired of waiting, hired me as a consultant, and forced me to implement it. So I’m happy to say the BizTalk adapter now comes with support for HTTP Proxy.

Support has also been added to:

  1. Enable "%UniversalDateTime%" macro on Receive Location (rename)
  2. "Leave File" on the Receive Location.
  3. Not throwing 10.000 exception to the eventlog (yes this is a feature)

Thanks to everyone giving feed-back through the codeplex site.

If you like it, please rate the project (If you don’t like it, you should not feel obligated to do so)

Get it at CodePlex...


You will still need to set the appropriate SSH parameters such as SSH Host, User name and Remote path. These parameters will be sent to the proxy server, which in turn will act as “man-in-the-middle” and connect to the SSH server using the parameters provided by the adapter.

Use AppFabric Cache to cache your WCF Service response
12 September 10 08:33 PM | wmmihaa | 19 comment(s)

[This post has been updated to support InvokeBegin and InvokeEnd to support BizTalk Receive Locations]

We’ve just finished the “BizTalk Release Party” in Stockholm, where Stephen W. Thomas, Richard Seroter and Ewan Fairweather held some fantastic sessions. One of the talks was about the AppFabric Cache formally known as “Velocity”.

Whenever I come across a new technology I try to put it in some useful context, where I can try it out. This is usually a quite painful process, as I tend to do this long before the technology has reached any sort of mature state. AppFabric Cache is a v1 product and therefore considerable more stable then other products or technologies I’ve been experimenting with.

While Ewan was presenting the Windows Server AppFabric Cache I though it could be interesting to use it for caching outgoing WCF service responses, so that the back-end logic would not be executed if it was cached. I’m not sure how useful this scenario really is, but I guess there could be many scenarios where it would be ok not to get the latest version of the information. Some of those situations might be:

  • Where the information is accessed during office hours, and only updated through nightly batches.
  • Where a composite service get bursts of calls that would often be the same.
  • When services expose static data which will seldom change over time.

In my sample I’ll use a fictitious Weather Forecast Service, which I think would qualify as good candidate because:

  • Nobody trust the weather forecasts in the first place, so it doesn’t matter if the result not 100% up to date.
  • The service is frequently called with the same input parameters (Zip code).
  • The service will support a very popular IPhone Windows 7 Mobile application, which in turn will cause an immense load on our back-end systems.



How it works:

WCF: The incoming call from the client is received through the Transport channel, after which it will proceed through an encoder and possible some other channels before it reaches the Dispatcher.

The Dispatcher is the last step before the request is handed over to the actual service. The Dispatcher is responsible for associating the incoming call with the appropriate operation and then invoking it. 

By creating a custom OperationInvoker you may customize the behavior of how the back-end logic is invoked. 


Windows Server AppFabric Cache provides distributed caching over many servers. It can utilize a cluster of servers that communicate with each other to form a single, unified application cache system. It comes with a decent API, and can be managed using PowerShell.


The Visual Studio solution has  three projects:

Project Description
bLogical.CachingExtension This is the main project, responsible for the custom behavior.
bLogical.WcfWeatherService A WCF service application, applying the CacheOperationBehavior attribute to indicate the response of the method should be cached if possible. The service makes a call to a database to pickup the forecast.
bLogical.Client Client tool calling the two services.


The cache implementation:

Using the Windows Server AppFabric Cache is pretty straight forward. I recommend you read Scott Hanselman’s post on the subject. The post also covers the installation process.

Basically you use the DataCashe.Put method to add the data to the cache, and the DataCache.Get method to retrieve the cached value. Working with the Windows Server AppFabric Cache is similar to using a HashTable, where you add values along with a key (string) which you can later use to get the value back. 


public object Invoke(object instance, object[] inputs, out object[] outputs)
// Serialize all input parameters. The string will be used as the Key to the Cache.
string input = GetSerializedKey(inputs);

// Return value from the Method
object value= this._cacheHelper.Cache.Get(input);

if (value != null)
outputs = new object[0];
return value;
//Invoke the method
value = this._innerOperationInvoker.Invoke(instance, inputs, out outputs);

// Add the return value to the Cache.
this._cacheHelper.Cache.Put(input, value, new TimeSpan(0,0,0,0,this._timeOut));

return value;


I use the input parameters as Key. But as the parameters can be any number of objects, I need to serialize them into an XML string first. I can then use the string as key together with the result from the invoked method. As I don’t want the value to be cached forever, I also pass in a TimeSpan to indicate the lifetime of the cached object.

Using the caching behavior:

You can use the cache behavior either declaratively in your code:

public interface IWeatherForecastService
Forecast GetForecast(string zipCode);

…or through configuration:

<serviceMetadata httpGetEnabled="true"/>
<cachingBehavior timeout="00:10:00" cacheName="bLogical"/>

<add name="cachingBehavior"
type="bLogical.CachingExtension.CacheElement, bLogical.CachingExtension,
Version=, Culture=neutral, PublicKeyToken=49c05550fea0c875"



I’ve run two tests; One with and one without caching enabled. I haven’t got time to run this in any real test environment. But even though I’ve run the test on my local laptop, the tests came out pretty clear.

Without Caching (~3 calls/sec):


(Using Visual Studio profiler, I found the database call to take ~200ms)

With Caching (~23 calls/sec):



Download and install:

1. Download the Windows Server AppFabric.

2. Read Scott Hanselman’s post as to how to set it up.

3. Open PowerShell and run the following commands:

get-command -module DistributedCacheConfiguration

First you need to grant access to your service account:
Grant-CacheAllowedClientAccount [Your Account]
Continue to create the Cache:

New-Cache bLogical

Start the cluster:


4. Download the sample


Using it with BizTalk:

Follow these steps to use the bLogical.CachingExtensions with BizTalk:

  1. Add a key to the bLogical.CachingExtensions project.
  2. Build the project and add it to the GAC.
  3. Open machine.config and add the extension to the behaviorExtensions section.
  4. Open BizTalk Administration Console
  5. Add a Request/Response ReceivePort > Add a Location
  6. Set the transport to WCF-Custom, and click configure
  7. Set the URI and Binding.
  8. On the Behavior tab, add a ServiceBehavior and select the CacheElement:




This Blog


    MVP - Microsoft Most Valuable Professional BizTalk User Group Sweden BizTalk blogdoc

    Follow me on Twitter Meet me at TechEd


    Locations of visitors to this page


    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.