by community-syndication | Jun 14, 2010 | BizTalk Community Blogs via Syndication
A former student approached me with a problem related to the Web programming model using WCF in .NET 3.5. In short, he was using a custom IErrorHandler to create a custom fault message, but the client was always receiving a generic error. I knew that WCF REST Starter Kit and WCF 4 both allowed for custom error messages, so I did some digging to see what might be at the root of the problem. It turns out that the WebHttpBehavior inserts its own IErrorHandler and it was getting in the way of the custom handler he was adding. After pointing this out to Dave, he quickly realized he could create a class that derived from the WebHttpBehavior and override the AddServerErrorHandlers to insert his own error handler. He also created the requisite BehaviorExtensionElement so the new endpoint behavior could be added in the configuration file.
public class JsonWebHttpBehavior : WebHttpBehavior
{
protected override void AddServerErrorHandlers(ServiceEndpoint endpoint,
System.ServiceModel.Dispatcher.EndpointDispatcher endpointDispatcher)
{
endpointDispatcher.DispatchRuntime.ChannelDispatcher.ErrorHandlers.Add(
new JsonErrorHandler(endpointDispatcher.DispatchRuntime.ChannelDispatcher.IncludeExceptionDetailInFaults));
}
}
public class JsonWebHttpElement : BehaviorExtensionElement
{
protected override object CreateBehavior()
{
return new JsonWebHttpBehavior();
}
public override Type BehaviorType
{
get { return typeof(JsonWebHttpBehavior); }
}
}
The job of the custom error handler is to create a custom fault class that provides data back to the calling application. This solution nicely takes into consideration the IncludeExceptionDetailsInFaults property to correctly send the details only when configured to do so. In this case, the status code is always set to 500 to trigger the correct error handling in the client library, but you could also modify this to send more specific HTTP status codes depending on the error message caught on the server.
[DataContract]
public class JsonFault
{
[DataMember]
public string ExceptionType;
[DataMember]
public string Message;
[DataMember]
public string StackTrace;
}
public class JsonErrorHandler : IErrorHandler
{
public JsonErrorHandler(bool includeExceptionDetailInFaults)
{
this.includeExceptionDetailInFaults = includeExceptionDetailInFaults;
}
public bool HandleError(Exception error)
{
return false;
}
public void ProvideFault(Exception error,
System.ServiceModel.Channels.MessageVersion version,
ref System.ServiceModel.Channels.Message fault)
{
JsonFault jsonFault;
if (includeExceptionDetailInFaults)
{
jsonFault = new JsonFault
{
ExceptionType = error.GetType().FullName,
Message = error.Message,
StackTrace = error.StackTrace
};
}
else
{
jsonFault = new JsonFault
{
ExceptionType = typeof(System.Exception).FullName,
Message =
"An error occurred on the server. See server logs for details.",
StackTrace = null
};
}
DataContractJsonSerializer serializer =
new DataContractJsonSerializer(typeof(JsonFault));
fault = Message.CreateMessage(version, null, jsonFault, serializer);
fault.Properties.Add(WebBodyFormatMessageProperty.Name,
new WebBodyFormatMessageProperty(WebContentFormat.Json));
WebOperationContext.Current.OutgoingResponse.ContentType = "application/json";
WebOperationContext.Current.OutgoingResponse.StatusCode =
System.Net.HttpStatusCode.InternalServerError;
}
private bool includeExceptionDetailInFaults;
}
You could certainly make modifications to only provide faults for certain types of exceptions (which is what .NET 4 does) log information in the HandleError method, etc. Many thanks to Dave Grundgeiger for the inspiration to look into this and the final solution which he designed and allowed me to share here.

