We finally started development with BTS and as expected, the first two days were rife with problems.
In our system we are getting a load of data files in different formats that need to be converted into a common schema and then loaded into a database. So we designed the common schema and started on a little data pump which takes the messages, deserialises them and loads them into the database. We didnt try the SQL adapter and updategram route, but we will put a spike in at Iteration 2 and look at that.
Day 1: To start off, we just wanted to see how to call a .NET component from an orchestration and this started off a string of problems. Firstly all the basic samples in the tutorials just dealing with transforming and copying files stopped working. All that HAT said was "Unparsed Interchange" which apparently means that the received file is not recognised (and this for samples that have worked previously in all my demos). For one whole day it didnt work. I posted this on the MSN BizTalkServerStuff group too but to no avail. Finally at the end of the day, just when i was packing up and leaving, one file actually got copied to the correct destination!! Why? no idea. It just started working.
Day 2: Now we had to call a .NET component which takes the data and just dumps it into a file (just to see if we could call our own components). That was yet another struggle. It took a combination of an article by Darren Jefford and another two by Mike Holdorf (parts 1 and 2) + some brainwaves and finally it worked. In the middle of that it took a fair amount of sifting through the Bloggers guide and the BTS Unleashed book to find out how to get debugging working and how to step into VS.NET code (for your component) while debugging an orchestration. The latter didnt work at all inspite of assidously following instructions but we managed to get the basic debugging and stepping from one shape to another working.
Here's the deal on calling your own components
(1) Create a component (strong named) that has a public method taking in either a XmlDocument or an XLANGMessage. Mike H's articles (linked above) will explain the namespaces needed etc. If you are using XLANGMessage you will need to use a RetrieveAs() method on the XLANGMessage object to get back an XmlDocument or Stream or whatever you need. Note that if you use XLANGMessage then you cant actually unit test the component cos you cannot create XLANGMessages outside BizTalk. XmlDocuments might be a better option if you want the unit tests to work.
(2) Include a reference to the project with the component in the orch project.
(3) Create a new orch variable of type 'your component'
(4) In the orchestration, after the Construct Message is finished, drag an EXPRESSION shape in the same path/branch. Ensure that the expression shape is NOT in the scope of the construct message. If it is within the scope it wont call your component.
(5) Edit the expression. use something like
myObject = new <Namespace>.<Class()>
myObject.DoSomething(incomingMessageInstance)
(6)Ensure that the user for the BTS Host Application (running the orchestration) has permissions to do whatever is needed on the folders. In my sample it dumped the data from the incomingMessageInstance into an XML file. In the official code it will de-serialise into a set of business objects.
This worked for us. I didnt have to debug after putting in the expression shape, although i suspect that my earlier problems with stepping into my component code were because it was within the scope of the construct message.
Hope this helps y'all.
More to follow.