BizTalk AS2 and Chunked Encoding (Disable it!)

In a recent project with a client we were configuring our messaging-only AS2 solution for moving data to and from their customers via AS2 (HTTP).  We had successfully moved a few customers on to the BizTalk 2009 solution already but ran into a strange issue while testing another client.
During testing, we generally used smaller test messages that could be easily detected and thrown away so we did not pick up on this problem initially.  My client stated noticing that when larger AS2 payloads were sent (by larger I mean maybe 1 kbyte and larger files so not big) we were getting HTTP connection errors.  The error message was: "Unable to read data from the transport connection.  The connection was closed.”  It appeared the remote HTTP server was closing the connection sooner than BizTalk expected.  Strangely enough, the payload seemed to go though most of the time anyway.
Originally, while researching this issue we came across many anecdotes about HTTP Keep Alives and how some Apache servers did not jive well with using that feature so we tried turning them off in our AS2 party configuration.  Nothing changed, however.  We investigated everything from firewall logs on both sides to considering sniffing the wire to see what the HTTP communication was doing.
The Fix
In the end, nothing we tried fixed the issue so I went back to the basics, read through all the Microsoft documentation and AS2 walkthroughs when finally I saw something that caught my eye: "Enable Chunked Encoding" was explicitly disabled/unchecked on the HTTP send ports.  There was no rationale as to why this was done so it very quickly fell through the cracks.  As soon as we unchecked Enable Chunked Encoding on the send ports of this customer the problem went away and we’ve been sailing smooth ever since.

BizTalk BAM Portal failure and configuration woes

Well … BizTalk just never fails to surprise me with the "one-thing-after-another" issues which I run into…
Symptom …
I did a fres BizTalk 2009 install on a virtual machine for some PoC deveopment … went to prepare a demo of BAM and the BAM Portal and when I hit the website it just failed with a generic message.  Well … as is standard practice at this point it MUST have been something I did wrong … so I decided I needed to fix the issue by re-configuring the BAM Portal.
The First Try …
For some reason, I had the bright idea that I should delete the BAM Portal web applications and app pool before un-configuring. I did that, restarted IIS and ran the BizTalk configuration tool.  Next, I un-configured the BAM Portal and completed the wizard … no problems, right? Of course not!  When I went back into the BizTalk Configuration Tool to configure the BAM Portal feature the services accounts and website options were disabled!
The Second Try …
It turns out that the BAM database was still configured to point to the original website even though I had unconfigured that feature.  So, according the this blog post I needed to use BM.exe to remove that configuration information.
The Fix…
  1. Open the command prompt and find your way to BM.exe (Program FilesBizTalk …tracking)
  2. Retrieve the current configuration information:
    bm get-config -FileName:"BAM_Config.xml"
  3. Update the config file to remove the reference to the current website:
    <GlobalProperty Name="BAMVRoot">http://blah.blah.remove.this.URL</GlobalProperty&gt;
  4. Update the BAM configuration database:
    bm update-config -FileName:"BAM_Config.xml"
  5. Re-run the BizTalk Configuration Tool and re-configure the BAM Portal feature and you should be good to go


Nothing in BizTalk is as it seems Wink

BizTalk Error: Failed to grant permission to execute. (Exception from HRESULT: 0x80131418)

Here is an issue I ran into for BizTalk 2009 when using the WCF-BasicHttp or WCF-WSHttp adapter. 
I received the following error:
The adapter "WCF-WSHttp" raised an error message. Details "System.Security.Policy.PolicyException: Failed to grant permission to execute.
What was I doing?
What I was trying to do is expose a schema as a web service endpoint so that any calls to that service would dump that message straight to the message box.  Now … not wanting to expose my internal schema I created a schema definition especially for this service and a corresponding map to map it to my canonical/internal schema.  Deployed the solution.
Next, I used the handy BizTalk WCF Service Publishing Wizard to create the .svc and ports, etc.  I then updated the Receive Port to run the map.  When I tested the endpoint I got the above error.  I then removed the map and the test ran succesfully (albeit with my intended map). 
What the heck was happening?
Well … as luck would have it I had quickly ramped up this virtual server environment and put the portal on port 80 which meant WSS was running on port 80.  Upon inspecting the .NET Trust Level for my web application it was set to WSS_Minimal!!! Arggg!  I had spent way too much time on this one!
What was the fix?
Just some things to remember when setting up a web application to run a service into BizTalk:
  • Create a separate App Pool running as a user that has permission to the BizTalk Isolated Host (I just ran it as my BizTalk Iso service account as a shortcut)
  • Make sure this app pool is running as classic mode and not integrated mode
  • CHECK THE TRUST LEVEL to make sure it is appropriate … in my case I just set it to Full Trust to get it through my test
  • Don’t for get to enable the receive location, it is not enabled by the wizard … you couldn’t imagine how many times I forgot to do this while trying to figure out why my darn service isn’t working again!