by community-syndication | Jun 14, 2010 | BizTalk Community Blogs via Syndication
The incomparable Mikael H%u00e5kansson has just published the details of my next visit to Sweden this September. After I told Mikael about my latest book, we thought it might be epic to put together a 2 day workshop that highlights the “when to use what” discussion. Two of my co-authors, Stephen Thomas and Ewan Fairweather, […]
by community-syndication | Jun 14, 2010 | BizTalk Community Blogs via Syndication
I have seen many BizTalk customers running into OutofMemory Exception while calling a map from inside the Orchestration, so I thought this blog post should help.
Typically, this happens when we are calling a map from inside the Orchestration and the map is inside a large assembly. This was a known issue and was documented at http://support.microsoft.com/kb/918643
“The System.Policy.Security.Evidence object is often used in transforms and can consume much memory. Whenever a map contains a scripting functoid that uses inline C# (or any other inline language), the assembly is created in memory. The System.Policy.Security.Evidence object uses the object of the actual calling assembly. This situation creates a rooted object that is not deleted until the BizTalk service is restarted.
Most of the default BizTalk functoids are implemented as inline script. These items can cause System.Byte[] objects to collect in memory. To minimize memory consumption, we recommend that you put any map that uses these functoids into a small assembly. Then, reference that assembly.”
So for example if you have got the map inside a 10 MB Assembly, it will always create 10 MB System.Byte[] objects in the memory and you can imagine how quickly you could run into the OOM Exception if you are on a 32 bit environment. Earlier only workaround was to put map in the small assembly but if you are not able to split the maps and other artifacts by different project, then the good news is that this issue is fixed in http://support.microsoft.com/?id=975118.
This hotfix has been released for BizTalk 2006, BizTalk 2006 R2 and BizTalk 2009. Also, this hotfix is part of BizTalk 2006 R2 SP1.
I have seen that this hotfix improves memory utilization by the orchestration hosts. This also helps increase performance and stability of the BizTalk applications. If you haven’t got this fix as of yet, I will highly recommend to apply this fix ASAP.
by community-syndication | Jun 14, 2010 | BizTalk Community Blogs via Syndication
For those of you that attended the “Real World SOA with .NET and Windows Azure” TechEd session that John deVadoss, Christoph Schittko and I did last week, I discussed the following reference architecture:
I didn’t have time to do a demo/walkthrough during the session, but as I mentioned, recordings are available:
- The first video, which focuses on the on-premise side in detail, is available here
- The second video, which focuses on the Windows Azure AppFabric relay aspect and how to implement it, is available here (note that this is #1 of 3 there are three videos and corresponding blog posts in this series that cover bridging between on-premise BizTalk and Windows Azure)
Thanks all that attended, we had fun, and the feedback has been great.
by community-syndication | Jun 14, 2010 | BizTalk Community Blogs via Syndication
This is the third in a series of posts on the new features included in BizTalk Server 2010 Beta. Enabling the BizTalk mapper and the BizTalk Adapter Pack in Windows Workflow Foundation is the starting point of Microsoft’s aim for a deep integration between BizTalk Server and Windows Server AppFabric. The first added feature is […]
by community-syndication | Jun 14, 2010 | BizTalk Community Blogs via Syndication
I opened up a codeplex project for housing some custom WCF binding work I have been doing: http://customwcfbindings.codeplex.com/.I uploaded my progress on a custom SalesForce binding based on the WCF LOB SDK if you want to take a look. There are a couple bugs I would like to get out of the way before making […]
by community-syndication | Jun 13, 2010 | BizTalk Community Blogs via Syndication
You can now download the beta of BizTalk 2010 from the BizTalk site at Microsoft: www.microsoft.com/biztalk
Please have a look, I’ve been running it for a while now and it looks good thus far.
If you encounter any issues please contact me: [email protected]
by community-syndication | Jun 12, 2010 | BizTalk Community Blogs via Syndication
At Pluralsight, we just released all of our .NET training videos for the iPad. If you’re a subscriber, you can get them now.
Last week at TechEd in New Orleans, we gave away 1000 complimentary subscriptions to the Pluralsight On-Demand! training library. It’s a white plastic card that looks something like this:
If you activate this card by 6/18 (next Friday), you will receive a 2-week subscription to our training library and you’ll be automatically entered to win a brand new 64 GB iPad sitting here on my desk (unopened). The winner will also receive a 1-year Professional subscription to Pluralsight On-Demand!, which makes it possible to fill up your the iPad with our .NET training courses.
We will announce the winner on 6/21. Will we announce it on Twitter (follow @pluralsight) and email the winner.
Don’t forget to activate your card – it only takes a few seconds. Instructions are on the back.

by community-syndication | Jun 12, 2010 | BizTalk Community Blogs via Syndication
Just came across this great sitewith a collection of color schemes for Visual Studio 2010 and older versions too. There are some real beauties there. I quite like the retro look of Turbo-Pascal Revisited (though i doubt i could use it for a long time without drowning in the blue) and have started to use […]
by community-syndication | Jun 12, 2010 | BizTalk Community Blogs via Syndication
TechEd North America 2010 is a wrap. You can grab the demos from both of my sessions here. Hope you enjoyed them.
Feel free to connect with me on Twitter (@skonnard) to stay in touch after the event. Also, I’ll be posting a bunch of pictures from the week to the Pluralsight .NET Training page on Facebook.
One of my favorite experiences from the week: we ran into a street band while walking back to the hotel one night, they were jamming New Orleans style and everyone was watching this little girl dance away. Awesome.

