Geeks With Blogs

News View Michael Stephenson's profile on BizTalk Blog Doc View Michael Stephenson's profile on LinkedIn

Post Categories

Michael Stephenson keeping your feet on premise while your heads in the cloud

Ive recently put together a WCF step for BizUnit to help us with predominantly with projects using BizTalk 2006 R2.  However remember that BizUnit can be used without BizTalk

Anyway this article will provide some information about the how this is implemented.  There is also a link to the sample application at the bottom.  In the sample I demonstrate how to call the service in a normal test, then how to use dynamic code and reflection to execute the same test.  This dynamic code is basically what is implemented inside the custom BizUnit step.  The third test demonstrates how to call BizUnit and allow it to execute your test.


The aim of the step is to recreate the standard SoapRequestResponseStep that comes out of the box with BizUnit but to do this for WCF services instead.  The step will not care about the implementation details of channels and behaviours as it is expected that this will be handled in the configuration files.

Using the BizUnit Step

Using the BizUnit step is supposed to be easy.  Im going to assume you have used BizUnit before (if not there are many great articles on the net about this)

The steps to use the BizUnit step are as follows:

1. Ensure that the test can access a proxy to your service

In the sample I have a shared assembly which contains details of the contract.  I reference this so that it is copied to the bin directory for my test.  Other ways to do this include adding a service reference from your test project.

2. Setup  the configuration file with the bindings for your service.  This is the same as when you use any WCF service.  You need to setup the bindings etc.

3. Create the xml file which will contain your request message.  This should deserialize to the type which will represent the input to the service

4. Create your BizUnit test file.  The picture below shows the example from the sample below.

The key points in the file are:

  • The various type names should equate to the type names for the interface and input to the service.
  • The contract name relates to the name given to the endpoint in the config file.  If no name is given it will simply load it based on the Interface Type name
  • You can add validators to validate and inspect the response from the service in the normal way you would for BizUnit.  This means you can do things like a schema validation on the response from your service.

5. Ensure the BizUnit step assembly is copied to the bin directory so the path is correct based on that in the BizUnit test file.  I normally do this by simply adding a reference from your Test Project.

6. Write the C# code to call your BizUnit Test.

Hopefully you can see from above there is only a couple of additional things which need to be done in addition to a normal BizUnit test making this fit quite well into the normal BizUnit way of doing things.

Design Decision

One thing people may ask about is why I dont dynamically create the code on the fly for the proxy by looking at the service meta data.  This would be a similar approach to the Soap step already in BizUnit.  To be honest either would have been fine, but what I tend to find on projects (BizTalk ones anyway) is that I usually have a simple windows forms app which is part of the solution and I use it to demonstrate things.  Anyway because of this I will have an assembly containing proxies anyway, so I just reuse this for my tests.  The other reason is for the Soap step I think I remember it creating a new proxy assembly for each individual test which can sometimes result in lots of files being created.


Hopefully you will find this post useful and if there is enough feedback wanting to know more about the internals of the step then I may do an additional post about it.  However until then just download the sample below.

Note: When you are going to run the tests, remember to run the host executable so the service is up and running before you run the test.


I have noticed a few sites that seem to copy the content of blog articles and display them in their own site.  It is a bit annoying that they do not clearly reference or acknowledge the author so I have decided to put this note on the bottom of all of my posts from now so it is clear who wrote it.

This article was written by: Michael Stephenson

The source of this article is:

Posted on Sunday, February 3, 2008 12:20 AM BizTalk , BizTalk Testing | Back to top

Comments on this post: Dynamic WCF Step for BizUnit

# re: Dynamic WCF Step for BizUnit
Requesting Gravatar...
Pretty useful test step - especially when wcf is such an important part of R2. Also, as long as we are talking about Bizunit, you may want to check out BizUnit Designer - a GUI that allows rapid creation of BizUnit test cases which can be used for unit testing or system testing distributed applications.
Left by Praneeth Reddy on Mar 23, 2008 1:22 PM

# re: Dynamic WCF Step for BizUnit
Requesting Gravatar...
Thanks a lot for the component! It came very useful in my BizTalk 2009 testing!
One thing that I had to fix is the implementation of the Execute method - it was actually using the constants instead of the values from config.
Also when a fault is returned from the orchestration, the exception is being wrapped into a generic BizUnit exception. As a result, it's impossible to use the ExpectedExceptionAttribute - but I guess it's BizUnit's issue.
Left by Alex Kaganov on Dec 29, 2009 3:59 PM

# re: Dynamic WCF Step for BizUnit
Requesting Gravatar...
Thanks for the reply! I didn't mean to make you remember all this stuff - just wanted to post for future users to save them some time.
I don't think though that using a ValidationStep would help. When a SOAP fault is returned, it shows up as an exception on the caller's side. I returned a typed exception, however, BizUnit wraps it up into its own type. I can still examine it through the InnerException property (actually two levels deep) but that prevents me from using [ExpectedException] attribute on my test method. Oh well, a minor inconvenience..
Left by Alex Kaganov on Jan 08, 2010 3:25 PM

# re: Dynamic WCF Step for BizUnit
Requesting Gravatar...

I cannot see the link to download the source code. Can you please help?

Left by Payal on Aug 10, 2010 5:22 AM

# re: Dynamic WCF Step for BizUnit
Requesting Gravatar...
Hi Michael,
Thanks for the post . I'm becoming a fan of you as I read through each of your posts :-)

WCF is not without security . Can you please enhance this to add a digital certificate for the wcf call

Left by Suresh Gladstone on Oct 27, 2010 4:39 PM

# re: Dynamic WCF Step for BizUnit
Requesting Gravatar...
I can't see the link to download the source code either. Does anyone have it?

(I suppose another option would be to make a call into my own class library and make the WCF call there).
Left by Nelson Robin on Jan 18, 2011 11:26 AM

# re: Dynamic WCF Step for BizUnit
Requesting Gravatar...

Nelson - Some companies block access to which means the widget on the page does not show up. If you cant get it from home drop me a line and you should be able to access it

Suresh - You should be able to use the standard WCF configuration to do pretty much anything you want with the normal bindings and behaviours and also plug in your own. Im assuming you might be referring to configuring the proxy in code which I would say try to do it in config because it will be easier, but if you want to use code then feel free to modify the sample as you need to

Left by Mike on Jan 21, 2011 5:11 PM

# re: Dynamic WCF Step for BizUnit
Requesting Gravatar...
Are you excited for NBA 2K18 Game? NBA 2k18 Game will feature NBA basketball games with real effects and customized players and teams. This game created with latest designed, game commentary, halftime shows and even various visual features and lighting, player animations and camera angles will be improved than previous series.
Left by Adam Doughty on Apr 09, 2017 11:33 PM

# re: Dynamic WCF Step for BizUnit
Requesting Gravatar...
find out most amazing quotes shayari in hindi online from here. we are sharing all details online attitude whatsapp status we are sharing all details shayari in hindi
Left by Quotes Hindi on Jul 10, 2017 10:47 PM

Your comment:
 (will show your gravatar)

Copyright © Michael Stephenson | Powered by: