BizTalk's programming model is largely based on orchestrations that, when used in combination with maps, for example, usually provides enough functionality for a range of problems. There can be cases when it is either difficult* or not possible* to represent a solution using
BizTalk's stock toolset.
BizTalk developers can extend BizTalk functionality using C#, Visual Basic .NET, or any .NET-supported language. You package your code in an assembly (DLL), or Class Library project in Visual Studio .NET and reference it from your BizTalk project in Visual Studio like you reference any other assembly (Select Project -> Add Reference from the Visual Studio menu).
You can access your assembly's functionality using an Expression shape from the Orchestration designer toolbox.
On hearing the great news, most developers fire-up Visual Studio and happily start writing a bunch of code (after all, BizTalk uses a declarative approach. If you like code it is hard to resist an opportunity to be in control again by writing your own code). Before you do that, make sure that you really cannot express your proposed solution in BizTalk.
Project Reviews, Architectural Guidance, Design Reviews, New Staff/Candidate Reviews
Contact Erik Westermann for more information (+1 416-809-1453).
When I was learning C++ I got stuck on several problems along the way. I often found myself late at night sitting in front of my noisy 486-based system - its 200Mb hard drive spinning the bits of my solution at the same dizzying rate that I was going through ideas to try to solve my problems. On further reflection about the problem at hand I found that I was standing in my own way - I was not able to find solutions to the problems because my approach was wrong. I ignored the symptom (not being able to solve the problem) and instead focused on finding a solution. I easily came up with an effective solution the moment I changed the way I thought about the problem!
My point is that I see a lot of developers immediately creating new assemblies, writing a bunch of code, and then calling that code through BizTalk. The presence of the code is often a symptom of not understanding the problem, understanding BizTalk, or both.
You need to keep this in mind if you still need to write some code:
- All of the types you use in your code must be serializable. An example of an object that you cannot serialize is SqlConnection.
- You must sign your assembly and deploy it into the GAC (Global Assembly Cache) to be able to call it from your BizTalk solution.
- Since your assembly is in the GAC, you may have to think differently about using configuration values from a config file.
These points are not as bad as they seem. I'll address the first two and leave the last one for you to figure out for your homework.
SOA / BPM / ESB / SaaS / S+S
Forget the alphabet soup - you'll get the main course with our consulting services!
Contact Erik Westermann for more information (+1 416-809-1453).
The first point, about using serializable types, is easy to address: avoid using non-serializable objects! The great thing is that this is pretty easy to do since most types you use day-to-day are in fact serializable.
If you accidentally use a serilaizable type, or cannot avoid using one* you might be tempted to use some unconventenial approaches. For example, if you look around the internet you might find some interesting ways to work around this by tricking the type system into serializing a non-serializable type - use those techniques with extreme caution.
You have to mark your types (classes) serializable for BizTalk to accept them - just add the [Serializable] to your class' declaration. The compiler will gently remind you with a cryptic error message if you lie and use non-serializable types anyway.
The second point - you need to sign your assembly and deploy in the GAC - is also really easy to address. Signing in this sense is actually to Strong Name-ing your assembly. You can use the Strong Name Utility (sn.exe) or use Visual Studio to sign your assembly. Deploying the signed assembly is also easy: just drag the assembly to the c:\windows\assembly folder (it goes there as a copy), or command line enthusiasts - use can use gacutil (gactul.exe).
Note that I will say that I have oversimplified the management aspect of strong naming and deploying assemblies into the GAC. Those topics are out of the scope of this particular article. Let me know if you'd like to see an article about that.
The great feature of both of these points this is that these procedures build on your knowledge of the .NET Framework, so there is not much more for you to learn if you are already familiar with these tasks. If you are not familiar with these tasks, then you'll gain a deeper understanding of the .NET Framework.
Thinking about or already using Commerce Server 2007?
Integrate your CS 2007 solution with CRM, Payment gateways and more!
Contact Erik Westermann for more information (+1 416-809-1453).
Although you can do just about anything you like in your custom assembly, you should carefully consider the performance impact of your code. For example, loading a huge XML document into an XmlDocument object will use a lot of memory, which can slow overall performance due to paging. I personally like to keep my custom code as lean as I can: I use StringBuilder, streaming types, I try to use math whenever I can, and use compact representations of data even if that makes my code a little more complicated. The classic rule still applies - avoid optimizing too early and without knowing whether it is necessary; however, if you know that you are processing very large messages then it makes sense to avoid operating on them entirely in memory.
* - When something seems impossible, it is usually a symptom of incorrectly approaching the solution or having an incomplete understanding of the problem (or both, at worst). You can more effectively address the solution when you understand BizTalk's capabilities - I am happy to say that I have not yet come across a problem I could not solve using BizTalk. Gaining a complete understanding of the problem is an exercise I'll leave to the reader.