Well … hope this helps someone else!

Visual Studio Team Test: Web Tests and IE8

I ran into an interesting problem while trying to create a demo for Visual Studio 2008 using the Web Test macro recorder (IE plugin) and Internet Explorer 8. 
The test website I had was on my local PC so I started recording and typed in the localhost address.  Suddenly, the macro recording stopped and only had a message stating the the recording had to be initiated via Visual Studio.  Also, the recording had stopped within Visual Studio as well … no steps were added to the test script.
After scratching my head, searching the net, and gazing into the air I realized that IE was switching from the Internet Zone (for the default about:blank page) to the Local Intranet Zone (for my web site).  To fix this, I manually added about:blank to my list of Intranet sites and everything worked as expected.
I am not sure if there is any more legit fix to this but this worked fine for me!

Silverlight 2.0: Creating an Offline Application (Smart Client), Part 1

The following is part 1 of a series of posts for creating an offline application using Silverlight 2.0


Once of the alluring aspects of Silverlight is creating an application with a pretty broad reach (cross-platform/browser) using technologies familiar to the “Microsoft Developer” (C#, VB.NET, etc.) together with some common application patterns (smart clients).  This series of posts is intended to plug the gap in creating a Silverlight 2.0 application that completes the “smart client” pattern with occasionally connected (read: “offline”) features.


Silverlight does have many of the aspects of a “smart client,” such as …

  • Automatic/intelligent installation and update
  • Broad client platform/device reach
  • “Connected” to back-end services (like LOB logic)
  • Use of local resources

… and some added of it’s own:

  • Very small runtime size (~4 MB)
  • Low client requirements (a browser)
  • Declarative programming model (XAML)
  • Rich UI Framework (Rich Internet Application)

However, it currently lacks formalized support for the most prominent feature of being occasionally connected.  Customers, however, are unwilling to compromise and want all of the above, together, without having to learn a new platform and a set of technologies (like Flash, for example).

Silverlight 3.0 promises new features to help in implementing these new features it is not out yet (in Beta at this time) and customers may already have a need for Silverlight today or have existing application in Silverlight 2.0.


The good news is that, with one exception, Silverlight 2.0 is fully equipped to handle the offline scenario with little additional effort over what may be coming in 3.0 or what you may have today with other Smart Client or Rich Internet Application (RIA) technologies.

The following techniques will be demonstrated in the upcoming series of posts:

  1. Offline, persistent, secure storage: Isolated Storage
  2. Synchronization with back-end services
  3. Detecting the network and connectivity to the back-end services
  4. Re-launching the application while offline

Companies can create fully disconnected application today in Silverlight 2.0 and I’ll walk you thought the process in upcoming posts.  If you would like to see anything specific please feel free to add some comments and I’ll try and incorporate those into subsequent posts.

Silverlight: Cloud Connected

A few weeks back I delivered a presentation on connecting Silverlight to services (web, SOAP, REST, etc.) as well as some practical real-world offline caching of data.
Here was the actual agenda from the slides:
  • “Wiring” up a Silverlight 2.0 application to a bunch of services
  • Demonstrations of leveraging WCF, ASP.NET Data Services/REST, XML
  • How you can quickly bind data through XAML in a pain-free manner.
  • A glimpse into the designer/developer workflow
  • Some discussions on differences you’ll notice from WPF.
  • A hands-on demo of the tools you’ll use in SL development
  • Some other stuff (LINQ, Lambda expressions, type inference, blah blah blah blah)
  • Working with IsolatedStorage in an attempt to have this thing work offline
Demo code is here.  Slides are here.

Review of online game trading sites: Goozex, SaySwap, GameTZ

I put up a review of some online game trading sites on … check it out:Do you have a bunch of old games you want to sell/trade? Gamestop/EB is
always an option, but we all know they have some pretty crappy trade in
prices. You could always try one of the many online game trading sites.
But, which one is best? See
this review to get a better idea of what to
expect from these online game trading services….

SOA – Service-Oriented Architecture

I just completed another webinar as part of CEI’s .NET Webinar Series. This time, the topic was Service-Oriented Architecture (SOA) with demos using WSE 3.0. You can download the slides and code below and if you have any questions you can either post them here or email myself or Eric directly. 

The agenda was:

  • SOA: Definition and Rationale
  • The Shift to Service-Orientation
  • SOA: Best Practices
  • Microsoft Solutions for SOA

Demos include:

  • Contract-first using XML Schema, xsd.exe, and WSDL
  • Policy-based security (WS-Security) and WSE 3.0
  • Schema Rationalization/Canonicalization
  • Perimeter/Referral routing using WSE and WS-Messaging (using SoapHttpRouter)

SOA Slides
Demo Code

Visual Studio Unit Testing an asynchronous event callback

Problem …
Long title … simple problem: I am writing automated unit test cases for an asynchronous method call which returns back via an event handler (a callback).

If I had architected the method that I am calling I would have used the standard Begin/End methods to handle the asynchronous calls but I am using a pre-written source code so I need to adhere to its methodology.

Solution …
Nonetheless, I needed a way to have a TestMethod make the asynchronous method call and then somehow get the results back from the event handler. I was not (am still not) aware of anything built-in to NUnit or Visual Studio Unit Testing to handle this
so I figured I was on my own.

I figured that all I really needed was a way to sleep the test method until the event handler is called and then signal it to continue and analyze the data returned from the event. Signal. I had heard that before when talking about Thread Synchronization … threading … that is what the event callback is … duh. I need a thread signal!

Enter AutoResetEvent …
Very fortunately for me, .NET has built-in just such a signal using a class called AutoResetEvent (System.Threading). Once I realized this, the code was frighteningly simple. One thread creates the signal object (initializing its state to un-signaled) and waits on it. The second thread sets the signal and the initial thread continues.

Here’s some code:

  1. using System.Threading;
  2. using Microsoft.VisualStudio.TestTools.UnitTesting;
  3. namespace MyTests
  4. {
  5. [TestClass]
  6. public class MyTestClass
  7. {
  8. AutoResetEvent _TestTrigger;
  9. DataType _MyData;
  10. [TestMethod]
  11. public void MyTestMethod()
  12. {
  13. this._TestTrigger = new AutoResetEvent(false);
  14. MyAsyncCall();
  15. this._TestTrigger.WaitOne();
  16. Assert.AreEqual()
  17. }
  18. private void My_EventHandler()
  19. {
  20. this._MyData = result from event handler;
  21. this._TestTrigger.Set();
  22. }
  23. }
  24. }

You can make modifications to this so that the calling method does not wait indefinitely as well as other handy mods. If you come up with anything cool please drop a comment here so everyone can share in your find!

Atlas – AJAX Programming for the .NET 2.0 Framework

I just completed a webinar on using Microsoft’s Atlas framework for creating "AJAX" applications in ASP.NET 2.0.  Despite that one of my demos failed to work (my poor, poor typing skills) the webinar went well.
The webinar started with an introduction to AJAX with a little (read: cheesy) demo of AJAX using a text editor and a browser.  The presentation moved into an overview of the Atlas framework and a decription of the client- and server-side architectures and improvements.  Of course, this all included some more cheesy demos (yet representitive) of:
  • Client-Side O-O API
  • Client-Side Declarative XML
  • Server-Side Control Extenders
  • Server-Side Partial Rendering (UpdatePanel)

For anyone that wants them … here are links to my slides and code:

For more information I recommend you check out the Atlas home page at: .